OSDN Git Service

* gcc.dg/anon-struct-6.c, gcc.dg/anon-struct-7.c,
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 6 Nov 2004 20:01:42 +0000 (20:01 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 6 Nov 2004 20:01:42 +0000 (20:01 +0000)
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

19 files changed:
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/anon-struct-6.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/anon-struct-7.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/anon-struct-8.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/bitfld-10.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/bitfld-11.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/bitfld-12.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/func-outside-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/func-outside-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/label-decl-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/label-decl-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/label-decl-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/label-decl-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/struct-empty-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/struct-empty-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/struct-empty-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/struct-semi-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/struct-semi-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/struct-semi-3.c [new file with mode: 0644]

index c9df8f1..ceef2fc 100644 (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.
diff --git a/gcc/testsuite/gcc.dg/anon-struct-6.c b/gcc/testsuite/gcc.dg/anon-struct-6.c
new file mode 100644 (file)
index 0000000..a204217
--- /dev/null
@@ -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 (file)
index 0000000..1879079
--- /dev/null
@@ -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 (file)
index 0000000..c4beb80
--- /dev/null
@@ -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 (file)
index 0000000..156929f
--- /dev/null
@@ -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 (file)
index 0000000..e6bff6c
--- /dev/null
@@ -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 (file)
index 0000000..8b2b659
--- /dev/null
@@ -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 (file)
index 0000000..fcf233f
--- /dev/null
@@ -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 (file)
index 0000000..4e0ff19
--- /dev/null
@@ -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 (file)
index 0000000..531f81e
--- /dev/null
@@ -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 (file)
index 0000000..5ec124b
--- /dev/null
@@ -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 (file)
index 0000000..d49531c
--- /dev/null
@@ -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 (file)
index 0000000..d804f8f
--- /dev/null
@@ -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 (file)
index 0000000..7797465
--- /dev/null
@@ -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 (file)
index 0000000..132ef45
--- /dev/null
@@ -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 (file)
index 0000000..b9285c0
--- /dev/null
@@ -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 (file)
index 0000000..091956b
--- /dev/null
@@ -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 (file)
index 0000000..e609fd2
--- /dev/null
@@ -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 (file)
index 0000000..25a33c7
--- /dev/null
@@ -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" } */