[PATCH] D50088: [Sema] Fix an error with C++17 auto non-type template parameters
Erik Pilkington via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 6 21:10:33 PDT 2018
erik.pilkington updated this revision to Diff 159449.
erik.pilkington retitled this revision from "[Sema] Dig through AutoTypes that have been deduced to an undeduced AutoType in Type::isUndeducedType" to "[Sema] Fix an error with C++17 auto non-type template parameters".
erik.pilkington edited the summary of this revision.
erik.pilkington added a comment.
New patch uses a different approach to fix this. I edited the summary/title to explain. Sorry for the flip-flop!
https://reviews.llvm.org/D50088
Files:
clang/lib/Sema/SemaTemplate.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
===================================================================
--- clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -335,3 +335,13 @@
void g(int, int);
using Int = A<int>::B<&g>::param2;
}
+
+namespace rdar41852459 {
+template <auto V> struct G {};
+
+template <class T> struct S {
+ template <auto V> void f() {
+ G<V> x;
+ }
+};
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===================================================================
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -974,7 +974,7 @@
QualType Sema::CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI,
SourceLocation Loc) {
if (TSI->getType()->isUndeducedType()) {
- // C++1z [temp.dep.expr]p3:
+ // C++17 [temp.dep.expr]p3:
// An id-expression is type-dependent if it contains
// - an identifier associated by name lookup with a non-type
// template-parameter declared with a type that contains a
@@ -9866,6 +9866,15 @@
if (!NewTSI)
return true;
+ if (NewTSI->getType()->isUndeducedType()) {
+ // C++17 [temp.dep.expr]p3:
+ // An id-expression is type-dependent if it contains
+ // - an identifier associated by name lookup with a non-type
+ // template-parameter declared with a type that contains a
+ // placeholder type (7.1.7.4),
+ NewTSI = SubstAutoTypeSourceInfo(NewTSI, Context.DependentTy);
+ }
+
if (NewTSI != NTTP->getTypeSourceInfo()) {
NTTP->setTypeSourceInfo(NewTSI);
NTTP->setType(NewTSI->getType());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50088.159449.patch
Type: text/x-patch
Size: 1722 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180807/b10e3eaf/attachment.bin>
More information about the cfe-commits
mailing list