[cfe-commits] r168011 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/SemaCXX/member-expr.cpp test/SemaCXX/pseudo-destructors.cpp

Richard Smith richard-llvm at metafoo.co.uk
Wed Nov 14 16:31:27 PST 2012


Author: rsmith
Date: Wed Nov 14 18:31:27 2012
New Revision: 168011

URL: http://llvm.org/viewvc/llvm-project?rev=168011&view=rev
Log:
Per [basic.lookup.classref]p3, in an expression of the form p->~type-name, the
type-name is looked up in the context of the complete postfix-expression. Don't
forget to pass the scope into this lookup when the type-name is a template-id;
it might name an alias template which can't be found within the class itself.

Bug spotted by Johannes Schaub on #llvm.

Modified:
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/test/SemaCXX/member-expr.cpp
    cfe/trunk/test/SemaCXX/pseudo-destructors.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=168011&r1=168010&r2=168011&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Nov 14 18:31:27 2012
@@ -2387,7 +2387,7 @@
     // "template" keyword is now permitted). We follow the C++0x
     // rules, even in C++03 mode with a warning, retroactively applying the DR.
     bool MemberOfUnknownSpecialization;
-    TemplateNameKind TNK = isTemplateName(0, SS, TemplateKWLoc.isValid(), Name,
+    TemplateNameKind TNK = isTemplateName(S, SS, TemplateKWLoc.isValid(), Name,
                                           ObjectType, EnteringContext, Result,
                                           MemberOfUnknownSpecialization);
     if (TNK == TNK_Non_template && LookupCtx->isDependentContext() &&

Modified: cfe/trunk/test/SemaCXX/member-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-expr.cpp?rev=168011&r1=168010&r2=168011&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/member-expr.cpp (original)
+++ cfe/trunk/test/SemaCXX/member-expr.cpp Wed Nov 14 18:31:27 2012
@@ -111,8 +111,13 @@
   struct X { };
   struct Y : X { };
 
+  template<typename T> struct Z { int n; };
+
   void f(Y *y) {
     y->N::X1<int>; // expected-error{{'rdar8231724::N::X1' is not a member of class 'rdar8231724::Y'}}
+    y->Z<int>::n; // expected-error{{'rdar8231724::Z<int>::n' is not a member of class 'rdar8231724::Y'}}
+    y->template Z<int>::n; // expected-error{{'rdar8231724::Z<int>::n' is not a member of class 'rdar8231724::Y'}} \
+    // expected-warning{{'template' keyword outside of a template}}
   }
 }
 

Modified: cfe/trunk/test/SemaCXX/pseudo-destructors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/pseudo-destructors.cpp?rev=168011&r1=168010&r2=168011&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/pseudo-destructors.cpp (original)
+++ cfe/trunk/test/SemaCXX/pseudo-destructors.cpp Wed Nov 14 18:31:27 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 struct A {};
 
 enum Foo { F };
@@ -80,3 +80,8 @@
 
   template void destroy(int*); // expected-note{{in instantiation of function template specialization}}
 }
+
+template<typename T> using Id = T;
+void AliasTemplate(int *p) {
+  p->~Id<int>();
+}





More information about the cfe-commits mailing list