]> granicus.if.org Git - clang/commitdiff
Be sure to emit delayed diagnostics after parsing the declaration
authorJohn McCall <rjmccall@apple.com>
Fri, 27 Jan 2012 01:29:43 +0000 (01:29 +0000)
committerJohn McCall <rjmccall@apple.com>
Fri, 27 Jan 2012 01:29:43 +0000 (01:29 +0000)
of a for-range variable.  Fixes PR11793.

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

lib/Parse/ParseDecl.cpp
test/SemaCXX/for-range-examples.cpp

index ac9b11289dc6976c3d472803b75624e58a99db07..b04baa7db88f2fe7104169cebb6a8c993393293f 100644 (file)
@@ -1110,6 +1110,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS,
     Decl *ThisDecl = Actions.ActOnDeclarator(getCurScope(), D);
     Actions.ActOnCXXForRangeDecl(ThisDecl);
     Actions.FinalizeDeclaration(ThisDecl);
+    D.complete(ThisDecl);
     return Actions.FinalizeDeclaratorGroup(getCurScope(), DS, &ThisDecl, 1);
   }
 
index b994e8c10bd612fdcc2434a51dbc24d2f510f4b6..dd356032cfb8acc183b10d6bdf2432c8caa112be 100644 (file)
@@ -148,3 +148,13 @@ int main() {
   }
   assert(total == 500);
 }
+
+// PR11793
+namespace test2 {
+  class A {
+    int xs[10]; // expected-note {{implicitly declared private here}}
+  };
+  void test(A &a) {
+    for (int x : a.xs) { } // expected-error {{'xs' is a private member of 'test2::A'}}
+  }
+}