diff mbox series

C++ PATCH for c++/85864, literal template and default template arg

Message ID CADzB+2koqNToF50Hd4LeSNR99waxGDy-tm7p8BgUGZt2JUx6SA@mail.gmail.com
State New
Headers show
Series C++ PATCH for c++/85864, literal template and default template arg | expand

Commit Message

Jason Merrill May 24, 2018, 2:25 p.m. UTC
Another adjustment needed for my having removed the type from
NONTYPE_ARGUMENT_PACK: instantiation_dependent_r needs to ignore that
like it does for TREE_LIST.

Tested x86_64-pc-linux-gnu, applying to trunk and 8.
diff mbox series

Patch

commit 9ebcb2b5403980ec25429c3f43bf951fae5772f8
Author: Jason Merrill <jason@redhat.com>
Date:   Wed May 23 15:29:18 2018 -0400

            PR c++/85864 - literal template and default template arg.
    
            * pt.c (instantiation_dependent_r): Handle NONTYPE_ARGUMENT_PACK.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 0b04770e123..d1181055af4 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -25212,6 +25212,7 @@  instantiation_dependent_r (tree *tp, int *walk_subtrees,
 	 TREE_TYPE.  */
     case TREE_LIST:
     case TREE_VEC:
+    case NONTYPE_ARGUMENT_PACK:
       return NULL_TREE;
 
     case TEMPLATE_PARM_INDEX:
diff --git a/gcc/testsuite/g++.dg/cpp1y/udlit-char-template2.C b/gcc/testsuite/g++.dg/cpp1y/udlit-char-template2.C
new file mode 100644
index 00000000000..06c13261156
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/udlit-char-template2.C
@@ -0,0 +1,23 @@ 
+// PR c++/85864
+// { dg-do compile { target c++14 } }
+
+template<class T, T... S> struct String_template {};
+
+template<class C, C... S>
+constexpr String_template<C, S...> operator""_template() {
+    return String_template<C, S...> {};
+}
+
+template<class prefix = decltype("0x"_template), class T>
+int hex(T v) { return 1; }
+
+template<int v> 
+void tt2() {
+  //    auto h2 = hex<decltype("0x"_template)>(1);
+    auto h = hex(2);
+}
+
+int main() {
+  //    auto h = hex(2);
+  //    return h;
+}