aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2014-06-03 00:57:39 -0400
committerJason Merrill <jason@gcc.gnu.org>2014-06-03 00:57:39 -0400
commit99d14de62fb7401b8099c42fca44413662318e40 (patch)
treeb5ec0e160827f7b27902acaa13319454c927cc46 /gcc
parentcfc8dced31257ef31f86a032da2c9e4cce53f563 (diff)
downloadgcc-99d14de62fb7401b8099c42fca44413662318e40.zip
gcc-99d14de62fb7401b8099c42fca44413662318e40.tar.gz
gcc-99d14de62fb7401b8099c42fca44413662318e40.tar.bz2
re PR c++/61046 (ICE in lookup_field_1, at cp/search.c:384)
PR c++/61046 * decl.c (reshape_init_class): Handle un-folded constant-expressions. From-SVN: r211160
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/decl.c13
-rw-r--r--gcc/testsuite/g++.dg/ext/desig7.C8
3 files changed, 18 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e57edc5..fae8da1 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2014-06-02 Jason Merrill <jason@redhat.com>
+ PR c++/61046
+ * decl.c (reshape_init_class): Handle un-folded
+ constant-expressions.
+
PR c++/61134
* pt.c (pack_deducible_p): Handle canonicalization.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index c61ad68..8dc5f1f 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5294,7 +5294,12 @@ reshape_init_class (tree type, reshape_iter *d, bool first_initializer_p,
if (d->cur->index == error_mark_node)
return error_mark_node;
- if (TREE_CODE (d->cur->index) == INTEGER_CST)
+ if (TREE_CODE (d->cur->index) == FIELD_DECL)
+ /* We already reshaped this. */
+ gcc_assert (d->cur->index == field);
+ else if (TREE_CODE (d->cur->index) == IDENTIFIER_NODE)
+ field = lookup_field_1 (type, d->cur->index, /*want_type=*/false);
+ else
{
if (complain & tf_error)
error ("%<[%E] =%> used in a GNU-style designated initializer"
@@ -5302,12 +5307,6 @@ reshape_init_class (tree type, reshape_iter *d, bool first_initializer_p,
return error_mark_node;
}
- if (TREE_CODE (d->cur->index) == FIELD_DECL)
- /* We already reshaped this. */
- gcc_assert (d->cur->index == field);
- else
- field = lookup_field_1 (type, d->cur->index, /*want_type=*/false);
-
if (!field || TREE_CODE (field) != FIELD_DECL)
{
if (complain & tf_error)
diff --git a/gcc/testsuite/g++.dg/ext/desig7.C b/gcc/testsuite/g++.dg/ext/desig7.C
new file mode 100644
index 0000000..44358ec
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/desig7.C
@@ -0,0 +1,8 @@
+// PR c++/61046
+
+struct A
+{
+ int ary[4];
+};
+const int i = 0;
+A bar = { [i] = 0 }; // { dg-error "designated" }