[cfe-commits] r160246 - in /cfe/trunk: include/clang/AST/Type.h test/SemaTemplate/alias-templates.cpp

Richard Smith richard-llvm at metafoo.co.uk
Sun Jul 15 18:59:26 PDT 2012


Author: rsmith
Date: Sun Jul 15 20:59:26 2012
New Revision: 160246

URL: http://llvm.org/viewvc/llvm-project?rev=160246&view=rev
Log:
More for PR11848: a pack expansion type isn't necessarily type-dependent (its
pattern might be an alias template which doesn't use its arguments). It's always
instantiation-dependent, though.

Modified:
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/test/SemaTemplate/alias-templates.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=160246&r1=160245&r2=160246&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Sun Jul 15 20:59:26 2012
@@ -4105,7 +4105,7 @@
 
   PackExpansionType(QualType Pattern, QualType Canon,
                     llvm::Optional<unsigned> NumExpansions)
-    : Type(PackExpansion, Canon, /*Dependent=*/true,
+    : Type(PackExpansion, Canon, /*Dependent=*/Pattern->isDependentType(),
            /*InstantiationDependent=*/true,
            /*VariableModified=*/Pattern->isVariablyModifiedType(),
            /*ContainsUnexpandedParameterPack=*/false),

Modified: cfe/trunk/test/SemaTemplate/alias-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/alias-templates.cpp?rev=160246&r1=160245&r2=160246&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/alias-templates.cpp (original)
+++ cfe/trunk/test/SemaTemplate/alias-templates.cpp Sun Jul 15 20:59:26 2012
@@ -125,17 +125,17 @@
   void h(...);
   template<typename T> using Y = X;
   template<typename T, typename ...Ts> struct S {
+    // An expression can contain an unexpanded pack without being type or
+    // value dependent. This is true even if the expression's type is a pack
+    // expansion type.
     void f1(Y<T> a) { h(g(a)); } // expected-error {{undeclared identifier 'g'}}
-    // FIXME: We should reject this too: 'as' has non-dependent type 'X', so
-    //        ADL should be performed at the point of definition of the
-    //        template.
-    void f2(Y<Ts>...as) { h(g(as)...); }
+    void f2(Y<Ts>...as) { h(g(as)...); } // expected-error {{undeclared identifier 'g'}}
+    void f3(Y<Ts>...as) { g(as...); } // ok
+    void f4(Ts ...ts) { h(g(sizeof(ts))...); } // expected-error {{undeclared identifier 'g'}}
+    // FIXME: We can reject this, since it has no valid instantiations because
+    // 'g' never has any associated namespaces.
+    void f5(Ts ...ts) { g(sizeof(ts)...); } // ok
   };
-  int g(X);
-  void test() {
-    S<int, int>().f1({});
-    S<int, int>().f2({});
-  }
 }
 
 namespace PR13243 {





More information about the cfe-commits mailing list