===================================================================
@@ -4766,15 +4766,18 @@ check_array_designated_initializer (const construc
/* Designated initializers for array elements are not supported. */
if (ce->index)
{
+ tree ce_index = (TREE_CODE (ce->index) == CONST_DECL
+ ? integral_constant_value (ce->index) : ce->index);
+
/* 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)
+ else 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)
+ if (TREE_INT_CST_LOW (ce_index) == index)
return true;
else
sorry ("non-trivial designated initializers not supported");
===================================================================
@@ -0,0 +1,7 @@
+// PR c++/55951
+
+enum { A };
+
+static const char *a[] = {
+ [A] = "a"
+};