[cfe-commits] r104937 - in /cfe/trunk: lib/Sema/SemaAccess.cpp test/CXX/class.access/class.access.base/p1.cpp test/CXX/class.access/class.access.base/p5.cpp test/CXX/class.access/class.friend/p1.cpp test/CXX/class.access/class.protected/p1.cpp test/CXX/class.access/p4.cpp test/SemaCXX/access-base-class.cpp

Douglas Gregor dgregor at apple.com
Thu May 27 21:34:56 PDT 2010


Author: dgregor
Date: Thu May 27 23:34:55 2010
New Revision: 104937

URL: http://llvm.org/viewvc/llvm-project?rev=104937&view=rev
Log:
When we complain about a member being inaccessible due to a constraint
along an access path, add another note pointing at the member we
actually found.

Modified:
    cfe/trunk/lib/Sema/SemaAccess.cpp
    cfe/trunk/test/CXX/class.access/class.access.base/p1.cpp
    cfe/trunk/test/CXX/class.access/class.access.base/p5.cpp
    cfe/trunk/test/CXX/class.access/class.friend/p1.cpp
    cfe/trunk/test/CXX/class.access/class.protected/p1.cpp
    cfe/trunk/test/CXX/class.access/p4.cpp
    cfe/trunk/test/SemaCXX/access-base-class.cpp

Modified: cfe/trunk/lib/Sema/SemaAccess.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAccess.cpp?rev=104937&r1=104936&r2=104937&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaAccess.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAccess.cpp Thu May 27 23:34:55 2010
@@ -870,6 +870,10 @@
         << BS->getSourceRange()
         << (BaseAccess == AS_protected)
         << (BS->getAccessSpecifierAsWritten() == AS_none);
+      
+      if (D)
+        S.Diag(D->getLocation(), diag::note_field_decl);
+      
       return;
     }
   }

