From: David Majnemer Date: Mon, 5 Aug 2013 04:53:41 +0000 (+0000) Subject: Sema: Don't assume a nested name specifier holds a type X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b051ce94e59c37cfe09e34fe2bf15c037cbbdb3;p=clang Sema: Don't assume a nested name specifier holds a type Sema::PerformObjectMemberConversion assumed that the Qualifier it was given holds a type. However, the specifier could hold just a namespace. In this case, we should ignore the qualifier and not attempt to cast to it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187715 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 898c526f01..8ba7a1deb7 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -2311,9 +2311,8 @@ Sema::PerformObjectMemberConversion(Expr *From, // x = 17; // error: ambiguous base subobjects // Derived1::x = 17; // okay, pick the Base subobject of Derived1 // } - if (Qualifier) { + if (Qualifier && Qualifier->getAsType()) { QualType QType = QualType(Qualifier->getAsType(), 0); - assert(!QType.isNull() && "lookup done with dependent qualifier?"); assert(QType->isRecordType() && "lookup done with non-record type"); QualType QRecordType = QualType(QType->getAs(), 0); diff --git a/test/SemaCXX/pr13394-crash-on-invalid.cpp b/test/SemaCXX/pr13394-crash-on-invalid.cpp index 160051c157..841e3c2034 100644 --- a/test/SemaCXX/pr13394-crash-on-invalid.cpp +++ b/test/SemaCXX/pr13394-crash-on-invalid.cpp @@ -15,3 +15,15 @@ namespace gatekeeper_v1 { // FIXME: Typo correction should remove the 'gatekeeper_v1::' name specifier gatekeeper_v1::closure_t *x; // expected-error-re {{no type named 'closure_t' in namespace 'gatekeeper_v1'$}} } + +namespace Foo { +struct Base { + void Bar() {} // expected-note{{'Bar' declared here}} +}; +} + +struct Derived : public Foo::Base { + void test() { + Foo::Bar(); // expected-error{{no member named 'Bar' in namespace 'Foo'; did you mean simply 'Bar'?}} + } +};