re PR c++/70505 (Constexpr failure when template type specified)
authorJason Merrill <jason@redhat.com>
Fri, 15 Apr 2016 16:32:22 +0000 (12:32 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 15 Apr 2016 16:32:22 +0000 (12:32 -0400)
PR c++/70505

* pt.c (tsubst_baselink): Give the new TEMPLATE_ID_EXPR
unknown_type_node, too.

From-SVN: r235042

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/constexpr-template10.C [new file with mode: 0644]

index cb09158..b159c9b 100644 (file)
@@ -1,4 +1,10 @@
 2016-04-15  Jason Merrill  <jason@redhat.com>
+
+       PR c++/70505
+       * pt.c (tsubst_baselink): Give the new TEMPLATE_ID_EXPR
+       unknown_type_node, too.
+
+2016-04-15  Jason Merrill  <jason@redhat.com>
            Nathan Sidwell  <nathan@acm.org>
 
        PR c++/70594
index 4a00530..325351f 100644 (file)
@@ -13666,9 +13666,10 @@ tsubst_baselink (tree baselink, tree object_type,
     /* Add back the template arguments, if present.  */
     if (BASELINK_P (baselink) && template_id_p)
       BASELINK_FUNCTIONS (baselink)
-       = build_nt (TEMPLATE_ID_EXPR,
-                   BASELINK_FUNCTIONS (baselink),
-                   template_args);
+       = build2 (TEMPLATE_ID_EXPR,
+                 unknown_type_node,
+                 BASELINK_FUNCTIONS (baselink),
+                 template_args);
     /* Update the conversion operator type.  */
     BASELINK_OPTYPE (baselink) = optype;
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-template10.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-template10.C
new file mode 100644 (file)
index 0000000..d63f1cc
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/70505
+// { dg-do compile { target c++11 } }
+
+template <class X>
+struct s
+{
+  template <class T>
+  static constexpr T f1(const T x) {return x;}
+  template <class T, T = f1<T>(sizeof(T))>
+  static constexpr T f2(const T x) {return x;}
+  static void f() {s<int>::f2(42);}
+};
+
+int main()
+{
+  s<int>::f();
+}