mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-14 08:39:40 +08:00
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:
parent
4fbbe6941c
commit
f47165c975
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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" }
|
||||
|
Loading…
Reference in New Issue
Block a user