diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-01-07 23:55:48 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-01-07 23:55:48 +0100 |
commit | c4581bbfb4a20bce2fb9d9dace1f30e4d5a494e8 (patch) | |
tree | 811169e27ff0b6859fe311ad5efb35c4b677067e /gcc | |
parent | 2d8d93c783dd43769075fa0474d670f6fb4a85f1 (diff) | |
download | gcc-c4581bbfb4a20bce2fb9d9dace1f30e4d5a494e8.zip gcc-c4581bbfb4a20bce2fb9d9dace1f30e4d5a494e8.tar.gz gcc-c4581bbfb4a20bce2fb9d9dace1f30e4d5a494e8.tar.bz2 |
re PR c/88701 (Internal compiler error for valid program using compound literal with variably modified type.)
PR c/88701
* c-decl.c (build_compound_literal): If not TREE_STATIC, only pushdecl
if current_function_decl is non-NULL.
* gcc.dg/pr88701.c: New test.
From-SVN: r267667
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr88701.c | 18 |
4 files changed, 30 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 5ee4b66..7cffd90 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2019-01-07 Jakub Jelinek <jakub@redhat.com> + + PR c/88701 + * c-decl.c (build_compound_literal): If not TREE_STATIC, only pushdecl + if current_function_decl is non-NULL. + 2019-01-07 Joseph Myers <joseph@codesourcery.com> PR c/88720 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 5c7232f..57049f8 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -5438,7 +5438,7 @@ build_compound_literal (location_t loc, tree type, tree init, bool non_const, pushdecl (decl); rest_of_decl_compilation (decl, 1, 0); } - else + else if (current_function_decl) pushdecl (decl); if (non_const) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ebc96a3..72e9d8e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-07 Jakub Jelinek <jakub@redhat.com> + + PR c/88701 + * gcc.dg/pr88701.c: New test. + 2019-01-07 Joseph Myers <joseph@codesourcery.com> PR c/88720 diff --git a/gcc/testsuite/gcc.dg/pr88701.c b/gcc/testsuite/gcc.dg/pr88701.c new file mode 100644 index 0000000..7aa846d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr88701.c @@ -0,0 +1,18 @@ +/* PR c/88701 */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +void foo (int [(int (*)[1]) { 0 } == 0]); +void bar (int n, int [(int (*)[n]) { 0 } == 0]); + +int +baz (int a[(int (*)[1]) { 0 } == 0]) +{ + return a[0]; +} + +int +qux (int n, int a[(int (*)[n]) { 0 } == 0]) +{ + return a[0] + n; +} |