[PATCH] Sema: Don't assume a nested name specifier holds a type
David Majnemer
david.majnemer at gmail.com
Sun Aug 4 00:29:23 PDT 2013
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.
http://llvm-reviews.chandlerc.com/D1283
Files:
lib/Sema/SemaExpr.cpp
test/SemaCXX/PR16709.cpp
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -2311,7 +2311,7 @@
// 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");
Index: test/SemaCXX/PR16709.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/PR16709.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+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'?}}
+ }
+};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1283.1.patch
Type: text/x-patch
Size: 1066 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130804/64347c22/attachment.bin>
More information about the cfe-commits
mailing list