From a11ed85ba193b8200c95d0844c6c38d0b591ec43 Mon Sep 17 00:00:00 2001 From: jsm28 Date: Sat, 6 Nov 2004 20:01:42 +0000 Subject: [PATCH] * gcc.dg/anon-struct-6.c, gcc.dg/anon-struct-7.c, gcc.dg/anon-struct-8.c, gcc.dg/bitfld-10.c, gcc.dg/bitfld-11.c, gcc.dg/bitfld-12.c, gcc.dg/func-outside-1.c, gcc.dg/func-outside-2.c, gcc.dg/label-decl-1.c, gcc.dg/label-decl-2.c, gcc.dg/label-decl-3.c, gcc.dg/label-decl-4.c, gcc.dg/struct-empty-1.c, gcc.dg/struct-empty-2.c, gcc.dg/struct-empty-3.c, gcc.dg/struct-semi-1.c, gcc.dg/struct-semi-2.c, gcc.dg/struct-semi-3.c: New tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@90193 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 12 ++++++++++++ gcc/testsuite/gcc.dg/anon-struct-6.c | 12 ++++++++++++ gcc/testsuite/gcc.dg/anon-struct-7.c | 10 ++++++++++ gcc/testsuite/gcc.dg/anon-struct-8.c | 10 ++++++++++ gcc/testsuite/gcc.dg/bitfld-10.c | 8 ++++++++ gcc/testsuite/gcc.dg/bitfld-11.c | 8 ++++++++ gcc/testsuite/gcc.dg/bitfld-12.c | 12 ++++++++++++ gcc/testsuite/gcc.dg/func-outside-1.c | 9 +++++++++ gcc/testsuite/gcc.dg/func-outside-2.c | 9 +++++++++ gcc/testsuite/gcc.dg/label-decl-1.c | 17 +++++++++++++++++ gcc/testsuite/gcc.dg/label-decl-2.c | 17 +++++++++++++++++ gcc/testsuite/gcc.dg/label-decl-3.c | 18 ++++++++++++++++++ gcc/testsuite/gcc.dg/label-decl-4.c | 14 ++++++++++++++ gcc/testsuite/gcc.dg/struct-empty-1.c | 10 ++++++++++ gcc/testsuite/gcc.dg/struct-empty-2.c | 10 ++++++++++ gcc/testsuite/gcc.dg/struct-empty-3.c | 10 ++++++++++ gcc/testsuite/gcc.dg/struct-semi-1.c | 19 +++++++++++++++++++ gcc/testsuite/gcc.dg/struct-semi-2.c | 20 ++++++++++++++++++++ gcc/testsuite/gcc.dg/struct-semi-3.c | 20 ++++++++++++++++++++ 19 files changed, 245 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/anon-struct-6.c create mode 100644 gcc/testsuite/gcc.dg/anon-struct-7.c create mode 100644 gcc/testsuite/gcc.dg/anon-struct-8.c create mode 100644 gcc/testsuite/gcc.dg/bitfld-10.c create mode 100644 gcc/testsuite/gcc.dg/bitfld-11.c create mode 100644 gcc/testsuite/gcc.dg/bitfld-12.c create mode 100644 gcc/testsuite/gcc.dg/func-outside-1.c create mode 100644 gcc/testsuite/gcc.dg/func-outside-2.c create mode 100644 gcc/testsuite/gcc.dg/label-decl-1.c create mode 100644 gcc/testsuite/gcc.dg/label-decl-2.c create mode 100644 gcc/testsuite/gcc.dg/label-decl-3.c create mode 100644 gcc/testsuite/gcc.dg/label-decl-4.c create mode 100644 gcc/testsuite/gcc.dg/struct-empty-1.c create mode 100644 gcc/testsuite/gcc.dg/struct-empty-2.c create mode 100644 gcc/testsuite/gcc.dg/struct-empty-3.c create mode 100644 gcc/testsuite/gcc.dg/struct-semi-1.c create mode 100644 gcc/testsuite/gcc.dg/struct-semi-2.c create mode 100644 gcc/testsuite/gcc.dg/struct-semi-3.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c9df8f16964..ceef2fcfc7f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2004-11-06 Joseph S. Myers + + * gcc.dg/anon-struct-6.c, gcc.dg/anon-struct-7.c, + gcc.dg/anon-struct-8.c, gcc.dg/bitfld-10.c, gcc.dg/bitfld-11.c, + gcc.dg/bitfld-12.c, gcc.dg/func-outside-1.c, + gcc.dg/func-outside-2.c, gcc.dg/label-decl-1.c, + gcc.dg/label-decl-2.c, gcc.dg/label-decl-3.c, + gcc.dg/label-decl-4.c, gcc.dg/struct-empty-1.c, + gcc.dg/struct-empty-2.c, gcc.dg/struct-empty-3.c, + gcc.dg/struct-semi-1.c, gcc.dg/struct-semi-2.c, + gcc.dg/struct-semi-3.c: New tests. + 2004-11-06 Eric Botcazou * g++.dg/opt/nothrow1.C: Use -42 instead of 42. diff --git a/gcc/testsuite/gcc.dg/anon-struct-6.c b/gcc/testsuite/gcc.dg/anon-struct-6.c new file mode 100644 index 00000000000..a2042176c03 --- /dev/null +++ b/gcc/testsuite/gcc.dg/anon-struct-6.c @@ -0,0 +1,12 @@ +/* Test diagnostics for structure member with no type specifier or + declarator. Test with no special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s { + int a; + const; +}; +/* { dg-warning "warning: useless type qualifier in empty declaration" "empty" { target *-*-* } 9 } */ +/* { dg-warning "warning: empty declaration" "empty" { target *-*-* } 9 } */ diff --git a/gcc/testsuite/gcc.dg/anon-struct-7.c b/gcc/testsuite/gcc.dg/anon-struct-7.c new file mode 100644 index 00000000000..18790790f31 --- /dev/null +++ b/gcc/testsuite/gcc.dg/anon-struct-7.c @@ -0,0 +1,10 @@ +/* Test diagnostics for structure member with no type specifier or + declarator. Test with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +struct s { + int a; + const; /* { dg-warning "warning: ISO C forbids member declarations with no members" } */ +}; diff --git a/gcc/testsuite/gcc.dg/anon-struct-8.c b/gcc/testsuite/gcc.dg/anon-struct-8.c new file mode 100644 index 00000000000..c4beb80c7cc --- /dev/null +++ b/gcc/testsuite/gcc.dg/anon-struct-8.c @@ -0,0 +1,10 @@ +/* Test diagnostics for structure member with no type specifier or + declarator. Test with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +struct s { + int a; + const; /* { dg-error "error: ISO C forbids member declarations with no members" } */ +}; diff --git a/gcc/testsuite/gcc.dg/bitfld-10.c b/gcc/testsuite/gcc.dg/bitfld-10.c new file mode 100644 index 00000000000..156929f49fd --- /dev/null +++ b/gcc/testsuite/gcc.dg/bitfld-10.c @@ -0,0 +1,8 @@ +/* Test for rejection of sizeof on bit-fields. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct { int a : 1; } x; + +int r = sizeof (x.a); /* { dg-error "error: 'sizeof' applied to a bit-field" } */ diff --git a/gcc/testsuite/gcc.dg/bitfld-11.c b/gcc/testsuite/gcc.dg/bitfld-11.c new file mode 100644 index 00000000000..e6bff6c7436 --- /dev/null +++ b/gcc/testsuite/gcc.dg/bitfld-11.c @@ -0,0 +1,8 @@ +/* Test for rejection of __alignof on bit-fields. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct { int a : 1; } x; + +int r = __alignof (x.a); /* { dg-error "error: '__alignof' applied to a bit-field" } */ diff --git a/gcc/testsuite/gcc.dg/bitfld-12.c b/gcc/testsuite/gcc.dg/bitfld-12.c new file mode 100644 index 00000000000..8b2b659997e --- /dev/null +++ b/gcc/testsuite/gcc.dg/bitfld-12.c @@ -0,0 +1,12 @@ +/* Test for rejection of taking address of bit-fields. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#include + +struct s { int a : 1; } x, *y; + +int a = offsetof (struct s, a); /* { dg-error "error: attempt to take address of bit-field structure member 'a'" } */ +void *b = &x.a; /* { dg-error "error: cannot take address of bit-field 'a'" } */ +void *c = &y->a; /* { dg-error "error: cannot take address of bit-field 'a'" } */ diff --git a/gcc/testsuite/gcc.dg/func-outside-1.c b/gcc/testsuite/gcc.dg/func-outside-1.c new file mode 100644 index 00000000000..fcf233f8a6b --- /dev/null +++ b/gcc/testsuite/gcc.dg/func-outside-1.c @@ -0,0 +1,9 @@ +/* Test for rejection of __func__ outside a function (GNU extensions + are OK there). Test with no special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +const char *a = __func__; /* { dg-warning "warning: '__func__' is not defined outside of function scope" "undef" { target *-*-* } 0 } */ +const char *b = __FUNCTION__; +const char *c = __PRETTY_FUNCTION__; diff --git a/gcc/testsuite/gcc.dg/func-outside-2.c b/gcc/testsuite/gcc.dg/func-outside-2.c new file mode 100644 index 00000000000..4e0ff19e7c4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/func-outside-2.c @@ -0,0 +1,9 @@ +/* Test for rejection of __func__ outside a function (GNU extensions + are OK there). Test with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +const char *a = __func__; /* { dg-error "error: '__func__' is not defined outside of function scope" "undef" { target *-*-* } 0 } */ +const char *b = __FUNCTION__; +const char *c = __PRETTY_FUNCTION__; diff --git a/gcc/testsuite/gcc.dg/label-decl-1.c b/gcc/testsuite/gcc.dg/label-decl-1.c new file mode 100644 index 00000000000..531f81e4177 --- /dev/null +++ b/gcc/testsuite/gcc.dg/label-decl-1.c @@ -0,0 +1,17 @@ +/* Test diagnostics for label declarations. Test with no special + options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef int b; + +void +f (void) +{ + __label__ a, b, c, d; + __extension__ (void)&&d; /* { dg-error "error: label 'd' used but not defined" } */ + goto c; /* { dg-error "error: label 'c' used but not defined" } */ + a: (void)0; + b: (void)0; +} diff --git a/gcc/testsuite/gcc.dg/label-decl-2.c b/gcc/testsuite/gcc.dg/label-decl-2.c new file mode 100644 index 00000000000..5ec124b52bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/label-decl-2.c @@ -0,0 +1,17 @@ +/* Test diagnostics for label declarations. Test with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +typedef int b; + +void +f (void) +{ + __label__ a, b, c, d; + __extension__ (void)&&d; /* { dg-error "error: label 'd' used but not defined" } */ + /* { dg-warning "warning: ISO C forbids label declarations" "label decls" { target *-*-* } 12 } */ + goto c; /* { dg-error "error: label 'c' used but not defined" } */ + a: (void)0; + b: (void)0; +} diff --git a/gcc/testsuite/gcc.dg/label-decl-3.c b/gcc/testsuite/gcc.dg/label-decl-3.c new file mode 100644 index 00000000000..d49531c5dc8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/label-decl-3.c @@ -0,0 +1,18 @@ +/* Test diagnostics for label declarations. Test with + -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +typedef int b; + +void +f (void) +{ + __label__ a, b, c, d; + __extension__ (void)&&d; /* { dg-error "error: label 'd' used but not defined" } */ + /* { dg-error "error: ISO C forbids label declarations" "label decls" { target *-*-* } 13 } */ + goto c; /* { dg-error "error: label 'c' used but not defined" } */ + a: (void)0; + b: (void)0; +} diff --git a/gcc/testsuite/gcc.dg/label-decl-4.c b/gcc/testsuite/gcc.dg/label-decl-4.c new file mode 100644 index 00000000000..d804f8f0fdc --- /dev/null +++ b/gcc/testsuite/gcc.dg/label-decl-4.c @@ -0,0 +1,14 @@ +/* Test diagnostics for duplicate label declarations. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +f (void) +{ + __label__ a, b, a; /* { dg-error "error: duplicate label declaration 'a'" } */ + /* { dg-error "error: previous declaration of 'a' was here" "previous" { target *-*-* } 9 } */ + __label__ c; /* { dg-error "error: previous declaration of 'c' was here" } */ + __label__ c; /* { dg-error "error: duplicate label declaration 'c'" } */ + return; +} diff --git a/gcc/testsuite/gcc.dg/struct-empty-1.c b/gcc/testsuite/gcc.dg/struct-empty-1.c new file mode 100644 index 00000000000..77974656734 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct-empty-1.c @@ -0,0 +1,10 @@ +/* Test diagnostics for empty structures and unions. Test with no + special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s0 {}; +union u0 {}; +struct s1 { int : 1; }; +union u1 { int : 1; }; diff --git a/gcc/testsuite/gcc.dg/struct-empty-2.c b/gcc/testsuite/gcc.dg/struct-empty-2.c new file mode 100644 index 00000000000..132ef45705c --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct-empty-2.c @@ -0,0 +1,10 @@ +/* Test diagnostics for empty structures and unions. Test with + -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +struct s0 {}; /* { dg-warning "warning: struct has no members" } */ +union u0 {}; /* { dg-warning "warning: union has no members" } */ +struct s1 { int : 1; }; /* { dg-warning "warning: struct has no named members" } */ +union u1 { int : 1; }; /* { dg-warning "warning: union has no named members" } */ diff --git a/gcc/testsuite/gcc.dg/struct-empty-3.c b/gcc/testsuite/gcc.dg/struct-empty-3.c new file mode 100644 index 00000000000..b9285c0a262 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct-empty-3.c @@ -0,0 +1,10 @@ +/* Test diagnostics for empty structures and unions. Test with + -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +struct s0 {}; /* { dg-error "error: struct has no members" } */ +union u0 {}; /* { dg-error "error: union has no members" } */ +struct s1 { int : 1; }; /* { dg-error "error: struct has no named members" } */ +union u1 { int : 1; }; /* { dg-error "error: union has no named members" } */ diff --git a/gcc/testsuite/gcc.dg/struct-semi-1.c b/gcc/testsuite/gcc.dg/struct-semi-1.c new file mode 100644 index 00000000000..091956b4c5f --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct-semi-1.c @@ -0,0 +1,19 @@ +/* Test diagnostics for missing and extra semicolons in structures. + Test with no special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s0 { ; }; +struct s1 { + int a; + ; + int b; +}; +struct s2 { + ; + int c +}; /* { dg-warning "warning: no semicolon at end of struct or union" } */ +struct s3 { + int d +}; /* { dg-warning "warning: no semicolon at end of struct or union" } */ diff --git a/gcc/testsuite/gcc.dg/struct-semi-2.c b/gcc/testsuite/gcc.dg/struct-semi-2.c new file mode 100644 index 00000000000..e609fd25aa6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct-semi-2.c @@ -0,0 +1,20 @@ +/* Test diagnostics for missing and extra semicolons in structures. + Test with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +struct s0 { ; }; /* { dg-warning "warning: extra semicolon in struct or union specified" } */ +/* { dg-warning "warning: struct has no members" "empty" { target *-*-* } 7 } */ +struct s1 { + int a; + ; /* { dg-warning "warning: extra semicolon in struct or union specified" } */ + int b; +}; +struct s2 { + ; /* { dg-warning "warning: extra semicolon in struct or union specified" } */ + int c +}; /* { dg-warning "warning: no semicolon at end of struct or union" } */ +struct s3 { + int d +}; /* { dg-warning "warning: no semicolon at end of struct or union" } */ diff --git a/gcc/testsuite/gcc.dg/struct-semi-3.c b/gcc/testsuite/gcc.dg/struct-semi-3.c new file mode 100644 index 00000000000..25a33c78a8d --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct-semi-3.c @@ -0,0 +1,20 @@ +/* Test diagnostics for missing and extra semicolons in structures. + Test with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +struct s0 { ; }; /* { dg-error "error: extra semicolon in struct or union specified" } */ +/* { dg-error "error: struct has no members" "empty" { target *-*-* } 7 } */ +struct s1 { + int a; + ; /* { dg-error "error: extra semicolon in struct or union specified" } */ + int b; +}; +struct s2 { + ; /* { dg-error "error: extra semicolon in struct or union specified" } */ + int c +}; /* { dg-error "error: no semicolon at end of struct or union" } */ +struct s3 { + int d +}; /* { dg-error "error: no semicolon at end of struct or union" } */ -- 2.11.4.GIT