diff options
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/991209-1.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/declspec-10.c | 45 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/declspec-11.c | 45 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/declspec-4.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/declspec-5.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/declspec-6.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/declspec-7.c | 39 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/declspec-8.c | 32 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/declspec-9.c | 43 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr14289-2.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr14289-3.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tls/diag-2.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tls/diag-4.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tls/diag-5.c | 3 |
15 files changed, 238 insertions, 33 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f7d6b82f011..e48d3015326 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2004-09-11 Joseph S. Myers <jsm@polyomino.org.uk> + + * gcc.dg/declspec-4.c, gcc.dg/declspec-5.c, gcc.dg/declspec-6.c, + gcc.dg/tls/diag-2.c: Update expected messages. + * gcc.dg/991209-1.c: Specify compilation options. Update expected + messages. + * gcc.dg/pr14289-2.c, gcc.dg/pr14289-3.c: Remove. + * gcc.dg/declspec-7.c, gcc.dg/declspec-8.c, gcc.dg/declspec-9.c, + gcc.dg/declspec-10.c, gcc.dg/declspec-11.c, gcc.dg/tls/diag-4.c, + gcc.dg/tls/diag-5.c: New tests. + 2004-09-11 Zack Weinberg <zack@codesourcery.com> * gcc.dg/20040910-1.c: Correct dg-error regexp. diff --git a/gcc/testsuite/gcc.dg/991209-1.c b/gcc/testsuite/gcc.dg/991209-1.c index b3a47285158..2381922c660 100644 --- a/gcc/testsuite/gcc.dg/991209-1.c +++ b/gcc/testsuite/gcc.dg/991209-1.c @@ -1,8 +1,9 @@ /* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-ansi -pedantic" } */ int foo () { return 1; } -register char *stack_ptr __asm ("%esp"); +register char *stack_ptr __asm ("%esp"); /* { dg-warning "warning: file-scope declaration of 'stack_ptr' specifies 'register'" } */ diff --git a/gcc/testsuite/gcc.dg/declspec-10.c b/gcc/testsuite/gcc.dg/declspec-10.c new file mode 100644 index 00000000000..454cb1d5480 --- /dev/null +++ b/gcc/testsuite/gcc.dg/declspec-10.c @@ -0,0 +1,45 @@ +/* Test declaration specifiers. Test various checks on storage class + and function specifiers that depend on information about the + declaration, not just the specifiers. Test with -pedantic. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +auto void f0 (void) {} /* { dg-warning "warning: function definition declared 'auto'" } */ +register void f1 (void) {} /* { dg-error "error: function definition declared 'register'" } */ +typedef void f2 (void) {} /* { dg-error "error: function definition declared 'typedef'" } */ + +void f3 (auto int); /* { dg-error "error: storage class specified for parameter 'type name'" } */ +void f4 (extern int); /* { dg-error "error: storage class specified for parameter 'type name'" } */ +void f5 (register int); +void f6 (static int); /* { dg-error "error: storage class specified for parameter 'type name'" } */ +void f7 (typedef int); /* { dg-error "error: storage class specified for parameter 'type name'" } */ + +auto int x; /* { dg-error "error: file-scope declaration of `x' specifies `auto'" } */ +register int y; /* { dg-warning "warning: file-scope declaration of 'y' specifies 'register'" } */ + +void h (void) { extern void x (void) {} } /* { dg-error "error: nested function `x' declared `extern'" } */ +/* { dg-warning "warning: ISO C forbids nested functions" "nested" { target *-*-* } 21 } */ + +void +g (void) +{ + void a; /* { dg-error "error: variable or field `a' declared void" } */ + const void b; /* { dg-error "error: variable or field `b' declared void" } */ + static void c; /* { dg-error "error: variable or field `c' declared void" } */ +} + +void p; +const void p1; +extern void q; +extern const void q1; +static void r; /* { dg-error "error: variable or field `r' declared void" } */ +static const void r1; /* { dg-error "error: variable or field `r1' declared void" } */ + +register void f8 (void); /* { dg-error "error: invalid storage class for function `f8'" } */ +/* { dg-warning "warning: file-scope declaration of 'f8' specifies 'register'" "register function" { target *-*-* } 39 } */ + +void i (void) { auto void y (void) {} } /* { dg-warning "warning: ISO C forbids nested functions" } */ +/* { dg-warning "warning: function definition declared 'auto'" "nested" { target *-*-* } 42 } */ + +inline int main (void) { return 0; } /* { dg-warning "warning: cannot inline function `main'" } */ diff --git a/gcc/testsuite/gcc.dg/declspec-11.c b/gcc/testsuite/gcc.dg/declspec-11.c new file mode 100644 index 00000000000..c418de135d6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/declspec-11.c @@ -0,0 +1,45 @@ +/* Test declaration specifiers. Test various checks on storage class + and function specifiers that depend on information about the + declaration, not just the specifiers. Test with -pedantic-errors. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +auto void f0 (void) {} /* { dg-error "error: function definition declared 'auto'" } */ +register void f1 (void) {} /* { dg-error "error: function definition declared 'register'" } */ +typedef void f2 (void) {} /* { dg-error "error: function definition declared 'typedef'" } */ + +void f3 (auto int); /* { dg-error "error: storage class specified for parameter 'type name'" } */ +void f4 (extern int); /* { dg-error "error: storage class specified for parameter 'type name'" } */ +void f5 (register int); +void f6 (static int); /* { dg-error "error: storage class specified for parameter 'type name'" } */ +void f7 (typedef int); /* { dg-error "error: storage class specified for parameter 'type name'" } */ + +auto int x; /* { dg-error "error: file-scope declaration of `x' specifies `auto'" } */ +register int y; /* { dg-error "error: file-scope declaration of 'y' specifies 'register'" } */ + +void h (void) { extern void x (void) {} } /* { dg-error "error: nested function `x' declared `extern'" } */ +/* { dg-error "error: ISO C forbids nested functions" "nested" { target *-*-* } 21 } */ + +void +g (void) +{ + void a; /* { dg-error "error: variable or field `a' declared void" } */ + const void b; /* { dg-error "error: variable or field `b' declared void" } */ + static void c; /* { dg-error "error: variable or field `c' declared void" } */ +} + +void p; +const void p1; +extern void q; +extern const void q1; +static void r; /* { dg-error "error: variable or field `r' declared void" } */ +static const void r1; /* { dg-error "error: variable or field `r1' declared void" } */ + +register void f8 (void); /* { dg-error "error: invalid storage class for function `f8'" } */ +/* { dg-error "error: file-scope declaration of 'f8' specifies 'register'" "register function" { target *-*-* } 39 } */ + +void i (void) { auto void y (void) {} } /* { dg-error "error: ISO C forbids nested functions" } */ +/* { dg-error "error: function definition declared 'auto'" "nested" { target *-*-* } 42 } */ + +inline int main (void) { return 0; } /* { dg-warning "warning: cannot inline function `main'" } */ diff --git a/gcc/testsuite/gcc.dg/declspec-4.c b/gcc/testsuite/gcc.dg/declspec-4.c index 0610e059413..fbc6c3667ca 100644 --- a/gcc/testsuite/gcc.dg/declspec-4.c +++ b/gcc/testsuite/gcc.dg/declspec-4.c @@ -22,7 +22,7 @@ int; /* { dg-warning "warning: useless type name in empty declaration" } */ long; /* { dg-warning "warning: useless keyword or type name in empty declaration" } */ /* { dg-warning "warning: empty declaration" "long" { target *-*-* } 22 } */ T; /* { dg-warning "warning: useless type name in empty declaration" } */ -static const; /* { dg-warning "warning: useless keyword or type name in empty declaration" } */ +static const; /* { dg-warning "warning: useless storage class specifier in empty declaration" } */ /* { dg-warning "warning: empty declaration" "long" { target *-*-* } 25 } */ union { long b; }; /* { dg-warning "warning: unnamed struct/union that defines no instances" } */ diff --git a/gcc/testsuite/gcc.dg/declspec-5.c b/gcc/testsuite/gcc.dg/declspec-5.c index aba27397023..febbfb32edc 100644 --- a/gcc/testsuite/gcc.dg/declspec-5.c +++ b/gcc/testsuite/gcc.dg/declspec-5.c @@ -22,7 +22,7 @@ int; /* { dg-warning "warning: useless type name in empty declaration" } */ long; /* { dg-warning "warning: useless keyword or type name in empty declaration" } */ /* { dg-warning "warning: empty declaration" "long" { target *-*-* } 22 } */ T; /* { dg-warning "warning: useless type name in empty declaration" } */ -static const; /* { dg-warning "warning: useless keyword or type name in empty declaration" } */ +static const; /* { dg-warning "warning: useless storage class specifier in empty declaration" } */ /* { dg-warning "warning: empty declaration" "long" { target *-*-* } 25 } */ union { long b; }; /* { dg-warning "warning: unnamed struct/union that defines no instances" } */ diff --git a/gcc/testsuite/gcc.dg/declspec-6.c b/gcc/testsuite/gcc.dg/declspec-6.c index 91a5d82b842..305eed78bd9 100644 --- a/gcc/testsuite/gcc.dg/declspec-6.c +++ b/gcc/testsuite/gcc.dg/declspec-6.c @@ -22,7 +22,7 @@ int; /* { dg-error "error: useless type name in empty declaration" } */ long; /* { dg-warning "warning: useless keyword or type name in empty declaration" } */ /* { dg-error "error: empty declaration" "long" { target *-*-* } 22 } */ T; /* { dg-error "error: useless type name in empty declaration" } */ -static const; /* { dg-warning "warning: useless keyword or type name in empty declaration" } */ +static const; /* { dg-warning "warning: useless storage class specifier in empty declaration" } */ /* { dg-error "error: empty declaration" "long" { target *-*-* } 25 } */ union { long b; }; /* { dg-error "error: unnamed struct/union that defines no instances" } */ diff --git a/gcc/testsuite/gcc.dg/declspec-7.c b/gcc/testsuite/gcc.dg/declspec-7.c new file mode 100644 index 00000000000..bb63d952d88 --- /dev/null +++ b/gcc/testsuite/gcc.dg/declspec-7.c @@ -0,0 +1,39 @@ +/* Test declaration specifiers. Test checks on storage class + specifiers that can be made at parse time rather than for each + declarator. Note that __thread is tested in + gcc.dg/tls/diag-*.c. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* Duplicate specifiers. */ + +inline inline void f0 (void), /* { dg-error "error: duplicate 'inline'" } */ + f1 (void); + +static static int a, /* { dg-error "error: duplicate 'static'" } */ + b; + +extern extern int c, /* { dg-error "error: duplicate 'extern'" } */ + d; + +typedef typedef int e, /* { dg-error "error: duplicate 'typedef'" } */ + f; + +void +h (void) +{ + auto auto int p, /* { dg-error "error: duplicate 'auto'" } */ + q; + + register register int r, /* { dg-error "error: duplicate 'register'" } */ + s; +} + +/* Multiple specifiers. */ + +static extern int x, /* { dg-error "error: multiple storage classes in declaration specifiers" } */ + y; + +extern typedef long z, /* { dg-error "error: multiple storage classes in declaration specifiers" } */ + w; diff --git a/gcc/testsuite/gcc.dg/declspec-8.c b/gcc/testsuite/gcc.dg/declspec-8.c new file mode 100644 index 00000000000..ea60126fe44 --- /dev/null +++ b/gcc/testsuite/gcc.dg/declspec-8.c @@ -0,0 +1,32 @@ +/* Test declaration specifiers. Test checks on storage class + specifiers and function specifiers in empty declarations. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* The constraints on storage class specifiers and function specifiers + must be met for empty declarations where they are useless. Thus + there may be only one storage class specifier (C90 6.5.1, C99 + 6.7.1#2) and "inline" must not be used because the declaration is + not that of an identifier for a function (C99 6.7.4#1), and + "register" and "auto" must not be used at file scope (C90 6.7, C99 + 6.9#2). */ + +static static struct s; /* { dg-error "error: duplicate 'static'" } */ +/* { dg-warning "warning: useless storage class specifier in empty declaration" "static static" { target *-*-* } 15 } */ + +static extern struct t; /* { dg-error "error: multiple storage classes in declaration specifiers" } */ +/* { dg-warning "warning: useless storage class specifier in empty declaration" "static extern" { target *-*-* } 18 } */ + +inline union u; /* { dg-error "error: 'inline' in empty declaration" } */ + +auto struct v; /* { dg-error "error: 'auto' in file-scope empty declaration" } */ + +register struct w; /* { dg-error "error: 'register' in file-scope empty declaration" } */ + +void +f (void) +{ + auto union p; /* { dg-warning "warning: useless storage class specifier in empty declaration" } */ + register struct q; /* { dg-warning "warning: useless storage class specifier in empty declaration" } */ +} diff --git a/gcc/testsuite/gcc.dg/declspec-9.c b/gcc/testsuite/gcc.dg/declspec-9.c new file mode 100644 index 00000000000..855393c943d --- /dev/null +++ b/gcc/testsuite/gcc.dg/declspec-9.c @@ -0,0 +1,43 @@ +/* Test declaration specifiers. Test various checks on storage class + and function specifiers that depend on information about the + declaration, not just the specifiers. Test with no special + options. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +auto void f0 (void) {} /* { dg-warning "warning: function definition declared 'auto'" } */ +register void f1 (void) {} /* { dg-error "error: function definition declared 'register'" } */ +typedef void f2 (void) {} /* { dg-error "error: function definition declared 'typedef'" } */ + +void f3 (auto int); /* { dg-error "error: storage class specified for parameter 'type name'" } */ +void f4 (extern int); /* { dg-error "error: storage class specified for parameter 'type name'" } */ +void f5 (register int); +void f6 (static int); /* { dg-error "error: storage class specified for parameter 'type name'" } */ +void f7 (typedef int); /* { dg-error "error: storage class specified for parameter 'type name'" } */ + +auto int x; /* { dg-error "error: file-scope declaration of `x' specifies `auto'" } */ +register int y; + +void h (void) { extern void x (void) {} } /* { dg-error "error: nested function `x' declared `extern'" } */ + +void +g (void) +{ + void a; /* { dg-error "error: variable or field `a' declared void" } */ + const void b; /* { dg-error "error: variable or field `b' declared void" } */ + static void c; /* { dg-error "error: variable or field `c' declared void" } */ +} + +void p; +const void p1; +extern void q; +extern const void q1; +static void r; /* { dg-error "error: variable or field `r' declared void" } */ +static const void r1; /* { dg-error "error: variable or field `r1' declared void" } */ + +register void f8 (void); /* { dg-error "error: invalid storage class for function `f8'" } */ + +void i (void) { auto void y (void) {} } + +inline int main (void) { return 0; } /* { dg-warning "warning: cannot inline function `main'" } */ diff --git a/gcc/testsuite/gcc.dg/pr14289-2.c b/gcc/testsuite/gcc.dg/pr14289-2.c deleted file mode 100644 index 7530b468cac..00000000000 --- a/gcc/testsuite/gcc.dg/pr14289-2.c +++ /dev/null @@ -1,12 +0,0 @@ -/* PR middle-end/14289 */ -/* { dg-do compile { target i?86-*-* } } */ -/* { dg-options "-O0" } */ - -static register int a[2] asm("ebx"); /* { dg-error "multiple storage" } */ - -void Nase(void) -{ - int i=6; - a[i]=5; /* { dg-error "address of global" } */ -} - diff --git a/gcc/testsuite/gcc.dg/pr14289-3.c b/gcc/testsuite/gcc.dg/pr14289-3.c deleted file mode 100644 index 7cfbf78ce05..00000000000 --- a/gcc/testsuite/gcc.dg/pr14289-3.c +++ /dev/null @@ -1,12 +0,0 @@ -/* PR middle-end/14289 */ -/* { dg-do compile { target i?86-*-* } } */ -/* { dg-options "-O0" } */ - -extern register int a[2] asm("ebx"); /* { dg-error "multiple storage" } */ - -void Nase(void) -{ - int i=6; - a[i]=5; /* { dg-error "address of global" } */ -} - diff --git a/gcc/testsuite/gcc.dg/tls/diag-2.c b/gcc/testsuite/gcc.dg/tls/diag-2.c index 3c5d9bdd724..5e7e17bee5a 100644 --- a/gcc/testsuite/gcc.dg/tls/diag-2.c +++ b/gcc/testsuite/gcc.dg/tls/diag-2.c @@ -3,19 +3,19 @@ __thread extern int g1; /* { dg-error "'__thread' before 'extern'" } */ __thread static int g2; /* { dg-error "'__thread' before 'static'" } */ __thread __thread int g3; /* { dg-error "duplicate '__thread'" } */ -typedef __thread int g4; /* { dg-error "multiple storage classes" } */ +typedef __thread int g4; /* { dg-error "'__thread' used with 'typedef'" } */ void foo() { - __thread int l1; /* { dg-error "implicitly auto and declared `__thread'" } */ - auto __thread int l2; /* { dg-error "multiple storage classes" } */ + __thread int l1; /* { dg-error "implicitly auto and declared '__thread'" } */ + auto __thread int l2; /* { dg-error "'__thread' used with 'auto'" } */ __thread extern int l3; /* { dg-error "'__thread' before 'extern'" } */ - register __thread int l4; /* { dg-error "multiple storage classes" } */ + register __thread int l4; /* { dg-error "'__thread' used with 'register'" } */ } __thread void f1 (); /* { dg-error "invalid storage class for function" } */ extern __thread void f2 (); /* { dg-error "invalid storage class for function" } */ static __thread void f3 (); /* { dg-error "invalid storage class for function" } */ -__thread void f4 () { } /* { dg-error "function definition declared `__thread'" } */ +__thread void f4 () { } /* { dg-error "function definition declared '__thread'" } */ void bar(__thread int p1); /* { dg-error "storage class specified for parameter" } */ diff --git a/gcc/testsuite/gcc.dg/tls/diag-4.c b/gcc/testsuite/gcc.dg/tls/diag-4.c new file mode 100644 index 00000000000..df3705d04ee --- /dev/null +++ b/gcc/testsuite/gcc.dg/tls/diag-4.c @@ -0,0 +1,10 @@ +/* Invalid __thread specifiers. As diag-4.c but some cases in + different orders. */ + +__thread typedef int g4; /* { dg-error "'__thread' used with 'typedef'" } */ + +void foo() +{ + __thread auto int l2; /* { dg-error "'__thread' used with 'auto'" } */ + __thread register int l4; /* { dg-error "'__thread' used with 'register'" } */ +} diff --git a/gcc/testsuite/gcc.dg/tls/diag-5.c b/gcc/testsuite/gcc.dg/tls/diag-5.c new file mode 100644 index 00000000000..623832c3812 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tls/diag-5.c @@ -0,0 +1,3 @@ +/* __thread specifiers on empty declarations. */ + +__thread struct foo; /* { dg-warning "warning: useless '__thread' in empty declaration" } */ |