aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-03-16 16:04:06 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-03-16 16:04:06 -0400
commit0136dc743ab537adaedffe94934c73f05e9d0204 (patch)
tree950dfde283028dc553b438f7fde310255714debd /gcc
parentf8f122781fa0c372ec99151f6584f2678ff4e0fd (diff)
downloadgcc-0136dc743ab537adaedffe94934c73f05e9d0204.zip
gcc-0136dc743ab537adaedffe94934c73f05e9d0204.tar.gz
gcc-0136dc743ab537adaedffe94934c73f05e9d0204.tar.bz2
re PR c++/48132 ([C++0x] Internal compiler error on array of std::complex with -std=c++0x)
PR c++/48132 * decl.c (check_array_designated_initializer): Allow integer index. (reshape_init_array_1): Set index on the elements. From-SVN: r171068
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c6
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-array3.C14
4 files changed, 29 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4649d96..a1f8f04 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
2011-03-16 Jason Merrill <jason@redhat.com>
+ PR c++/48132
+ * decl.c (check_array_designated_initializer): Allow integer index.
+ (reshape_init_array_1): Set index on the elements.
+
+2011-03-16 Jason Merrill <jason@redhat.com>
+
PR c++/48113
* typeck.c (convert_for_initialization): Use
perform_implicit_conversion_flags.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index f9d90ad..3139ad8 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4596,6 +4596,9 @@ check_array_designated_initializer (const constructor_elt *ce)
if (ce->index == error_mark_node)
error ("name used in a GNU-style designated "
"initializer for an array");
+ else if (TREE_CODE (ce->index) == INTEGER_CST)
+ /* An index added by reshape_init. */
+ return true;
else
{
gcc_assert (TREE_CODE (ce->index) == IDENTIFIER_NODE);
@@ -4899,7 +4902,8 @@ reshape_init_array_1 (tree elt_type, tree max_index, reshape_iter *d)
elt_init = reshape_init_r (elt_type, d, /*first_initializer_p=*/false);
if (elt_init == error_mark_node)
return error_mark_node;
- CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (new_init), NULL_TREE, elt_init);
+ CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (new_init),
+ size_int (index), elt_init);
}
return new_init;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index dee4a8d..f5e7580 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2011-03-16 Jason Merrill <jason@redhat.com>
+ * g++.dg/cpp0x/constexpr-array3.C: New.
+
+2011-03-16 Jason Merrill <jason@redhat.com>
+
* g++.dg/cpp0x/sfinae6.C: New.
* gcc/testsuite/g++.dg/cpp0x/initlist38.C: Adjust expected error.
* gcc/testsuite/g++.dg/cpp0x/pr45908.C: Likewise.
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array3.C
new file mode 100644
index 0000000..145a430
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array3.C
@@ -0,0 +1,14 @@
+// PR c++/48132
+// { dg-options -std=c++0x }
+
+struct C
+{
+ constexpr C (int x) : c (x) {}
+ int c;
+};
+
+void
+foo ()
+{
+ C a[] = { C (0) };
+}