From: Jakub Jelinek Date: Thu, 14 Mar 2019 08:14:48 +0000 (+0100) Subject: re PR c++/89512 (ICE in get_expr_operands, at tree-ssa-operands.c:882) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b2725ea5df920e68591375847c0310254020eec7;p=gcc.git re PR c++/89512 (ICE in get_expr_operands, at tree-ssa-operands.c:882) PR c++/89512 * semantics.c (finish_qualified_id_expr): Reject variable templates. * g++.dg/cpp1y/var-templ61.C: New test. From-SVN: r269672 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7c0b4f47322..054a891bcef 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2019-03-14 Jakub Jelinek + PR c++/89512 + * semantics.c (finish_qualified_id_expr): Reject variable templates. + PR c++/89652 * constexpr.c (struct constexpr_ctx): Change save_exprs type from hash_set to vec. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 798a2b3bb30..fcf06061bc7 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2112,6 +2112,14 @@ finish_qualified_id_expr (tree qualifying_class, expr = build_offset_ref (qualifying_class, expr, /*address_p=*/false, complain); } + else if (!template_p + && TREE_CODE (expr) == TEMPLATE_DECL + && !DECL_FUNCTION_TEMPLATE_P (expr)) + { + if (complain & tf_error) + error ("%qE missing template arguments", expr); + return error_mark_node; + } else { /* In a template, return a SCOPE_REF for most qualified-ids diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 73ac51a8bbd..dbd918c6ca4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-03-14 Jakub Jelinek + PR c++/89512 + * g++.dg/cpp1y/var-templ61.C: New test. + PR c++/89652 * g++.dg/cpp1y/constexpr-89652.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ61.C b/gcc/testsuite/g++.dg/cpp1y/var-templ61.C new file mode 100644 index 00000000000..be2fe0f4423 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ61.C @@ -0,0 +1,20 @@ +// PR c++/89512 +// { dg-do compile { target c++14 } } + +struct A { + template + static const int a = 0; +}; + +struct B { + template + static int foo () + { + return T::a; // { dg-error "missing template arguments" } + } +}; + +int bar () +{ + return B::foo (); // { dg-message "required from here" } +}