diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-29 11:15:27 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-29 11:15:27 +0000 |
commit | 3bc7521a3c29a77cbd5e5247d3e474c07d628ae6 (patch) | |
tree | 05e6cc55deff5f86a6391e8a7be37e25bc5871e6 /gcc/cp | |
parent | c1f70dd1d4fb1f6b0b16421a95b173c2f73abc91 (diff) | |
download | gcc-3bc7521a3c29a77cbd5e5247d3e474c07d628ae6.tar.gz |
2012-05-29 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 187948 using svnmerge
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@187951 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 45 | ||||
-rw-r--r-- | gcc/cp/call.c | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 3 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 5 | ||||
-rw-r--r-- | gcc/cp/parser.c | 34 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 1 | ||||
-rw-r--r-- | gcc/cp/tree.c | 5 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 9 |
8 files changed, 90 insertions, 18 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 391407fb9da..5850ff6847d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,48 @@ +2012-05-28 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/53503 + * semantics.c (potential_constant_expression_1): Handle LTGT_EXPR. + +2012-05-26 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/53491 + * tree.c (stabilize_expr): Handle exp of void type. + +2012-05-26 Jason Merrill <jason@redhat.com> + + PR c++/53220 + * call.c (convert_like_real) [ck_list]: Take array address directly. + * typeck.c (decay_conversion): Reject decay of an array compound + literal. + +2012-05-25 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/32054 + * parser.c (cp_parser_member_declaration): A storage class is not + allowed in a declaration of an anonymous aggregate in a class scope. + +2012-05-24 Uros Bizjak <ubizjak@gmail.com> + + PR obj-c++/53441 + * decl.c (grokdeclarator): Check that current_class_type is non-NULL + before calling constructor_name_p. + +2012-05-24 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/32080 + * parser.c (cp_parser_ctor_initializer_opt_and_function_body, + cp_parser_function_body): Add a bool parameter, true when parsing + a function-try-block. + (cp_parser_function_try_block): Pass true to the above. + (cp_parser_function_definition_after_declarator, + cp_parser_function_transaction): Adjust. + +2012-05-23 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/29185 + * decl2.c (delete_sanity): Extend 'deleting array' warning to + any array type. + 2012-05-21 Paolo Carlini <paolo.carlini@oracle.com> PR c++/51184 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index daaae2b6ead..5efa57cd759 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5849,11 +5849,15 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, (elttype, cp_type_quals (elttype) | TYPE_QUAL_CONST); array = build_array_of_n_type (elttype, len); array = finish_compound_literal (array, new_ctor, complain); + /* Take the address explicitly rather than via decay_conversion + to avoid the error about taking the address of a temporary. */ + array = cp_build_addr_expr (array, complain); + array = cp_convert (build_pointer_type (elttype), array); /* Build up the initializer_list object. */ totype = complete_type (totype); field = next_initializable_field (TYPE_FIELDS (totype)); - CONSTRUCTOR_APPEND_ELT (vec, field, decay_conversion (array, complain)); + CONSTRUCTOR_APPEND_ELT (vec, field, array); field = next_initializable_field (DECL_CHAIN (field)); CONSTRUCTOR_APPEND_ELT (vec, field, size_int (len)); new_ctor = build_constructor (totype, vec); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d883da6b640..14a6a40d6ce 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -9803,7 +9803,8 @@ grokdeclarator (const cp_declarator *declarator, clones. */ DECL_ABSTRACT (decl) = 1; } - else if (constructor_name_p (unqualified_id, current_class_type)) + else if (current_class_type + && constructor_name_p (unqualified_id, current_class_type)) permerror (input_location, "ISO C++ forbids nested type %qD with same name " "as enclosing class", unqualified_id); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index c40b830a1aa..bf9ca333b35 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -438,9 +438,8 @@ delete_sanity (tree exp, tree size, bool doing_vec, int use_global_delete, } /* An array can't have been allocated by new, so complain. */ - if (TREE_CODE (exp) == VAR_DECL - && TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE) - warning (0, "deleting array %q#D", exp); + if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE) + warning (0, "deleting array %q#E", exp); t = build_expr_type_conversion (WANT_POINTER, exp, true); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 56e54634a4e..9fd8c84d923 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -1989,7 +1989,7 @@ static cp_parameter_declarator *cp_parser_parameter_declaration static tree cp_parser_default_argument (cp_parser *, bool); static void cp_parser_function_body - (cp_parser *); + (cp_parser *, bool); static tree cp_parser_initializer (cp_parser *, bool *, bool *); static tree cp_parser_initializer_clause @@ -2000,7 +2000,7 @@ static VEC(constructor_elt,gc) *cp_parser_initializer_list (cp_parser *, bool *); static bool cp_parser_ctor_initializer_opt_and_function_body - (cp_parser *); + (cp_parser *, bool); /* Classes [gram.class] */ @@ -17395,16 +17395,18 @@ cp_parser_default_argument (cp_parser *parser, bool template_parm_p) compound_statement */ static void -cp_parser_function_body (cp_parser *parser) +cp_parser_function_body (cp_parser *parser, bool in_function_try_block) { - cp_parser_compound_statement (parser, NULL, false, true); + cp_parser_compound_statement (parser, NULL, in_function_try_block, true); } /* Parse a ctor-initializer-opt followed by a function-body. Return - true if a ctor-initializer was present. */ + true if a ctor-initializer was present. When IN_FUNCTION_TRY_BLOCK + is true we are parsing a function-try-block. */ static bool -cp_parser_ctor_initializer_opt_and_function_body (cp_parser *parser) +cp_parser_ctor_initializer_opt_and_function_body (cp_parser *parser, + bool in_function_try_block) { tree body, list; bool ctor_initializer_p; @@ -17431,7 +17433,7 @@ cp_parser_ctor_initializer_opt_and_function_body (cp_parser *parser) last = STATEMENT_LIST_TAIL (list)->stmt; } /* Parse the function-body. */ - cp_parser_function_body (parser); + cp_parser_function_body (parser, in_function_try_block); if (check_body_p) check_constexpr_ctor_body (last, list); /* Finish the function body. */ @@ -18908,6 +18910,12 @@ cp_parser_member_declaration (cp_parser* parser) particular type), as opposed to a nested class. */ else if (ANON_AGGR_TYPE_P (type)) { + /* C++11 9.5/6. */ + if (decl_specifiers.storage_class != sc_none) + error_at (decl_spec_token_start->location, + "a storage class on an anonymous aggregate " + "in class scope is not allowed"); + /* Remove constructors and such from TYPE, now that we know it is an anonymous aggregate. */ fixup_anonymous_aggr (type); @@ -19707,8 +19715,8 @@ cp_parser_function_try_block (cp_parser* parser) /* Let the rest of the front end know where we are. */ try_block = begin_function_try_block (&compound_stmt); /* Parse the function-body. */ - ctor_initializer_p - = cp_parser_ctor_initializer_opt_and_function_body (parser); + ctor_initializer_p = cp_parser_ctor_initializer_opt_and_function_body + (parser, /*in_function_try_block=*/true); /* We're done with the `try' part. */ finish_function_try_block (try_block); /* Parse the handlers. */ @@ -21048,8 +21056,8 @@ cp_parser_function_definition_after_declarator (cp_parser* parser, else if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TRY)) ctor_initializer_p = cp_parser_function_try_block (parser); else - ctor_initializer_p - = cp_parser_ctor_initializer_opt_and_function_body (parser); + ctor_initializer_p = cp_parser_ctor_initializer_opt_and_function_body + (parser, /*in_function_try_block=*/false); finish_lambda_scope (); @@ -27224,8 +27232,8 @@ cp_parser_function_transaction (cp_parser *parser, enum rid keyword) if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TRY)) ctor_initializer_p = cp_parser_function_try_block (parser); else - ctor_initializer_p - = cp_parser_ctor_initializer_opt_and_function_body (parser); + ctor_initializer_p = cp_parser_ctor_initializer_opt_and_function_body + (parser, /*in_function_try_block=*/false); parser->in_transaction = old_in; diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 8b53d277fbd..263ebc27668 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8487,6 +8487,7 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags) case UNGT_EXPR: case UNGE_EXPR: case UNEQ_EXPR: + case LTGT_EXPR: case RANGE_EXPR: case COMPLEX_EXPR: want_rval = true; diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 7c59105b9ce..236180de7fd 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -3281,6 +3281,11 @@ stabilize_expr (tree exp, tree* initp) if (!TREE_SIDE_EFFECTS (exp)) init_expr = NULL_TREE; + else if (VOID_TYPE_P (TREE_TYPE (exp))) + { + *initp = exp; + return void_zero_node; + } /* There are no expressions with REFERENCE_TYPE, but there can be call arguments with such a type; just treat it as a pointer. */ else if (TREE_CODE (TREE_TYPE (exp)) == REFERENCE_TYPE diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 92794ea77a2..901b15fcd16 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1886,6 +1886,15 @@ decay_conversion (tree exp, tsubst_flags_t complain) return error_mark_node; } + /* Don't let an array compound literal decay to a pointer. It can + still be used to initialize an array or bind to a reference. */ + if (TREE_CODE (exp) == TARGET_EXPR) + { + if (complain & tf_error) + error_at (loc, "taking address of temporary array"); + return error_mark_node; + } + ptrtype = build_pointer_type (TREE_TYPE (type)); if (TREE_CODE (exp) == VAR_DECL) |