]> granicus.if.org Git - clang/commitdiff
When parsing a cast-expression that starts with a scope annotation,
authorDouglas Gregor <dgregor@apple.com>
Fri, 23 Apr 2010 02:08:13 +0000 (02:08 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 23 Apr 2010 02:08:13 +0000 (02:08 +0000)
try to annotate as a type first to determine whether we have a
functional-style cast. Patch by Eli Friedman, fixes PR6830.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102161 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExpr.cpp
test/SemaCXX/qualified-id-lookup.cpp

index 588825b01ca4fbcecdaf449374d43121a78188df..b9e632a1846e42f57c4015b781db287eaefeac25 100644 (file)
@@ -788,6 +788,14 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
   }
 
   case tok::annot_cxxscope: { // [C++] id-expression: qualified-id
+    // If TryAnnotateTypeOrScopeToken annotates the token, tail recurse.
+    // (We can end up in this situation after tentative parsing.)
+    if (TryAnnotateTypeOrScopeToken())
+      return ExprError();
+    if (!Tok.is(tok::annot_cxxscope))
+      return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
+                                 NotCastExpr, TypeOfCast);
+
     Token Next = NextToken();
     if (Next.is(tok::annot_template_id)) {
       TemplateIdAnnotation *TemplateId
index abde62efceae3bcbae557d5e1cfddde300c8bb5f..dfb059aa36ad00cac24ec295c390fb64da82782f 100644 (file)
@@ -124,3 +124,25 @@ namespace test1 {
 
   template class ClassChecker<int>;  
 }
+
+namespace PR6830 {
+  namespace foo {
+
+    class X {
+    public:
+      X() {}
+    };
+
+  }  // namespace foo
+
+  class Z {
+  public:
+    explicit Z(const foo::X& x) {}
+
+    void Work() {}
+  };
+
+  void Test() {
+    Z(foo::X()).Work();
+  }
+}