From: Jason Merrill Date: Tue, 27 Jan 2015 19:16:51 +0000 (-0500) Subject: re PR c++/63889 (Ice with redundant static in class scope constexpr variable template.) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=94e54b8d14ac5525d8a4004e0450f5c6fff50252;p=gcc.git re PR c++/63889 (Ice with redundant static in class scope constexpr variable template.) PR c++/63889 * pt.c (finish_template_variable): Move from semantics.c. Handle multiple template arg levels. Handle coercion here. (lookup_template_variable): Not here. From-SVN: r220183 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ac916527ec7..b914f4b1334 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2015-01-27 Jason Merrill + + PR c++/63889 + * pt.c (finish_template_variable): Move from semantics.c. + Handle multiple template arg levels. Handle coercion here. + (lookup_template_variable): Not here. + 2015-01-23 Jason Merrill PR c++/64314 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index bc2653016f3..d377daaf2a6 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8091,13 +8091,28 @@ tree lookup_template_variable (tree templ, tree arglist) { tree type = unknown_type_node; - tsubst_flags_t complain = tf_warning_or_error; - tree parms = INNERMOST_TEMPLATE_PARMS (DECL_TEMPLATE_PARMS (templ)); - arglist = coerce_template_parms (parms, arglist, templ, complain, - /*req_all*/true, /*use_default*/true); return build2 (TEMPLATE_ID_EXPR, type, templ, arglist); } +/* Instantiate a variable declaration from a TEMPLATE_ID_EXPR for use. */ + +tree +finish_template_variable (tree var) +{ + tree templ = TREE_OPERAND (var, 0); + + tree arglist = TREE_OPERAND (var, 1); + tree tmpl_args = DECL_TI_ARGS (DECL_TEMPLATE_RESULT (templ)); + arglist = add_outermost_template_args (tmpl_args, arglist); + + tree parms = DECL_TEMPLATE_PARMS (templ); + tsubst_flags_t complain = tf_warning_or_error; + arglist = coerce_innermost_template_parms (parms, arglist, templ, complain, + /*req_all*/true, + /*use_default*/true); + + return instantiate_template (templ, arglist, complain); +} struct pair_fn_data { diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 915048daf0a..75aa501fe8c 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2454,15 +2454,6 @@ finish_call_expr (tree fn, vec **args, bool disallow_virtual, return result; } -/* Instantiate a variable declaration from a TEMPLATE_ID_EXPR for use. */ - -tree -finish_template_variable (tree var) -{ - return instantiate_template (TREE_OPERAND (var, 0), TREE_OPERAND (var, 1), - tf_error); -} - /* Finish a call to a postfix increment or decrement or EXPR. (Which is indicated by CODE, which should be POSTINCREMENT_EXPR or POSTDECREMENT_EXPR.) */ diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ22.C b/gcc/testsuite/g++.dg/cpp1y/var-templ22.C new file mode 100644 index 00000000000..9ddc925e97e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ22.C @@ -0,0 +1,14 @@ +// PR c++/63889 +// { dg-do compile { target c++14 } } + +template +struct A +{ + template + static constexpr bool is_ok = true; + + template> + A(T) { } +}; + +A p(42);