diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-07-22 10:11:16 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-07-22 10:11:16 +0000 |
commit | 9a7bab7f97e44fe2e5cc6392d744ad5acb069e40 (patch) | |
tree | 3ea4f8ebfcd8cea35de19665d6ffa3cbdf453ef4 /gcc/testsuite/gcc.dg/gnu89-init-2.c | |
parent | 5ba2a872f115cad18d6a51c4e11b591eda5dc57e (diff) | |
download | gcc-9a7bab7f97e44fe2e5cc6392d744ad5acb069e40.tar.gz |
* c-decl.c (build_compound_literal): Defer compound literal decls
until until file end to emit them only if they are actually used.
* gcc.dg/gnu89-init-2.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@55645 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/gnu89-init-2.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/gnu89-init-2.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/gnu89-init-2.c b/gcc/testsuite/gcc.dg/gnu89-init-2.c new file mode 100644 index 00000000000..ce966ec8987 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gnu89-init-2.c @@ -0,0 +1,25 @@ +/* Test whether __compound_literal.* objects are not emitted unless + they are actually needed. */ +/* Origin: Jakub Jelinek <jakub@redhat.com> */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -O2" } */ +/* { dg-final { scan-assembler-not "__compound_literal" } } */ + +struct A { int i; int j; int k[4]; }; +struct B { }; +struct C { int i; }; +struct D { int i; struct C j; }; + +struct A a = (struct A) { .j = 6, .k[2] = 12 }; +struct B b = (struct B) { }; +int c[] = (int []) { [2] = 6, 7, 8 }; +int d[] = (int [3]) { 1 }; +int e[2] = (int []) { 1, 2 }; +int f[2] = (int [2]) { 1 }; +struct C g[3] = { [2] = (struct C) { 13 }, [1] = (const struct C) { 12 } }; +struct D h = { .j = (struct C) { 15 }, .i = 14 }; +struct D i[2] = { [1].j = (const struct C) { 17 }, + [0] = { 0, (struct C) { 16 } } }; +static const int *j = 1 ? (const int *) 0 : & (const int) { 26 }; +int k = (int) sizeof ((int [6]) { 1, 2, 3, 4, 5, 6 }) + 4; +int l = (int) sizeof ((struct C) { 16 }); |