Completely reworked patch after review.
http://reviews.llvm.org/D5769
Files:
lib/Sema/TreeTransform.h
test/SemaTemplate/instantiate-non-dependent-types.cpp
Index: test/SemaTemplate/instantiate-non-dependent-types.cpp
===================================================================
--- test/SemaTemplate/instantiate-non-dependent-types.cpp
+++ test/SemaTemplate/instantiate-non-dependent-types.cpp
@@ -11,4 +11,34 @@
typedef instantiate<&X1<int>::member> i; // expected-note{{in instantiation of}}
};
-X2<int> x;
+X2<int> x;
+
+template <class T, class A> class C {
+public:
+ int i;
+ void f(T &t) {
+ T *q = new T();
+ t.T::~T();
+ q->~T();
+ // expected-error@+1 {{'int' is not a class, namespace, or scoped enumeration}}
+ q->A::~A();
+ // expected-error@+1 {{no member named '~int' in 'Q'}}
+ q->~A();
+
+ delete q;
+ }
+};
+
+class Q {
+public:
+ Q() {}
+ ~Q() {}
+};
+
+C<Q, int> dummy;
+int main() {
+ Q qinst;
+ // expected-note@+1 {{in instantiation of member function 'C<Q, int>::f' requested here}}
+ dummy.f(qinst);
+}
+
Index: lib/Sema/TreeTransform.h
===================================================================
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -10510,9 +10510,16 @@
// The scope type is now known to be a valid nested name specifier
// component. Tack it on to the end of the nested name specifier.
- if (ScopeType)
- SS.Extend(SemaRef.Context, SourceLocation(),
- ScopeType->getTypeLoc(), CCLoc);
+ if (ScopeType) {
+ if (!ScopeType->getType()->getAs<TagType>()) {
+ getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
+ diag::err_expected_class_or_namespace)
+ << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
+ return ExprError();
+ }
+ SS.Extend(SemaRef.Context, SourceLocation(), ScopeType->getTypeLoc(),
+ CCLoc);
+ }
SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
return getSema().BuildMemberReferenceExpr(Base, BaseType,
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits