diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c9df8f169649240e79bfbf46fdb1eaefd3d95389..ceef2fcfc7f3a75b672640710f6af43ebe778e41 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2004-11-06 Joseph S. Myers <joseph@codesourcery.com> + + * 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 <ebotcazou@libertysurf.fr> * 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 0000000000000000000000000000000000000000..a2042176c037797f8059ef5b0a3c63a2f61434f5 --- /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 <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..18790790f314114b1fa683ecddf63fd0f1f147df --- /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 <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..c4beb80c7ccbbc802e508d59717c6543aaa99ba4 --- /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 <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..156929f49fd7a132d2d06839f8a8e8ce10f0bdc6 --- /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 <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..e6bff6c74367631f4d77dcf2fe8b5c411288fb22 --- /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 <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..8b2b659997efacca6c16e7b9e7413ae4571ba42e --- /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 <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#include <stddef.h> + +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 0000000000000000000000000000000000000000..fcf233f8a6b3b400a9347e7d61a530f3cfc7bf5b --- /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 <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..4e0ff19e7c44617950f6fef48b734d822c5057d9 --- /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 <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..531f81e4177760ab0fd74c1f0aa2d56989f19473 --- /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 <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..5ec124b52bb8e479e354e4ee8439d6833e8af8d2 --- /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 <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..d49531c5dc8426866ece60adc444b95aae59725c --- /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 <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..d804f8f0fdc66dccb76a7d2bcd359f3354756be8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/label-decl-4.c @@ -0,0 +1,14 @@ +/* Test diagnostics for duplicate label declarations. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..779746567340d2cd7e12a8e89b78d451aece074f --- /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 <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..132ef45705c91ea848cc19b7bf0b01d37bfb29ef --- /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 <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..b9285c0a262a0705817aa562894442d05092a2c6 --- /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 <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..091956b4c5fe2f1ec040565e2f93bd94a0415231 --- /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 <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..e609fd25aa6ea34f0afb35d1b34b4427d1837640 --- /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 <joseph@codesourcery.com> */ +/* { 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 0000000000000000000000000000000000000000..25a33c78a8d60c71db35f32aa1259fbc4d7d6d57 --- /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 <joseph@codesourcery.com> */ +/* { 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" } */