From: Douglas Gregor Date: Sun, 7 Mar 2010 23:26:22 +0000 (+0000) Subject: Robustify callers that rebuild typename type nodes again NULL return X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a50ce325b1ddd2bcbbfc1082ac93f3861d0a3a3d;p=clang Robustify callers that rebuild typename type nodes again NULL return types. Fixes PR6463. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97924 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index b959202b88..e32d14e1c8 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1083,6 +1083,9 @@ Sema::ActOnMemInitializer(DeclPtrTy ConstructorD, // specialization, we take it as a type name. BaseType = CheckTypenameType((NestedNameSpecifier *)SS.getScopeRep(), *MemberOrBase, SS.getRange()); + if (BaseType.isNull()) + return true; + R.clear(); } } diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 03219580f9..445b68b167 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -4992,6 +4992,9 @@ CurrentInstantiationRebuilder::TransformTypenameType(TypeLocBuilder &TLB, Result = getDerived().RebuildTypenameType(NNS, T->getIdentifier(), SourceRange(TL.getNameLoc())); + if (Result.isNull()) + return QualType(); + TypenameTypeLoc NewTL = TLB.push(Result); NewTL.setNameLoc(TL.getNameLoc()); return Result; diff --git a/test/SemaTemplate/typename-specifier-4.cpp b/test/SemaTemplate/typename-specifier-4.cpp index 0a6fef74c3..280a1b4c39 100644 --- a/test/SemaTemplate/typename-specifier-4.cpp +++ b/test/SemaTemplate/typename-specifier-4.cpp @@ -99,3 +99,20 @@ namespace PR6268 { return Inner(); } } + +namespace PR6463 { + struct B { typedef int type; }; // expected-note 2{{member found by ambiguous name lookup}} + struct C { typedef int type; }; // expected-note 2{{member found by ambiguous name lookup}} + + template + struct A : B, C { + type& a(); // expected-error{{found in multiple base classes}} + int x; + }; + + // FIXME: Improve source location info here. + template + typename A::type& A::a() { // expected-error{{found in multiple base classes}} + return x; // expected-error{{undeclared identifier}} + } +}