]> granicus.if.org Git - clang/commitdiff
When typo-correcting a member using declaration, don't exclude member templates.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 30 Apr 2014 18:15:00 +0000 (18:15 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 30 Apr 2014 18:15:00 +0000 (18:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207681 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/using-decl-1.cpp

index b1b67a648b18bb04d660ed9954b31028d50d3962..c4f6ee13ea19038a11d2380beed27bc32dd79efa 100644 (file)
@@ -7336,10 +7336,6 @@ public:
       // FIXME: Check that the base class member is accessible?
     }
 
-    if (RequireMemberOf && !isa<FieldDecl>(ND) && !isa<CXXMethodDecl>(ND) &&
-        !isa<TypeDecl>(ND))
-      return false;
-
     // Completely unqualified names are invalid for a 'using' declaration.
     if (Candidate.WillReplaceSpecifier() && !Candidate.getCorrectionSpecifier())
       return false;
index 2ce0b10908630964892ab90fe7fb86c66552a4f8..a91d20b0f3214fc055f409a106e8ba53c8beff83 100644 (file)
@@ -195,32 +195,43 @@ namespace UsingDeclVsHiddenName {
   }
 }
 
-struct Z {
-  Z();
-};
+namespace PR19171 {
+  struct Z {
+    Z();
+  };
 
-typedef struct {
-  Z i;
-} S;
+  typedef struct {
+    Z i;
+  } S;
 
-struct Y : S {
-  using S::S; // expected-error {{no member named 'S' in 'S'}}
-};
+  struct Y : S {
+    using S::S; // expected-error {{no member named 'S' in 'PR19171::S'}}
+  };
 
-// [namespace.udecl]p3: In a using-declaration used as a member-declaration,
-// the nested-name-specifier shall name a base class of the class being defined.
-// If such a using-declaration names a constructor, the nested-name-specifier
-// shall name a direct base class of the class being defined;
+  // [namespace.udecl]p3: In a using-declaration used as a member-declaration,
+  // the nested-name-specifier shall name a base class of the class being defined.
+  // If such a using-declaration names a constructor, the nested-name-specifier
+  // shall name a direct base class of the class being defined;
 
-// FIXME: For c++11, Typo correction should only consider constructor of direct base class
-struct PR19171_B { }; // expected-note {{'PR19171_B' declared here}}
-struct PR19171_C : PR19171_B { };
-struct PR19171_D : PR19171_C {
-  using PR19171_B::PR19171_C; // expected-error{{no member named 'PR19171_C' in 'PR19171_B'; did you mean 'PR19171_B'?}}
-};
+  // FIXME: For c++11, Typo correction should only consider constructor of direct base class
+  struct B_blah { }; // expected-note {{'B_blah' declared here}}
+  struct C_blah : B_blah { };
+  struct D : C_blah {
+    using B_blah::C_blah; // expected-error {{no member named 'C_blah' in 'PR19171::B_blah'; did you mean 'B_blah'?}}
+  };
 
-struct PR19171_E { };
-struct PR19171_EE { int EE; };
-struct PR19171_F : PR19171_E {
-  using PR19171_E::EE; // expected-error-re{{no member named 'EE' in 'PR19171_E'{{$}}}}
-};
+  struct E { };
+  struct EE { int EE; };
+  struct F : E {
+    using E::EE; // expected-error-re {{no member named 'EE' in 'PR19171::E'{{$}}}}
+  };
+}
+
+namespace TypoCorrectTemplateMember {
+  struct A {
+    template<typename T> void foobar(T); // expected-note {{'foobar' declared here}}
+  };
+  struct B : A {
+    using A::goobar; // expected-error {{no member named 'goobar' in 'TypoCorrectTemplateMember::A'; did you mean 'foobar'?}}
+  };
+}