]> granicus.if.org Git - clang/commitdiff
Fix crash if typo correction corrects a member using-declaration to a
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 30 Apr 2014 17:40:35 +0000 (17:40 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 30 Apr 2014 17:40:35 +0000 (17:40 +0000)
non-member declaration. Patch by Dinesh Dwivedi!

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

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

index e3bedf78e6ee21fe961348d0a4c46c983f1c53ef..d49e68e027e5fe5ad45fff8e5463b3d1c66632ea 100644 (file)
@@ -7329,6 +7329,12 @@ public:
     if (!ND || isa<NamespaceDecl>(ND))
       return false;
 
+    // FIXME: We should check if ND is member of base class of class having
+    // using declaration and direct base class in case using declaration names
+    // a constructor.
+    if (RequireMember && !ND->isCXXClassMember())
+      return false;
+
     if (RequireMember && !isa<FieldDecl>(ND) && !isa<CXXMethodDecl>(ND) &&
         !isa<TypeDecl>(ND))
       return false;
index 21aa107e219d8b1b12026f85ef302bd66b2522c4..d5e793bbb5a83ac94d009d8fd40b0c7a51a12ef1 100644 (file)
@@ -194,3 +194,36 @@ namespace UsingDeclVsHiddenName {
     using A::HiddenLocalExtern2;
   }
 }
+
+struct Z {
+  Z();
+};
+
+typedef struct {
+  Z i;
+} S;
+
+struct Y : S {
+  using S::S; // expected-error {{no member named 'S' in 'S'}}
+};
+
+// [namespace.udecl] Para3: 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: Typo correction should only consider member of base classes
+struct PR19171_E { };
+struct PR19171_EE { int EE; }; // expected-note {{'PR19171_EE::EE' declared here}} \
+                                // expected-note {{target of using declaration}}
+struct PR19171_F : PR19171_E {
+       using PR19171_E::EE; // expected-error{{no member named 'EE' in 'PR19171_E'; did you mean 'PR19171_EE::EE'?}} \
+                          // expected-error{{using declaration refers into 'PR19171_E::', which is not a base class of 'PR19171_F'}}
+};