aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2011-12-07 21:43:06 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2011-12-07 21:43:06 +0100
commit6f8e335e64fdac2f205714e2ccda0df654f3cdb9 (patch)
treed785b96dbf47464fb3dd0f3a5aea61925e294546 /gcc
parent14b1860e4e982d27e6669621c105e72d6c8bff41 (diff)
downloadgcc-6f8e335e64fdac2f205714e2ccda0df654f3cdb9.zip
gcc-6f8e335e64fdac2f205714e2ccda0df654f3cdb9.tar.gz
gcc-6f8e335e64fdac2f205714e2ccda0df654f3cdb9.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c8
-rw-r--r--gcc/cp/parser.c3
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/ext/desig3.C9
5 files changed, 28 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 76bd0af..0224868 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 055c1b2..07cc9e6 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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)
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 17a607d..5952a0f 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1a4a182..9803f77 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/ext/desig3.C b/gcc/testsuite/g++.dg/ext/desig3.C
new file mode 100644
index 0000000..d1ff5e5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/desig3.C
@@ -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" }