aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2013-03-26 16:49:49 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2013-03-26 16:49:49 +0000
commit515e4d1d5a8ad5aaeefc81e2593db778c92860fe (patch)
treeaff0b875826f6a2c39bce2ccd7646d85f92c45ed /gcc/cp
parent6f33817e6ae3515ef30a0d0d0e740f56479dd882 (diff)
downloadgcc-515e4d1d5a8ad5aaeefc81e2593db778c92860fe.zip
gcc-515e4d1d5a8ad5aaeefc81e2593db778c92860fe.tar.gz
gcc-515e4d1d5a8ad5aaeefc81e2593db778c92860fe.tar.bz2
re PR c++/55951 (ICE in check_array_designated_initializer, at cp/decl.c:4785)
/cp 2013-03-26 Paolo Carlini <paolo.carlini@oracle.com> PR c++/55951 * decl.c (check_array_designated_initializer): Handle CONST_DECL as ce->index. /testsuite 2013-03-26 Paolo Carlini <paolo.carlini@oracle.com> PR c++/55951 * g++.dg/ext/desig5.C: New. From-SVN: r197116
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c27
2 files changed, 24 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3dfb31a..01044e4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
2013-03-26 Paolo Carlini <paolo.carlini@oracle.com>
+ PR c++/55951
+ * decl.c (check_array_designated_initializer): Handle CONST_DECL
+ as ce->index.
+
+2013-03-26 Paolo Carlini <paolo.carlini@oracle.com>
+
* decl.c (grokfndecl): Handle separately <inline> and <constexpr>
error messages.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a821328..ca68bb5 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4760,7 +4760,7 @@ grok_reference_init (tree decl, tree type, tree init, int flags)
is valid, i.e., does not have a designated initializer. */
static bool
-check_array_designated_initializer (const constructor_elt *ce,
+check_array_designated_initializer (constructor_elt *ce,
unsigned HOST_WIDE_INT index)
{
/* Designated initializers for array elements are not supported. */
@@ -4769,9 +4769,21 @@ check_array_designated_initializer (const constructor_elt *ce,
/* The parser only allows identifiers as designated
initializers. */
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)
+ {
+ error ("name used in a GNU-style designated "
+ "initializer for an array");
+ return false;
+ }
+ else if (identifier_p (ce->index))
+ {
+ error ("name %qD used in a GNU-style designated "
+ "initializer for an array", ce->index);
+ return false;
+ }
+
+ ce->index = cxx_constant_value (ce->index);
+
+ if (TREE_CODE (ce->index) == INTEGER_CST)
{
/* A C99 designator is OK if it matches the current index. */
if (TREE_INT_CST_LOW (ce->index) == index)
@@ -4780,11 +4792,8 @@ check_array_designated_initializer (const constructor_elt *ce,
sorry ("non-trivial designated initializers not supported");
}
else
- {
- gcc_assert (identifier_p (ce->index));
- error ("name %qD used in a GNU-style designated "
- "initializer for an array", ce->index);
- }
+ gcc_unreachable ();
+
return false;
}