r187715 - Sema: Don't assume a nested name specifier holds a type
David Majnemer
david.majnemer at gmail.com
Sun Aug 4 21:53:42 PDT 2013
Author: majnemer
Date: Sun Aug 4 23:53:41 2013
New Revision: 187715
URL: http://llvm.org/viewvc/llvm-project?rev=187715&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/pr13394-crash-on-invalid.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=187715&r1=187714&r2=187715&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Aug 4 23:53:41 2013
@@ -2311,9 +2311,8 @@ Sema::PerformObjectMemberConversion(Expr
// 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<RecordType>(), 0);
Modified: cfe/trunk/test/SemaCXX/pr13394-crash-on-invalid.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/pr13394-crash-on-invalid.cpp?rev=187715&r1=187714&r2=187715&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/pr13394-crash-on-invalid.cpp (original)
+++ cfe/trunk/test/SemaCXX/pr13394-crash-on-invalid.cpp Sun Aug 4 23:53:41 2013
@@ -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'?}}
+ }
+};
More information about the cfe-commits
mailing list