[PATCH] D65050: [SemaTemplate] Mark a function type as dependent when its parameter list contains pack expansion
S. B. Tam via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 21 06:32:57 PDT 2019
cpplearner created this revision.
cpplearner added reviewers: doug.gregor, eli.friedman, lvoufo, rsmith.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.
Given `template<class> using Int = int;`, the type `void(Int<Ts>...)` should be treated as a dependent type, even though `Int<Ts>` is not dependent.
This fixes https://bugs.llvm.org/show_bug.cgi?id=42654
Repository:
rC Clang
https://reviews.llvm.org/D65050
Files:
clang/lib/AST/Type.cpp
clang/test/SemaTemplate/alias-templates.cpp
Index: clang/test/SemaTemplate/alias-templates.cpp
===================================================================
--- clang/test/SemaTemplate/alias-templates.cpp
+++ clang/test/SemaTemplate/alias-templates.cpp
@@ -267,3 +267,34 @@
int z = Bar(); // expected-error {{use of template template parameter 'Bar' requires template arguments}}
}
}
+
+namespace PR42654 {
+ template<typename> struct function { };
+
+ template<typename...T>
+ struct thing {
+ void f(function<void(T...)>) { }
+ };
+
+ template<typename ...Ts>
+ struct Environment
+ {
+ template<typename T>
+ using Integer = int;
+
+ using Function = function<void(Integer<Ts>...)>;
+ using MyTuple = thing<Integer<Ts>...>;
+
+ void run(Function func)
+ {
+ MyTuple t;
+ t.f(func);
+ }
+ };
+
+ void f()
+ {
+ Environment<int, double> env;
+ env.run({});
+ }
+}
Index: clang/lib/AST/Type.cpp
===================================================================
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2912,7 +2912,7 @@
// Fill in the trailing argument array.
auto *argSlot = getTrailingObjects<QualType>();
for (unsigned i = 0; i != getNumParams(); ++i) {
- if (params[i]->isDependentType())
+ if (params[i]->isDependentType() || params[i]->getAs<PackExpansionType>())
setDependent();
else if (params[i]->isInstantiationDependentType())
setInstantiationDependent();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65050.210990.patch
Type: text/x-patch
Size: 1442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190721/d74d6e80/attachment.bin>
More information about the cfe-commits
mailing list