diff options
Diffstat (limited to 'gcc/c/c-parser.cc')
| -rw-r--r-- | gcc/c/c-parser.cc | 33 | 
1 files changed, 15 insertions, 18 deletions
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 0cf3f92..9b3a786 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -1767,7 +1767,7 @@ static tree c_parser_simple_asm_expr (c_parser *);  static tree c_parser_gnu_attributes (c_parser *);  static struct c_expr c_parser_initializer (c_parser *, tree);  static struct c_expr c_parser_braced_init (c_parser *, tree, bool, -					   struct obstack *, tree); +					   struct obstack *, bool);  static void c_parser_initelt (c_parser *, struct obstack *);  static void c_parser_initval (c_parser *, struct c_expr *,  			      struct obstack *); @@ -6459,7 +6459,9 @@ static struct c_expr  c_parser_initializer (c_parser *parser, tree decl)  {    if (c_parser_next_token_is (parser, CPP_OPEN_BRACE)) -    return c_parser_braced_init (parser, NULL_TREE, false, NULL, decl); +    return c_parser_braced_init (parser, NULL_TREE, false, NULL, +				 decl != error_mark_node +				 && C_DECL_VARIABLE_SIZE (decl));    else      {        struct c_expr ret; @@ -6499,12 +6501,12 @@ location_t last_init_list_comma;     compound literal, and NULL_TREE for other initializers and for     nested braced lists.  NESTED_P is true for nested braced lists,     false for the list of a compound literal or the list that is the -   top-level initializer in a declaration.  DECL is the declaration for -   the top-level initializer for a declaration, otherwise NULL_TREE.  */ +   top-level initializer in a declaration.  VARSIZE_P indicates +   wether the object to be initialized has a variable size.  */  static struct c_expr  c_parser_braced_init (c_parser *parser, tree type, bool nested_p, -		      struct obstack *outer_obstack, tree decl) +		      struct obstack *outer_obstack, bool varsize_p)  {    struct c_expr ret;    struct obstack braced_init_obstack; @@ -6532,7 +6534,7 @@ c_parser_braced_init (c_parser *parser, tree type, bool nested_p,      }    else      { -      if (decl && decl != error_mark_node && C_DECL_VARIABLE_SIZE (decl)) +      if (varsize_p)  	error_at (brace_loc,  		  "variable-sized object may not be initialized except "  		  "with an empty initializer"); @@ -6826,7 +6828,7 @@ c_parser_initval (c_parser *parser, struct c_expr *after,    if (c_parser_next_token_is (parser, CPP_OPEN_BRACE) && !after)      init = c_parser_braced_init (parser, NULL_TREE, true, -				 braced_init_obstack, NULL_TREE); +				 braced_init_obstack, false);    else      {        init = c_parser_expr_no_commas (parser, after); @@ -11793,15 +11795,9 @@ c_parser_postfix_expression (c_parser *parser)  	    else  	      {  		tree type_expr = NULL_TREE; +		tree type = groktypename (t1, &type_expr, NULL);  		expr.value = c_build_va_arg (start_loc, e1.value, loc, -					     groktypename (t1, &type_expr, NULL)); -		if (type_expr) -		  { -		    expr.value = build2 (C_MAYBE_CONST_EXPR, -					 TREE_TYPE (expr.value), type_expr, -					 expr.value); -		    C_MAYBE_CONST_EXPR_NON_CONST (expr.value) = true; -		  } +					     type, type_expr);  		set_c_expr_source_range (&expr, start_loc, end_loc);  	      }  	  } @@ -13516,10 +13512,11 @@ c_parser_postfix_expression_after_paren_type (c_parser *parser,  	       || (scspecs && scspecs->storage_class == csc_static)  	       || constexpr_p), constexpr_p, &richloc);    type = groktypename (type_name, &type_expr, &type_expr_const); +  bool varsize_p = false;    if (type != error_mark_node && C_TYPE_VARIABLE_SIZE (type))      { -      error_at (type_loc, "compound literal has variable size"); -      type = error_mark_node; +      pedwarn (type_loc, OPT_Wpedantic, "compound literal has variable size"); +      varsize_p = true;      }    else if (TREE_CODE (type) == FUNCTION_TYPE)      { @@ -13544,7 +13541,7 @@ c_parser_postfix_expression_after_paren_type (c_parser *parser,  				     (TYPE_QUALS (type_no_array)  				      | TYPE_QUAL_CONST));      } -  init = c_parser_braced_init (parser, type, false, NULL, NULL_TREE); +  init = c_parser_braced_init (parser, type, false, NULL, varsize_p);    if (constexpr_p)      finish_underspecified_init (NULL_TREE, underspec_state);    finish_init ();  | 
