From: Jason Merrill Date: Mon, 7 Dec 2015 04:34:57 +0000 (-0500) Subject: Fix template/ref1.C, nontype15.C, addr-builtin1.C with -std=c++1z. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=19dedccfc36a34b843292e6493c7ffd429673de2;p=gcc.git Fix template/ref1.C, nontype15.C, addr-builtin1.C with -std=c++1z. * parser.c (cp_parser_template_argument): Handle references in C++1z mode. * constexpr.c (potential_constant_expression_1): Don't error about TREE_THIS_VOLATILE on declarations. [COMPONENT_REF]: Don't consider the object if we're dealing with an overloaded function. From-SVN: r231351 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 310cdba837b..1fdbe05c5f7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,12 @@ 2015-12-06 Jason Merrill + * parser.c (cp_parser_template_argument): Handle references in + C++1z mode. + * constexpr.c (potential_constant_expression_1): Don't error about + TREE_THIS_VOLATILE on declarations. + [COMPONENT_REF]: Don't consider the object if we're dealing with + an overloaded function. + * constraint.cc (strictly_subsumes): New. * cp-tree.h: Declare it. * pt.c (process_partial_specialization): Use it instead of diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 42e99021f11..208f43b430d 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -4130,7 +4130,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, return false; if (t == NULL_TREE) return true; - if (TREE_THIS_VOLATILE (t)) + if (TREE_THIS_VOLATILE (t) && !DECL_P (t)) { if (flags & tf_error) error ("expression %qE has side-effects", t); @@ -4345,6 +4345,8 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, of literal type or of pointer to literal type. */ /* This test would be redundant, as it follows from the postfix-expression being a potential constant expression. */ + if (type_unknown_p (t)) + return true; return RECUR (TREE_OPERAND (t, 0), want_rval); case EXPR_PACK_EXPANSION: diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 85f6cc18aec..1c7b1d50747 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -15364,7 +15364,16 @@ cp_parser_template_argument (cp_parser* parser) because the argument could really be a type-id. */ if (maybe_type_id) cp_parser_parse_tentatively (parser); - argument = cp_parser_constant_expression (parser); + + if (cxx_dialect <= cxx14) + argument = cp_parser_constant_expression (parser); + else + { + /* With C++17 generalized non-type template arguments we need to handle + lvalue constant expressions, too. */ + argument = cp_parser_assignment_expression (parser); + require_potential_constant_expression (argument); + } if (!maybe_type_id) return argument; diff --git a/gcc/testsuite/g++.dg/template/nontype8.C b/gcc/testsuite/g++.dg/template/nontype8.C index d2976dfc047..d31f8923d5c 100644 --- a/gcc/testsuite/g++.dg/template/nontype8.C +++ b/gcc/testsuite/g++.dg/template/nontype8.C @@ -8,6 +8,6 @@ struct S { int m; static int s; } s; X<&a[2]> x3; // { dg-error "" } address of array element X<&s.m> x4; // { dg-error "" } address of non-static member -X<&s.s> x5; // { dg-error "" } &S::s must be used +X<&s.s> x5; // { dg-error "" "" { target { ! c++1z } } } &S::s must be used X<&S::s> x6; // OK: address of static member