]> granicus.if.org Git - clang/commitdiff
Sema: Don't assume a nested name specifier holds a type
authorDavid Majnemer <david.majnemer@gmail.com>
Mon, 5 Aug 2013 04:53:41 +0000 (04:53 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Mon, 5 Aug 2013 04:53:41 +0000 (04:53 +0000)
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

lib/Sema/SemaExpr.cpp
test/SemaCXX/pr13394-crash-on-invalid.cpp

index 898c526f01c63364a5405ece435f2a28c761ed78..8ba7a1deb7e18ade42cb35f475c37376ea31677f 100644 (file)
@@ -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<RecordType>(), 0);
index 160051c157e6915810e4576b197b922e7dbd18d6..841e3c203402c2f4f84918667eed739c5b0f9e69 100644 (file)
@@ -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'?}}
+  }
+};