c++: Constant expression parsing and parameters.
authorJason Merrill <jason@redhat.com>
Thu, 21 May 2020 14:27:11 +0000 (10:27 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 21 May 2020 22:04:22 +0000 (18:04 -0400)
commitbeb019d346b903c16b9fd349937de444b6a8b6c0
tree712206ff4c6993253a99a11b9736f06d069f998a
parent4f602147b6abbe05f862d3feda8290d4cf5c583f
c++: Constant expression parsing and parameters.

The difference between a "potential" constant-expression and a regular
constant-expression is the treatment of parameters; in a constexpr function,
a parameter is potentially constant when evaluating a call to that function,
but it is not constant during parsing of the function.
cp_parser_constant_expression should check the latter rather than the
former.

gcc/cp/ChangeLog:

* cp-tree.h (is_rvalue_constant_expression): Declare.
* constexpr.c (is_rvalue_constant_expression): New.
* parser.c (cp_parser_constant_expression): Use it.
* decl.c (cp_finish_decl): Try to treat a constexpr initializer in a
template as constant.
gcc/cp/constexpr.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/parser.c