[PATCH] D50088: [Sema] Fix an error with C++17 auto non-type template parameters

2018-08-07 Thread Phabricator via Phabricator via cfe-commits
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=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::B<>::param2;
 }
+
+namespace rdar41852459 {
+template  struct G {};
+
+template  struct S {
+  template  void f() {
+G x;
+  }
+  template  void f2() {
+G x;
+  }
+  template  void f3() {
+G x;
+  }
+};
+
+template  struct I {};
+
+template  struct K {
+  template  void f() {
+I x;
+  }
+  template  void f2() {
+I x;
+  }
+  template  void f3() {
+I x;
+  }
+};
+
+template  struct L {};
+template  struct M {
+  template  void f() {
+L x;
+  }
+  template  void f() {
+L x;
+  }
+  template  void f() {
+L 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 *,
  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());


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::B<>::param2;
 }
+
+namespace rdar41852459 {
+template  struct G {};
+
+template  struct S {
+  template  void f() {
+G x;
+  }
+  template  void f2() {
+G x;
+  }
+  template  void f3() {
+G x;
+  }
+};
+
+template  struct I {};
+
+template  struct K {
+  template  void f() {
+I x;
+  }
+  template  void f2() {
+I x;
+  }
+  template  void f3() {
+I x;
+  }
+};
+
+template  struct L {};
+template  struct M {
+  template  void f() {
+L x;
+  }
+  template  void f() {
+L x;
+  }
+  template  void f() {
+L 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 *,
  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());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50088: [Sema] Fix an error with C++17 auto non-type template parameters

2018-08-07 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339198: [Sema] Ensure an auto non-type template parameter is 
dependent (authored by epilk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50088?vs=159449=159612#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50088

Files:
  lib/Sema/SemaTemplate.cpp
  test/SemaTemplate/temp_arg_nontype_cxx1z.cpp


Index: test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
===
--- test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -335,3 +335,46 @@
   void g(int, int);
   using Int = A::B<>::param2;
 }
+
+namespace rdar41852459 {
+template  struct G {};
+
+template  struct S {
+  template  void f() {
+G x;
+  }
+  template  void f2() {
+G x;
+  }
+  template  void f3() {
+G x;
+  }
+};
+
+template  struct I {};
+
+template  struct K {
+  template  void f() {
+I x;
+  }
+  template  void f2() {
+I x;
+  }
+  template  void f3() {
+I x;
+  }
+};
+
+template  struct L {};
+template  struct M {
+  template  void f() {
+L x;
+  }
+  template  void f() {
+L x;
+  }
+  template  void f() {
+L x;
+  }
+};
+}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -974,7 +974,7 @@
 QualType Sema::CheckNonTypeTemplateParameterType(TypeSourceInfo *,
  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());


Index: test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
===
--- test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -335,3 +335,46 @@
   void g(int, int);
   using Int = A::B<>::param2;
 }
+
+namespace rdar41852459 {
+template  struct G {};
+
+template  struct S {
+  template  void f() {
+G x;
+  }
+  template  void f2() {
+G x;
+  }
+  template  void f3() {
+G x;
+  }
+};
+
+template  struct I {};
+
+template  struct K {
+  template  void f() {
+I x;
+  }
+  template  void f2() {
+I x;
+  }
+  template  void f3() {
+I x;
+  }
+};
+
+template  struct L {};
+template  struct M {
+  template  void f() {
+L x;
+  }
+  template  void f() {
+L x;
+  }
+  template  void f() {
+L x;
+  }
+};
+}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -974,7 +974,7 @@
 QualType Sema::CheckNonTypeTemplateParameterType(TypeSourceInfo *,
  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());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50088: [Sema] Fix an error with C++17 auto non-type template parameters

2018-08-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Can you also add a test where the `auto` is not top-level (eg, `template`) and a test using `decltype(auto)`?


https://reviews.llvm.org/D50088



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50088: [Sema] Fix an error with C++17 auto non-type template parameters

2018-08-06 Thread Erik Pilkington via Phabricator via cfe-commits
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::B<>::param2;
 }
+
+namespace rdar41852459 {
+template  struct G {};
+
+template  struct S {
+  template  void f() {
+G 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 *,
  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());


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::B<>::param2;
 }
+
+namespace rdar41852459 {
+template  struct G {};
+
+template  struct S {
+  template  void f() {
+G 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 *,
  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());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits