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
This commit is contained in:
Steve Ellcey 2006-08-01 16:31:40 +00:00 committed by Steve Ellcey
parent 4fbbe6941c
commit f47165c975
4 changed files with 20 additions and 2 deletions

View File

@ -1,3 +1,8 @@
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>
PR debug/23336

View File

@ -4730,6 +4730,14 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup)
TREE_TYPE (decl) = error_mark_node;
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)
{

View File

@ -1,3 +1,8 @@
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>
PR debug/23336

View File

@ -3,6 +3,6 @@
int x = { 2 };
const char * y = { "hello" };
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 d = {}; // { dg-error "requires one element in initializer" }