diff options
author | Joseph Myers <jsm28@cam.ac.uk> | 2001-05-25 12:12:47 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2001-05-25 12:12:47 +0100 |
commit | 0e03329a6f5e6abf7df9adb8331136414e6fb5a6 (patch) | |
tree | 0d9cee59da5c70c8d1b6baefbc0569ba13d97432 /gcc/testsuite | |
parent | b60868e00c8cc0fdda3018293c6c1149a62bed52 (diff) | |
download | gcc-0e03329a6f5e6abf7df9adb8331136414e6fb5a6.zip gcc-0e03329a6f5e6abf7df9adb8331136414e6fb5a6.tar.gz gcc-0e03329a6f5e6abf7df9adb8331136414e6fb5a6.tar.bz2 |
c-parse.in (array_declarator): New.
* c-parse.in (array_declarator): New. Handle C99 constructs.
Don't restrict [*] declarators to C only.
(after_type_declarator, parm_declarator_starttypename,
parm_declarator_nostarttypename, notype_declarator,
direct_absdcl1): Use it.
* c-decl.c (build_array_declarator, set_array_declarator_type):
New functions. Warn that [*] isn't properly implemented; pedwarn
for [*] outside C99 mode if pedantic rather than giving a hard
error.
(grokdeclarator): Handle static and type qualifiers in parameter
array declarators.
* c-tree.h (build_array_declarator, set_array_declarator_type):
Declare.
* extend.texi (Attribute Syntax): Document attributes in parameter
array declarators.
testsuite:
* gcc.dg/c90-arraydecl-1.c, gcc.dg/c99-arraydecl-1.c: New tests.
From-SVN: r42574
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c90-arraydecl-1.c | 31 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c99-arraydecl-1.c | 111 |
3 files changed, 146 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5dc9c2d..5ce646c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-05-25 Joseph S. Myers <jsm28@cam.ac.uk> + + * gcc.dg/c90-arraydecl-1.c, gcc.dg/c99-arraydecl-1.c: New tests. + 2001-05-24 Mark Mitchell <mark@codesourcery.com> G++ no longer defines builtins that do not begin with __builtin. diff --git a/gcc/testsuite/gcc.dg/c90-arraydecl-1.c b/gcc/testsuite/gcc.dg/c90-arraydecl-1.c new file mode 100644 index 0000000..b3e7035 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c90-arraydecl-1.c @@ -0,0 +1,31 @@ +/* Test for C99 forms of array declarator: rejected in C90. */ +/* Origin: Joseph Myers <jsm28@cam.ac.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +/* Use of [*] (possibly with type qualifiers) in an array declarator with + function prototype scope is a C99 feature. GCC does not yet implement + it correctly, so gives a warning about this. so we can't yet test here + that we get just one error and no warnings. */ + +void foo0 (int a, int b[*]); /* { dg-error "ISO C89" "\[*\] not in C89" } */ +/* { dg-warning "implement" "\[*\] not implemented" { target *-*-* } 11 } */ +void foo1 (int, int [*]); /* { dg-error "ISO C89" "\[*\] not in C89" } */ +/* { dg-warning "implement" "\[*\] not implemented" { target *-*-* } 13 } */ + +/* Use of static and type qualifiers (not allowed with abstract declarators) + is a C99 feature. */ + +void bar0 (int a[const]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "ISO C89" "\[quals\] not in C89" { target *-*-* } 19 } */ +void bar1 (int a[const 2]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "ISO C89" "\[quals expr\] not in C89" { target *-*-* } 21 } */ +void bar2 (int a[static 2]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "ISO C89" "\[static expr\] not in C89" { target *-*-* } 23 } */ +void bar3 (int a[static const 2]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "ISO C89" "\[static quals expr\] not in C89" { target *-*-* } 25 } */ +void bar4 (int a[const static 2]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "ISO C89" "\[quals static expr\] not in C89" { target *-*-* } 27 } */ + +/* Because [*] isn't properly implemented and so warns, we don't test here + for [const *] yet. */ diff --git a/gcc/testsuite/gcc.dg/c99-arraydecl-1.c b/gcc/testsuite/gcc.dg/c99-arraydecl-1.c new file mode 100644 index 0000000..24ddd65 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c99-arraydecl-1.c @@ -0,0 +1,111 @@ +/* Test for C99 forms of array declarator. */ +/* Origin: Joseph Myers <jsm28@cam.ac.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +/* Because GCC doesn't yet implement it, we don't yet test for [*] here. */ + +/* Test each of: [quals], [quals expr], [static expr], [static quals expr], + [quals static expr]. Not yet: [quals *]. */ + +void f00 (int a[const]); +void f01 (int [const]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "abstract" "\[quals\] in abstract declarator" { target *-*-* } 12 } */ +void +f02 (int a[const]) +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } 17 } */ + int *const *c = &a; +} +void +f03 (a) + int a[const]; +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } 25 } */ + int *const *c = &a; +} + +void f10 (int a[const 2]); +void f11 (int [const 2]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "abstract" "\[quals expr\] in abstract declarator" { target *-*-* } 31 } */ +void +f12 (int a[const 2]) +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } 36 } */ + int *const *c = &a; +} +void +f13 (a) + int a[const 2]; +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } 44 } */ + int *const *c = &a; +} + +void f20 (int a[static 2]); +void f21 (int [static 2]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "abstract" "\[static expr\] in abstract declarator" { target *-*-* } 50 } */ +void +f22 (int a[static 2]) +{ + int **b = &a; + int *const *c = &a; +} +void +f23 (a) + int a[static 2]; +{ + int **b = &a; + int *const *c = &a; +} + +void f30 (int a[static const 2]); +void f31 (int [static const 2]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "abstract" "\[static quals expr\] in abstract declarator" { target *-*-* } 67 } */ +void +f32 (int a[static const 2]) +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } 72 } */ + int *const *c = &a; +} +void +f33 (a) + int a[static const 2]; +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } 80 } */ + int *const *c = &a; +} + +void f40 (int a[const static 2]); +void f41 (int [const static 2]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "abstract" "\[quals static expr\] in abstract declarator" { target *-*-* } 86 } */ +void +f42 (int a[const static 2]) +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } 91 } */ + int *const *c = &a; +} +void +f43 (a) + int a[const static 2]; +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } 99 } */ + int *const *c = &a; +} + +/* Test rejection of static and type qualifiers in non-parameter contexts. */ +int x[const 2]; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "non-parameter" "quals in non-parm array" { target *-*-* } 105 } */ +int y[static 2]; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "non-parameter" "static in non-parm array" { target *-*-* } 107 } */ +void g (int a[static 2][3]); +void h (int a[2][static 3]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "non-parameter" "static in non-final parm array" { target *-*-* } 110 } */ |