diff options
author | mrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-05-18 18:22:12 +0000 |
---|---|---|
committer | mrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-05-18 18:22:12 +0000 |
commit | 32d33ab2b6aa8f79eaa31808de566d58d1a85b55 (patch) | |
tree | 3393aa88e335ad0c151ee642c9e17e8807ed52e9 /gcc/testsuite/gcc.dg/vla-6.c | |
parent | 64089cc9f030d8ef7972adb5d117e0b23f47d62b (diff) | |
download | gcc-32d33ab2b6aa8f79eaa31808de566d58d1a85b55.tar.gz |
Fix up vla, vm and [*] sematics.
PR c/18740
PR c/7948
PR c/25802
* c-tree.h (struct c_arg_info): Add had_vla_unspec.
(c_vla_unspec_p): Add.
(c_vla_type_p): Add.
* c-decl.c (struct c_scope): Add had_vla_unspec.
(build_array_declarator): Add support for [*].
(grokdeclarator): Likewise.
(grokparms): Likewise.
(get_parm_info): Likewise.
* c-objc-common.c (c_vla_unspec_p): Likewise.
* c-objc-common.h (LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P): Likewise.
* c-parser.c (c_parser_typeof_specifier): Evaluate arguments to
typeof when argument is a variably modified type not inside sizeof or alignof.
(c_parser_direct_declarator_inner): Propagate errors.
(c_parser_sizeof_expression): Add support for [*].
* c-typeck.c (c_vla_type_p): Add.
(composite_type): Add support for vla compositing.
(comptypes_internal): Add support for vla compatibility.
(c_expr_sizeof_expr): Evaluate vla arguments.
* tree.c (variably_modified_type_p): Update comment for [*].
testsuite:
* gcc.dg/c90-arraydecl-1.c: Update for vla, vm [*] fixups.
* gcc.dg/vla-4.c: Add.
* gcc.dg/vla-5.c: Add.
* gcc.dg/vla-6.c: Add.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113888 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/vla-6.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/vla-6.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/vla-6.c b/gcc/testsuite/gcc.dg/vla-6.c new file mode 100644 index 00000000000..b7bdb31eeca --- /dev/null +++ b/gcc/testsuite/gcc.dg/vla-6.c @@ -0,0 +1,26 @@ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +int a[*]; /* { dg-error "not allowed in other than function prototype scope" } */ +void foo1() { int a[*]; } /* { dg-error "not allowed in other than function prototype scope" } */ +void foo2() { int a[*]; } /* { dg-error "not allowed in other than function prototype scope" } */ +int foo3(int i)[*]; /* { dg-error "not allowed in other than function prototype scope" } */ +void foo4(int o[*][4]) { } /* { dg-error "not allowed in other than function prototype scope" } */ +void foo5(int o[4][*]) { } /* { dg-error "not allowed in other than function prototype scope" } */ + +/* [*] can't be used in a type that's not a declaration */ +void foo11(int x[sizeof(int (*)[*])]); /* { dg-error "not allowed in other than a declaration" } */ +void foo12(int [*]); /* { dg-error "not allowed in other than a declaration" } */ + +extern int n; +int B[100]; +void foo10(int m) { + typedef int (*vla)[m]; + struct tag { + vla x; /* { dg-error "a member of a structure or union cannot have a variably modified type" } */ + /* PR c/7948 */ + int (*y)[n]; /* { dg-error "a member of a structure or union cannot have a variably modified type" } */ + int z[n]; /* { dg-error "a member of a structure or union cannot have a variably modified type" } */ + }; + /* PR c/25802 */ + extern int (*r)[m]; /* { dg-error "variably modified type must have no linkage" } */ +} |