diff options
author | Jason Merrill <jason@redhat.com> | 2017-06-19 14:20:10 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2017-06-19 14:20:10 -0400 |
commit | 4b691b139f04d13a00a959020ff976fdab60b9b1 (patch) | |
tree | 49dff5d7a10ccfed86633f18d38020cbb01cabaa /gcc/cp/decl2.c | |
parent | c9f8853f9e74816ccb68a5a549f1f61295ce07ed (diff) | |
download | gcc-4b691b139f04d13a00a959020ff976fdab60b9b1.zip gcc-4b691b139f04d13a00a959020ff976fdab60b9b1.tar.gz gcc-4b691b139f04d13a00a959020ff976fdab60b9b1.tar.bz2 |
PR c++/81073 - constexpr and static var in statement-expression.
* typeck2.c (store_init_value): Always call
require_potential_constant_expression.
* pt.c (convert_nontype_argument): Likewise.
* constexpr.c (potential_constant_expression_1): Adjust message.
Use decl_maybe_constant_var_p instead of decl_constant_var_p.
* decl2.c (decl_maybe_constant_var_p): Consider initializer.
From-SVN: r249382
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r-- | gcc/cp/decl2.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 72239ec..a475146 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -4145,10 +4145,19 @@ decl_maybe_constant_var_p (tree decl) /* A proxy isn't constant. */ return false; if (TREE_CODE (type) == REFERENCE_TYPE) - /* References can be constant. */ + /* References can be constant. */; + else if (CP_TYPE_CONST_NON_VOLATILE_P (type) + && INTEGRAL_OR_ENUMERATION_TYPE_P (type)) + /* And const integers. */; + else + return false; + + if (DECL_INITIAL (decl) + && !DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl)) + /* We know the initializer, and it isn't constant. */ + return false; + else return true; - return (CP_TYPE_CONST_NON_VOLATILE_P (type) - && INTEGRAL_OR_ENUMERATION_TYPE_P (type)); } /* Complain that DECL uses a type with no linkage. In C++98 mode this is |