anon-struct-6.c, [...]: New tests.

* 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.

From-SVN: r90193
This commit is contained in:
Joseph Myers 2004-11-06 20:01:42 +00:00 committed by Joseph Myers
parent d43844e2d6
commit fccf8fc6d1
19 changed files with 245 additions and 0 deletions

View file

@ -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.

View file

@ -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 } */

View file

@ -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" } */
};

View file

@ -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" } */
};

View file

@ -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" } */

View file

@ -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" } */

View file

@ -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'" } */

View file

@ -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__;

View file

@ -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__;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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; };

View file

@ -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" } */

View file

@ -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" } */

View file

@ -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" } */

View file

@ -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" } */

View file

@ -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" } */