]> granicus.if.org Git - clang/commitdiff
Per [basic.lookup.classref]p3, in an expression of the form p->~type-name, the
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 15 Nov 2012 00:31:27 +0000 (00:31 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 15 Nov 2012 00:31:27 +0000 (00:31 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168011 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplate.cpp
test/SemaCXX/member-expr.cpp
test/SemaCXX/pseudo-destructors.cpp

index f56b05406d075a93c98f6df966ff1597a68459f0..1fa554abd03e3cde4635b67dc81a44111d16670b 100644 (file)
@@ -2387,7 +2387,7 @@ TemplateNameKind Sema::ActOnDependentTemplateName(Scope *S,
     // "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() &&
index 763f9c754c1e80f88a9741a8727c1925cc02fdb9..515bcd43b2c04401e28d1f7310f27bd8c9a72026 100644 (file)
@@ -111,8 +111,13 @@ namespace rdar8231724 {
   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}}
   }
 }
 
index a8f6683ced00c17cec0b123cfde0215ed178b164..95363e5f6bae755b92d4028f0b92d17629acef29 100644 (file)
@@ -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 @@ namespace PR11339 {
 
   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>();
+}