PR c++/61046
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Jun 2014 04:57:39 +0000 (04:57 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Jun 2014 04:57:39 +0000 (04:57 +0000)
* decl.c (reshape_init_class): Handle un-folded
constant-expressions.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211160 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/ext/desig7.C [new file with mode: 0644]

index e57edc5..fae8da1 100644 (file)
@@ -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.
 
index c61ad68..8dc5f1f 100644 (file)
@@ -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 (file)
index 0000000..44358ec
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/61046
+
+struct A
+{
+  int ary[4];
+};
+const int i = 0;
+A bar = { [i] = 0 }; // { dg-error "designated" }