From a7b12f1f3ed87fc36cf837862fca8477513446b4 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 15 Apr 2016 12:32:22 -0400 Subject: [PATCH] re PR c++/70505 (Constexpr failure when template type specified) PR c++/70505 * pt.c (tsubst_baselink): Give the new TEMPLATE_ID_EXPR unknown_type_node, too. From-SVN: r235042 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 7 ++++--- .../g++.dg/cpp0x/constexpr-template10.C | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-template10.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cb0915838a2..b159c9b4f1b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2016-04-15 Jason Merrill + + PR c++/70505 + * pt.c (tsubst_baselink): Give the new TEMPLATE_ID_EXPR + unknown_type_node, too. + 2016-04-15 Jason Merrill Nathan Sidwell diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 4a00530b312..325351fbee5 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 index 00000000000..d63f1cc630f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-template10.C @@ -0,0 +1,17 @@ +// PR c++/70505 +// { dg-do compile { target c++11 } } + +template +struct s +{ + template + static constexpr T f1(const T x) {return x;} + template (sizeof(T))> + static constexpr T f2(const T x) {return x;} + static void f() {s::f2(42);} +}; + +int main() +{ + s::f(); +} -- 2.30.2