diff options
author | Jason Merrill <jason@gcc.gnu.org> | 2010-11-01 21:31:18 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-11-01 21:31:18 -0400 |
commit | fa2200cbb1ef5a6a7bdb9a5ba708c7400eb6b404 (patch) | |
tree | 6c2db2fc090bec484b5ef60fbe416d72e1c7b6a4 /gcc/cp/parser.c | |
parent | c41095db2f17d8e8695bfab2a582b8f99639633f (diff) | |
download | gcc-fa2200cbb1ef5a6a7bdb9a5ba708c7400eb6b404.tar.gz |
call.c (null_ptr_cst_p): Use maybe_constant_value.
* call.c (null_ptr_cst_p): Use maybe_constant_value.
(set_up_extended_ref_temp): Support constant initialization.
(initialize_reference): Adjust.
* class.c (check_bitfield_decl): Use cxx_constant_value.
* cvt.c (ocp_convert): Don't use integral_constant_value when
converting to class type.
* decl.c (finish_case_label): Use maybe_constant_value.
(build_init_list_var_init): Support constant initialization.
(check_initializer): Likewise. Reorganize.
(cp_finish_decl): Likewise.
(expand_static_init): Likewise.
(compute_array_index_type): Use maybe_constant_value.
Add complain parm.
(create_array_type_for_decl, grokdeclarator): Pass it.
(build_enumerator): Use cxx_constant_value.
* decl2.c (grokfield): Use maybe_constant_init.
* except.c (check_noexcept_r): Handle constexpr.
(build_noexcept_spec): Use maybe_constant_value.
* init.c (expand_default_init): Support constant initialization.
(build_vec_init): Likewise.
(constant_value_1): Adjust.
(build_new_1): Adjust.
* parser.c (cp_parser_constant_expression): Allow non-integral
in C++0x mode.
(cp_parser_direct_declarator): Don't fold yet in C++0x mode.
(cp_parser_initializer_clause): Toss folded result if non-constant.
* pt.c (fold_decl_constant_value): Remove.
(convert_nontype_argument): Use maybe_constant_value. Give clearer
error about overflow.
(tsubst): Move array bounds handling into compute_array_index_type.
(value_dependent_expression_p): Handle constant CALL_EXPR.
* semantics.c (finish_static_assert): Use maybe_constant_value.
(ensure_literal_type_for_constexpr_object): Make sure type is complete.
(potential_constant_expression): Use maybe_constant_value.
* tree.c (cast_valid_in_integral_constant_expression_p): Any cast
is potentially valid in C++0x.
* typeck2.c (store_init_value): Handle constant init.
(check_narrowing): Use maybe_constant_value.
(build_functional_cast): Set TREE_CONSTANT on literal T().
* cp-tree.h (DECL_INTEGRAL_CONSTANT_VAR_P): Remove.
(LOOKUP_ALREADY_DIGESTED): New.
(compute_array_index_type): Adjust prototype.
From-SVN: r166167
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 33d8561603b..90277603eeb 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -7176,7 +7176,8 @@ cp_parser_constant_expression (cp_parser* parser, saved_non_integral_constant_expression_p = parser->non_integral_constant_expression_p; /* We are now parsing a constant-expression. */ parser->integral_constant_expression_p = true; - parser->allow_non_integral_constant_expression_p = allow_non_constant_p; + parser->allow_non_integral_constant_expression_p + = (allow_non_constant_p || cxx_dialect >= cxx0x); parser->non_integral_constant_expression_p = false; /* Although the grammar says "conditional-expression", we parse an "assignment-expression", which also permits "throw-expression" @@ -7195,7 +7196,8 @@ cp_parser_constant_expression (cp_parser* parser, = saved_allow_non_integral_constant_expression_p; if (allow_non_constant_p) *non_constant_p = parser->non_integral_constant_expression_p; - else if (parser->non_integral_constant_expression_p) + else if (parser->non_integral_constant_expression_p + && cxx_dialect < cxx0x) expression = error_mark_node; parser->non_integral_constant_expression_p = saved_non_integral_constant_expression_p; @@ -14975,8 +14977,8 @@ cp_parser_direct_declarator (cp_parser* parser, = cp_parser_constant_expression (parser, /*allow_non_constant=*/true, &non_constant_p); - if (!non_constant_p) - bounds = fold_non_dependent_expr (bounds); + if (!non_constant_p || cxx_dialect >= cxx0x) + /* OK */; /* Normally, the array bound must be an integral constant expression. However, as an extension, we allow VLAs in function scopes as long as they aren't part of a @@ -16408,7 +16410,15 @@ cp_parser_initializer_clause (cp_parser* parser, bool* non_constant_p) /*allow_non_constant_p=*/true, non_constant_p); if (!*non_constant_p) - initializer = fold_non_dependent_expr (initializer); + { + /* We only want to fold if this is really a constant + expression. FIXME Actually, we don't want to fold here, but in + cp_finish_decl. */ + tree folded = fold_non_dependent_expr (initializer); + folded = maybe_constant_value (folded); + if (TREE_CONSTANT (folded)) + initializer = folded; + } } else initializer = cp_parser_braced_list (parser, non_constant_p); |