[PATCH] D50088: [Sema] Fix an error with C++17 auto non-type template parameters
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 7 15:59:48 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339198: [Sema] Ensure an auto non-type template parameter is dependent (authored by epilk, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D50088?vs=159449&id=159613#toc
Repository:
rL LLVM
https://reviews.llvm.org/D50088
Files:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
Index: cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
===================================================================
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -335,3 +335,46 @@
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;
+ }
+ template <auto *PV> void f2() {
+ G<PV> x;
+ }
+ template <decltype(auto) V> void f3() {
+ G<V> x;
+ }
+};
+
+template <auto *PV> struct I {};
+
+template <class T> struct K {
+ template <auto *PV> void f() {
+ I<PV> x;
+ }
+ template <auto V> void f2() {
+ I<V> x;
+ }
+ template <decltype(auto) V> void f3() {
+ I<V> x;
+ }
+};
+
+template <decltype(auto)> struct L {};
+template <class T> struct M {
+ template <auto *PV> void f() {
+ L<PV> x;
+ }
+ template <auto V> void f() {
+ L<V> x;
+ }
+ template <decltype(auto) V> void f() {
+ L<V> x;
+ }
+};
+}
Index: cfe/trunk/lib/Sema/SemaTemplate.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp
+++ cfe/trunk/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.159613.patch
Type: text/x-patch
Size: 2339 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180807/6a97efa5/attachment.bin>
More information about the llvm-commits
mailing list