Modified: cfe/trunk/test/CXX/class.access/class.access.base/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/class.access.base/p1.cpp?rev=104937&r1=104936&r2=104937&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.access/class.access.base/p1.cpp (original)
+++ cfe/trunk/test/CXX/class.access/class.access.base/p1.cpp Thu May 27 23:34:55 2010
@@ -54,8 +54,10 @@
 //   of the base class are accessible as protected members of the
 //   derived class.
 namespace test1 {
-  class Base {
-  public: int pub; static int spub;
+  class Base { // expected-note 6{{member is declared here}}
+  public: 
+    int pub; // expected-note{{member is declared here}}
+    static int spub; // expected-note{{member is declared here}}
   protected: int prot; static int sprot; // expected-note 4 {{declared protected here}}
   private: int priv; static int spriv; // expected-note 8 {{declared private here}}
   };
@@ -102,13 +104,15 @@
 //   the base class are accessible as private members of the derived
 //   class.
 namespace test2 {
-  class Base {
+  class Base { // expected-note 6{{member is declared here}}
   public:
-    int pub;
-    static int spub;
+    int pub; // expected-note{{member is declared here}}
+    static int spub; // expected-note{{member is declared here}}
   protected:
-    int prot; // expected-note {{declared protected here}}
-    static int sprot; // expected-note {{declared protected here}}
+    int prot; // expected-note {{declared protected here}} \
+    // expected-note{{member is declared here}}
+    static int sprot; // expected-note {{declared protected here}} \
+    // expected-note{{member is declared here}}
   private:
     int priv; // expected-note 4 {{declared private here}}
     static int spriv; // expected-note 4 {{declared private here}}

Modified: cfe/trunk/test/CXX/class.access/class.access.base/p5.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/class.access.base/p5.cpp?rev=104937&r1=104936&r2=104937&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.access/class.access.base/p5.cpp (original)
+++ cfe/trunk/test/CXX/class.access/class.access.base/p5.cpp Thu May 27 23:34:55 2010
@@ -27,7 +27,7 @@
   };
 
   struct D {
-    public: static int x;
+    public: static int x; // expected-note{{member is declared here}}
     static int test() { return x; }
   };
   struct E : private D { // expected-note{{constrained by private inheritance}}
@@ -45,7 +45,7 @@
 
 namespace test2 {
   class A {
-  protected: static int x;
+  protected: static int x; // expected-note{{member is declared here}}
   };
 
   class B : private A {}; // expected-note {{private inheritance}}

Modified: cfe/trunk/test/CXX/class.access/class.friend/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/class.friend/p1.cpp?rev=104937&r1=104936&r2=104937&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.access/class.friend/p1.cpp (original)
+++ cfe/trunk/test/CXX/class.access/class.friend/p1.cpp Thu May 27 23:34:55 2010
@@ -121,7 +121,7 @@
     friend struct ilist_walker_bad;
     X *Prev;
   protected:
-    X *getPrev() { return Prev; }
+    X *getPrev() { return Prev; } // expected-note{{member is declared here}}
   };
 
   class ilist_node : private ilist_half_node { // expected-note {{declared private here}} expected-note {{constrained by private inheritance here}}

Modified: cfe/trunk/test/CXX/class.access/class.protected/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/class.protected/p1.cpp?rev=104937&r1=104936&r2=104937&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.access/class.protected/p1.cpp (original)
+++ cfe/trunk/test/CXX/class.access/class.protected/p1.cpp Thu May 27 23:34:55 2010
@@ -2,8 +2,10 @@
 
 namespace test0 {
   class A {
-    protected: int x; // expected-note 3 {{declared}}
-    static int sx; // expected-note 3 {{declared}}
+    protected: int x; // expected-note 3 {{declared}} \
+    // expected-note {{member is declared here}}
+    static int sx; // expected-note 3 {{declared}} \
+    // expected-note {{member is declared here}}
   };
   class B : public A {
   };
@@ -136,8 +138,8 @@
 namespace test4 {
   class C;
   class A {
-    protected: int x; // expected-note 2 {{declared}}
-    static int sx;
+    protected: int x; // expected-note 3 {{declared}}
+    static int sx;    // expected-note 3{{member is declared here}}
     static void test(C&);
   };
   class B : public A {
@@ -174,8 +176,8 @@
 namespace test5 {
   class D;
   class A {
-    protected: int x;
-    static int sx;
+    protected: int x; // expected-note 3{{member is declared here}}
+    static int sx; // expected-note 3{{member is declared here}}
     static void test(D&);
   };
   class B : public A {
@@ -326,11 +328,12 @@
 }
 
 namespace test9 {
-  class A {
-  protected: int foo(); // expected-note 8 {{declared}}
+  class A { // expected-note {{member is declared here}}
+  protected: int foo(); // expected-note 8 {{declared}} \
+    // expected-note {{member is declared here}}
   };
 
-  class B : public A {
+  class B : public A { // expected-note {{member is declared here}}
     friend class D;
   };
 

Modified: cfe/trunk/test/CXX/class.access/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/p4.cpp?rev=104937&r1=104936&r2=104937&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.access/p4.cpp (original)
+++ cfe/trunk/test/CXX/class.access/p4.cpp Thu May 27 23:34:55 2010
@@ -160,7 +160,7 @@
   private:
     operator Private(); // expected-note 4 {{declared private here}}
   public:
-    operator Public();
+    operator Public(); // expected-note 2{{member is declared here}}
   };
 
   class Derived1 : private Base { // expected-note 2 {{declared private here}} \
@@ -267,7 +267,7 @@
 // Don't silently upgrade forbidden-access paths to private.
 namespace test9 {
   class A {
-    public: static int x;
+  public: static int x; // expected-note {{member is declared here}}
   };
   class B : private A { // expected-note {{constrained by private inheritance here}}
   };

Modified: cfe/trunk/test/SemaCXX/access-base-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/access-base-class.cpp?rev=104937&r1=104936&r2=104937&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/access-base-class.cpp (original)
+++ cfe/trunk/test/SemaCXX/access-base-class.cpp Thu May 27 23:34:55 2010
@@ -61,7 +61,7 @@
 namespace T6 {
   class C;
   
-  class A {};
+  class A {}; // expected-note{{member is declared here}}
   
   class B : private A { // expected-note {{declared private here}} expected-note {{constrained by private inheritance here}}
     void f(C* c);





More information about the cfe-commits mailing list