[cfe-commits] r149109 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/SemaCXX/for-range-examples.cpp

John McCall rjmccall at apple.com
Thu Jan 26 17:29:44 PST 2012


Author: rjmccall
Date: Thu Jan 26 19:29:43 2012
New Revision: 149109

URL: http://llvm.org/viewvc/llvm-project?rev=149109&view=rev
Log:
Be sure to emit delayed diagnostics after parsing the declaration
of a for-range variable.  Fixes PR11793.

Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/test/SemaCXX/for-range-examples.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=149109&r1=149108&r2=149109&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Jan 26 19:29:43 2012
@@ -1110,6 +1110,7 @@
     Decl *ThisDecl = Actions.ActOnDeclarator(getCurScope(), D);
     Actions.ActOnCXXForRangeDecl(ThisDecl);
     Actions.FinalizeDeclaration(ThisDecl);
+    D.complete(ThisDecl);
     return Actions.FinalizeDeclaratorGroup(getCurScope(), DS, &ThisDecl, 1);
   }
 

Modified: cfe/trunk/test/SemaCXX/for-range-examples.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/for-range-examples.cpp?rev=149109&r1=149108&r2=149109&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/for-range-examples.cpp (original)
+++ cfe/trunk/test/SemaCXX/for-range-examples.cpp Thu Jan 26 19:29:43 2012
@@ -148,3 +148,13 @@
   }
   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'}}
+  }
+}





More information about the cfe-commits mailing list