re PR c++/51229 ([C++0x] [4.7 Regression] Broken diagnostic: 'integer_cst' not supported by dump_dec)
PR c++/51229 * decl.c (reshape_init_class): Complain if d->cur->index is INTEGER_CST. * parser.c (cp_parser_initializer_list): If cp_parser_parse_definitely fails, clear designator. * g++.dg/ext/desig3.C: New test. From-SVN: r182088
This commit is contained in:
parent
14b1860e4e
commit
6f8e335e64
5 changed files with 28 additions and 1 deletions
|
@ -1,5 +1,11 @@
|
|||
2011-12-07 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/51229
|
||||
* decl.c (reshape_init_class): Complain if d->cur->index is
|
||||
INTEGER_CST.
|
||||
* parser.c (cp_parser_initializer_list): If cp_parser_parse_definitely
|
||||
fails, clear designator.
|
||||
|
||||
PR c++/51369
|
||||
* init.c (build_value_init): Allow array types even when
|
||||
processing_template_decl.
|
||||
|
|
|
@ -5078,6 +5078,14 @@ reshape_init_class (tree type, reshape_iter *d, bool first_initializer_p,
|
|||
/* Handle designated initializers, as an extension. */
|
||||
if (d->cur->index)
|
||||
{
|
||||
if (TREE_CODE (d->cur->index) == INTEGER_CST)
|
||||
{
|
||||
if (complain & tf_error)
|
||||
error ("%<[%E] =%> used in a GNU-style designated initializer"
|
||||
" for class %qT", d->cur->index, type);
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
field = lookup_field_1 (type, d->cur->index, /*want_type=*/false);
|
||||
|
||||
if (!field || TREE_CODE (field) != FIELD_DECL)
|
||||
|
|
|
@ -17737,7 +17737,8 @@ cp_parser_initializer_list (cp_parser* parser, bool* non_constant_p)
|
|||
designator = cp_parser_constant_expression (parser, false, NULL);
|
||||
cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
|
||||
cp_parser_require (parser, CPP_EQ, RT_EQ);
|
||||
cp_parser_parse_definitely (parser);
|
||||
if (!cp_parser_parse_definitely (parser))
|
||||
designator = NULL_TREE;
|
||||
}
|
||||
else
|
||||
designator = NULL_TREE;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
2011-12-07 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/51229
|
||||
* g++.dg/ext/desig3.C: New test.
|
||||
|
||||
PR c++/51369
|
||||
* g++.dg/cpp0x/constexpr-51369.C: New test.
|
||||
|
||||
|
|
9
gcc/testsuite/g++.dg/ext/desig3.C
Normal file
9
gcc/testsuite/g++.dg/ext/desig3.C
Normal file
|
@ -0,0 +1,9 @@
|
|||
// PR c++/51229
|
||||
// { dg-do compile }
|
||||
// { dg-options "" }
|
||||
|
||||
struct A { int i; };
|
||||
|
||||
int a[5] = { .foo = 7 };// { dg-error "used in a GNU-style designated initializer for an array" }
|
||||
int b[] = { .foo = 8 }; // { dg-error "used in a GNU-style designated initializer for an array" }
|
||||
A c = { [0] = {} }; // { dg-error "used in a GNU-style designated initializer for class" }
|
Loading…
Add table
Reference in a new issue