[PATCH] Fix for crash due to g++.old-deja/g++.other/using3.C
Dinesh Dwivedi
dinesh.d at samsung.com
Tue Apr 29 03:07:12 PDT 2014
Updated test-cases
updated test case fails if we comment lines 7335:7337.
using declaration for class member can not use templates id, scoped enumerators etc.
http://reviews.llvm.org/D3051
Files:
lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/using-decl-1.cpp
Index: lib/Sema/SemaDeclCXX.cpp
===================================================================
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -7329,6 +7329,12 @@
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: test/SemaCXX/using-decl-1.cpp
===================================================================
--- test/SemaCXX/using-decl-1.cpp
+++ test/SemaCXX/using-decl-1.cpp
@@ -194,3 +194,50 @@
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'}}
+};
+
+struct PR19171_A {
+ PR19171_A();
+ template<class T>
+ void S(T a) {};
+};
+
+struct PR19171_AA {
+ PR19171_AA();
+};
+
+struct PR19171_AAA : PR19171_AA {
+ using PR19171_AA::S; // expected-error {{no member named 'S' in 'PR19171_AA'}}
+};
+
+// [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'}}
+};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3051.8904.patch
Type: text/x-patch
Size: 2467 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140429/1821aa54/attachment.bin>
More information about the cfe-commits
mailing list