]> granicus.if.org Git - clang/commitdiff
More for PR11848: a pack expansion type isn't necessarily type-dependent (its
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 16 Jul 2012 01:59:26 +0000 (01:59 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 16 Jul 2012 01:59:26 +0000 (01:59 +0000)
pattern might be an alias template which doesn't use its arguments). It's always
instantiation-dependent, though.

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

include/clang/AST/Type.h
test/SemaTemplate/alias-templates.cpp

index ff27200bfffd554447cb6cb8b6cb0952136e25a0..fbb3a582ca82aa93f8b294625cb887be54975f45 100644 (file)
@@ -4105,7 +4105,7 @@ class PackExpansionType : public Type, public llvm::FoldingSetNode {
 
   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),
index a3d66ae63b9be4a57bcb0ba820fbd70ddbca8729..20ba6e0cb7bc48bf40db9ade007bf10c5cf4d046 100644 (file)
@@ -125,17 +125,17 @@ namespace Core22036 {
   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 {