Commit f47165c9 by Steve Ellcey Committed by Steve Ellcey

re PR c++/28256 (ICE with empty initializer)

	PR c++/28256
	* decl.c (check_initializer): Check for 1 initializer on scalar types.
	* g++.dg/init/brace2.C: Change expected error message, add empty init.

From-SVN: r115856
parent 4fbbe694
2006-08-01 Steve Ellcey <sje@cup.hp.com>
PR c++/28256
* decl.c (check_initializer): Check for 1 initializer on scalar types.
2006-08-01 Daniel Jacobowitz <dan@codesourcery.com> 2006-08-01 Daniel Jacobowitz <dan@codesourcery.com>
PR debug/23336 PR debug/23336
......
...@@ -4730,6 +4730,14 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup) ...@@ -4730,6 +4730,14 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup)
TREE_TYPE (decl) = error_mark_node; TREE_TYPE (decl) = error_mark_node;
init = NULL_TREE; init = NULL_TREE;
} }
else if (!CP_AGGREGATE_TYPE_P (type)
&& init && BRACE_ENCLOSED_INITIALIZER_P (init)
&& VEC_length (constructor_elt, CONSTRUCTOR_ELTS (init)) != 1)
{
error ("scalar object %qD requires one element in initializer", decl);
TREE_TYPE (decl) = error_mark_node;
init = NULL_TREE;
}
if (TREE_CODE (decl) == CONST_DECL) if (TREE_CODE (decl) == CONST_DECL)
{ {
......
2006-08-01 Steve Ellcey <sje@cup.hp.com>
PR c++/28256
* g++.dg/init/brace2.C: Change expected error message, add empty init.
2006-08-01 Daniel Jacobowitz <dan@codesourcery.com> 2006-08-01 Daniel Jacobowitz <dan@codesourcery.com>
PR debug/23336 PR debug/23336
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
int x = { 2 }; int x = { 2 };
const char * y = { "hello" }; const char * y = { "hello" };
int a = 2; int a = 2;
int b = { 2,3 }; // { dg-error "too many initializers" } int b = { 2,3 }; // { dg-error "requires one element in initializer" }
int c = { { 2 } } ; // { dg-error "braces around scalar initializer" } int c = { { 2 } } ; // { dg-error "braces around scalar initializer" }
int d = {}; // { dg-error "requires one element in initializer" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment