]> granicus.if.org Git - clang/commitdiff
Return a declaration to the parser when creating a field in C++ so that
authorJohn McCall <rjmccall@apple.com>
Tue, 15 Feb 2011 07:12:36 +0000 (07:12 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 15 Feb 2011 07:12:36 +0000 (07:12 +0000)
the parser will complete the declarator with a valid decl and thus trigger
delayed diagnostics for it.  It certainly looks like we were intentionally
returning null here, but I couldn't find any good reason for it, and there
wasn't a comment, so farewell to all that.

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

lib/Sema/SemaDeclCXX.cpp
test/CXX/class.access/p6.cpp

index 370def568e21ea6ec45049fe8a5db16b8ba3c81c..f929aa039ed4f717cf0bf762a176c785e71ff125 100644 (file)
@@ -1077,10 +1077,8 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
   if (Deleted) // FIXME: Source location is not very good.
     SetDeclDeleted(Member, D.getSourceRange().getBegin());
 
-  if (isInstField) {
+  if (isInstField)
     FieldCollector->Add(cast<FieldDecl>(Member));
-    return 0;
-  }
   return Member;
 }
 
index 87957084747a60d36c5806fcc38a624b138eacfc..1112699c8b9ad05f4ba380edb3d22f53e5e299f2 100644 (file)
@@ -139,3 +139,17 @@ namespace test5 {
     template <A::Enum en> class bar {}; // expected-error {{'Enum' is a private member of 'test5::A'}}
   };
 }
+
+namespace test6 {
+  class A {
+  public: class public_inner {};
+  protected: class protected_inner {};
+  private: class private_inner {}; // expected-note {{declared private here}}
+  };
+
+  class B : A {
+    public_inner a;
+    protected_inner b;
+    private_inner c; // expected-error {{ 'private_inner' is a private member of 'test6::A'}}
+  };
+}