]> granicus.if.org Git - clang/commitdiff
When we complain about a member being inaccessible due to a constraint
authorDouglas Gregor <dgregor@apple.com>
Fri, 28 May 2010 04:34:55 +0000 (04:34 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 28 May 2010 04:34:55 +0000 (04:34 +0000)
along an access path, add another note pointing at the member we
actually found.

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

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

index 444ee798587de594810aa895d0c22cff2d01f0bc..54d06f531c01c995477446865fafbf21a786d349 100644 (file)
@@ -870,6 +870,10 @@ static void DiagnoseAccessPath(Sema &S,
         << BS->getSourceRange()
         << (BaseAccess == AS_protected)
         << (BS->getAccessSpecifierAsWritten() == AS_none);
+      
+      if (D)
+        S.Diag(D->getLocation(), diag::note_field_decl);
+      
       return;
     }
   }
index 09884316f9cd5186aba7e522600c70da75d61ce4..43cc99eb8b493cd37f4c51e459fb6a3233958a8f 100644 (file)
@@ -54,8 +54,10 @@ namespace test0 {
 //   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 @@ namespace test1 {
 //   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}}
index 938d9fbe9bf8a91346d3a94433e29d2ad99fdccd..255fbfc9fc93ea202a62f8362e667c696cc7d2da 100644 (file)
@@ -27,7 +27,7 @@ namespace test1 {
   };
 
   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 test1 {
 
 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}}
index b2818768b5860b8987f27ac6b8c3674f9cd1a75e..277b70bee6bdb423f3708b33a7de91457d310697 100644 (file)
@@ -121,7 +121,7 @@ namespace test2 {
     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}}
index 6ff630c996972ef7823430308a4ab7a9adce0d3c..778e16aa3f533f09b39683f9f3bea1a0bfc02c29 100644 (file)
@@ -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 test3 {
 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 test4 {
 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 test8 {
 }
 
 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;
   };
 
index e8afbe7a39249748bdbff49fa4ad1cebe8ac0540..c1c5199ad4590bd6d08572b9ebcbfb2982e4d615 100644 (file)
@@ -160,7 +160,7 @@ namespace test4 {
   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 @@ namespace test8 {
 // 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}}
   };
index 85516902163e70c53be2c34236a26a6e14d2a8b8..f676e199b6ce84c8211ab8759625e4aa358cf3f0 100644 (file)
@@ -61,7 +61,7 @@ namespace T5 {
 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);