From c3e38a03df5f6074fd83d06c2c8d7393b0446026 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Mon, 9 Feb 2015 21:19:02 +0000 Subject: [PATCH] re PR c/64856 (Initializing struct not accepted in gnu99) PR c/64856 * c-typeck.c (process_init_element): Don't always wrap COMPOUND_LITERAL_EXPR in a SAVE_EXPR in C99 mode when initializing a range of elements. * gcc.dg/pr64856.c: New test. From-SVN: r220550 --- gcc/c/ChangeLog | 9 ++++++++- gcc/c/c-typeck.c | 3 +-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr64856.c | 13 +++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr64856.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 4c822f4ca09..fa5774cbea0 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,10 +1,17 @@ +2015-02-09 Marek Polacek + + PR c/64856 + * c-typeck.c (process_init_element): Don't always wrap + COMPOUND_LITERAL_EXPR in a SAVE_EXPR in C99 mode when + initializing a range of elements. + 2015-02-04 Jakub Jelinek PR c/64824 PR c/64868 * c-parser.c (c_parser_omp_atomic): Handle RDIV_EXPR. -2015-02-02 Bruno Loff +2015-02-02 Bruno Loff * c-parser.c (c_parser_declspecs): Call invoke_plugin_callbacks after processing enum declaration. diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 65c6f7f4272..a3a9c7760c7 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -8785,8 +8785,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit, /* If value is a compound literal and we'll be just using its content, don't put it into a SAVE_EXPR. */ if (TREE_CODE (value.value) != COMPOUND_LITERAL_EXPR - || !require_constant_value - || flag_isoc99) + || !require_constant_value) { tree semantic_type = NULL_TREE; if (TREE_CODE (value.value) == EXCESS_PRECISION_EXPR) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4fd039790e5..3d14e6041b8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-02-09 Marek Polacek + + PR c/64856 + * gcc.dg/pr64856.c: New test. + 2015-02-09 Jakub Jelinek PR target/64979 diff --git a/gcc/testsuite/gcc.dg/pr64856.c b/gcc/testsuite/gcc.dg/pr64856.c new file mode 100644 index 00000000000..c21d95a780a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr64856.c @@ -0,0 +1,13 @@ +/* PR c/64856 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct A { + unsigned long b; +}; + +struct B { + struct A c[5]; +}; + +struct B d = { .c = { [0 ... 4] = (struct A){ .b = 2 } } }; -- 2.30.2