summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-11-14 23:24:14 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-11-14 23:24:14 +0000
commitb336acd54731e4258e4848b1e3409493a2ae780b (patch)
treea201846a39be53f6e3ecd20c4823e63363353116 /gcc
parent4aab03406da1df304eabbdc6091720a789297ef8 (diff)
downloadgcc-b336acd54731e4258e4848b1e3409493a2ae780b.tar.gz
* gcc.dg/c99-flex-array-5.c, gcc.dg/c99-fordecl-3.c,
gcc.dg/comp-goto-1.c, gcc.dg/comp-goto-2.c, gcc.dg/comp-goto-3.c, gcc.dg/format/strfmon-2.c, gcc.dg/pointer-arith-1.c, gcc.dg/pointer-arith-2.c, gcc.dg/pointer-arith-3.c, gcc.dg/pointer-arith-4.c, gcc.dg/switch-5.c, gcc.dg/switch-6.c, gcc.dg/switch-7.c: New tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@90637 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/gcc.dg/c99-flex-array-5.c6
-rw-r--r--gcc/testsuite/gcc.dg/c99-fordecl-3.c15
-rw-r--r--gcc/testsuite/gcc.dg/comp-goto-1.c13
-rw-r--r--gcc/testsuite/gcc.dg/comp-goto-2.c13
-rw-r--r--gcc/testsuite/gcc.dg/comp-goto-3.c13
-rw-r--r--gcc/testsuite/gcc.dg/format/strfmon-2.c13
-rw-r--r--gcc/testsuite/gcc.dg/pointer-arith-1.c39
-rw-r--r--gcc/testsuite/gcc.dg/pointer-arith-2.c41
-rw-r--r--gcc/testsuite/gcc.dg/pointer-arith-3.c41
-rw-r--r--gcc/testsuite/gcc.dg/pointer-arith-4.c41
-rw-r--r--gcc/testsuite/gcc.dg/switch-5.c75
-rw-r--r--gcc/testsuite/gcc.dg/switch-6.c14
-rw-r--r--gcc/testsuite/gcc.dg/switch-7.c14
14 files changed, 347 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b01b06a2cf0..c21b4e1ec14 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2004-11-14 Joseph S. Myers <joseph@codesourcery.com>
+
+ * gcc.dg/c99-flex-array-5.c, gcc.dg/c99-fordecl-3.c,
+ gcc.dg/comp-goto-1.c, gcc.dg/comp-goto-2.c, gcc.dg/comp-goto-3.c,
+ gcc.dg/format/strfmon-2.c, gcc.dg/pointer-arith-1.c,
+ gcc.dg/pointer-arith-2.c, gcc.dg/pointer-arith-3.c,
+ gcc.dg/pointer-arith-4.c, gcc.dg/switch-5.c, gcc.dg/switch-6.c,
+ gcc.dg/switch-7.c: New tests.
+
2004-11-14 Dorit Naishlos <dorit@il.ibm.com>
* gcc.dg/vect/vect-78.c: Now vectorized on powerpc*.
diff --git a/gcc/testsuite/gcc.dg/c99-flex-array-5.c b/gcc/testsuite/gcc.dg/c99-flex-array-5.c
new file mode 100644
index 00000000000..11c8d1cf2c1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-flex-array-5.c
@@ -0,0 +1,6 @@
+/* Test for flexible array members: not permitted in unions. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+union u { int a; char b[]; }; /* { dg-error "error: flexible array member in union" } */
diff --git a/gcc/testsuite/gcc.dg/c99-fordecl-3.c b/gcc/testsuite/gcc.dg/c99-fordecl-3.c
new file mode 100644
index 00000000000..c51a5551a99
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-fordecl-3.c
@@ -0,0 +1,15 @@
+/* Test for C99 declarations in for loops. Test constraints: struct
+ and union tags can't be declared there (affirmed in response to
+ DR#277). */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+void
+foo (void)
+{
+ for (struct s { int p; } *p = 0; ;) /* { dg-error "error: 'struct s' declared in 'for' loop initial declaration" } */
+ ;
+ for (union u { int p; } *p = 0; ;) /* { dg-error "error: 'union u' declared in 'for' loop initial declaration" } */
+ ;
+}
diff --git a/gcc/testsuite/gcc.dg/comp-goto-1.c b/gcc/testsuite/gcc.dg/comp-goto-1.c
new file mode 100644
index 00000000000..66afac87b9f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/comp-goto-1.c
@@ -0,0 +1,13 @@
+/* Test diagnostics for addresses of labels and computed gotos. Test
+ with no special options. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void
+f (void)
+{
+ void *p = &&a;
+ goto *p;
+ a: ;
+}
diff --git a/gcc/testsuite/gcc.dg/comp-goto-2.c b/gcc/testsuite/gcc.dg/comp-goto-2.c
new file mode 100644
index 00000000000..babfe9b5361
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/comp-goto-2.c
@@ -0,0 +1,13 @@
+/* Test diagnostics for addresses of labels and computed gotos. Test
+ with -pedantic. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-pedantic" } */
+
+void
+f (void)
+{
+ void *p = &&a; /* { dg-warning "warning: taking the address of a label is non-standard" } */
+ goto *p; /* { dg-warning "warning: ISO C forbids 'goto \\*expr;'" } */
+ a: ;
+}
diff --git a/gcc/testsuite/gcc.dg/comp-goto-3.c b/gcc/testsuite/gcc.dg/comp-goto-3.c
new file mode 100644
index 00000000000..add18613d75
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/comp-goto-3.c
@@ -0,0 +1,13 @@
+/* Test diagnostics for addresses of labels and computed gotos. Test
+ with -pedantic-errors. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors" } */
+
+void
+f (void)
+{
+ void *p = &&a; /* { dg-error "error: taking the address of a label is non-standard" } */
+ goto *p; /* { dg-error "error: ISO C forbids 'goto \\*expr;'" } */
+ a: ;
+}
diff --git a/gcc/testsuite/gcc.dg/format/strfmon-2.c b/gcc/testsuite/gcc.dg/format/strfmon-2.c
new file mode 100644
index 00000000000..1ecef711d34
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/format/strfmon-2.c
@@ -0,0 +1,13 @@
+/* Test for strfmon format checking. Test for missing fill character
+ at end of format. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat" } */
+
+#include "format.h"
+
+void
+foo (char *s, size_t m)
+{
+ strfmon (s, m, "%="); /* { dg-warning "missing fill character at end" } */
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-arith-1.c b/gcc/testsuite/gcc.dg/pointer-arith-1.c
new file mode 100644
index 00000000000..fec20547bf3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-arith-1.c
@@ -0,0 +1,39 @@
+/* Test diagnostics for arithmetic on void and function pointers.
+ Test with no special options. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void *p;
+void (*f)(void);
+
+void
+g (void)
+{
+ p + 0;
+ p + 1;
+ 0 + p;
+ 1 + p;
+ p - 0;
+ p - 1;
+ p += 0;
+ p += 1;
+ p -= 0;
+ p -= 1;
+ f + 0;
+ f + 1;
+ 0 + f;
+ 1 + f;
+ f - 0;
+ f - 1;
+ f += 0;
+ f += 1;
+ f -= 0;
+ f -= 1;
+ p[0]; /* { dg-warning "warning: dereferencing 'void \\*' pointer" } */
+ 0[p]; /* { dg-warning "warning: dereferencing 'void \\*' pointer" } */
+ f[0]; /* { dg-error "error: subscripted value is neither array nor pointer" } */
+ 0[f]; /* { dg-error "error: subscripted value is neither array nor pointer" } */
+ p - p;
+ f - f;
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-arith-2.c b/gcc/testsuite/gcc.dg/pointer-arith-2.c
new file mode 100644
index 00000000000..8e95ab52078
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-arith-2.c
@@ -0,0 +1,41 @@
+/* Test diagnostics for arithmetic on void and function pointers.
+ Test with -Wpointer-arith. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-Wpointer-arith" } */
+
+void *p;
+void (*f)(void);
+
+void
+g (void)
+{
+ p + 0; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ p + 1; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ 0 + p; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ 1 + p; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ p - 0; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ p - 1; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ p += 0; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ p += 1; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ p -= 0; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ p -= 1; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ f + 0; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ f + 1; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ 0 + f; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ 1 + f; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ f - 0; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ f - 1; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ f += 0; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ f += 1; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ f -= 0; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ f -= 1; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ p[0]; /* { dg-warning "warning: dereferencing 'void \\*' pointer" } */
+ /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" "array 1" { target *-*-* } 33 } */
+ 0[p]; /* { dg-warning "warning: dereferencing 'void \\*' pointer" } */
+ /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" "array 1" { target *-*-* } 35 } */
+ f[0]; /* { dg-error "error: subscripted value is neither array nor pointer" } */
+ 0[f]; /* { dg-error "error: subscripted value is neither array nor pointer" } */
+ p - p; /* { dg-warning "warning: pointer of type 'void \\*' used in subtraction" } */
+ f - f; /* { dg-warning "warning: pointer to a function used in subtraction" } */
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-arith-3.c b/gcc/testsuite/gcc.dg/pointer-arith-3.c
new file mode 100644
index 00000000000..90f524101b8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-arith-3.c
@@ -0,0 +1,41 @@
+/* Test diagnostics for arithmetic on void and function pointers.
+ Test with -pedantic. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-pedantic" } */
+
+void *p;
+void (*f)(void);
+
+void
+g (void)
+{
+ p + 0; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ p + 1; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ 0 + p; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ 1 + p; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ p - 0; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ p - 1; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ p += 0; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ p += 1; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ p -= 0; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ p -= 1; /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" } */
+ f + 0; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ f + 1; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ 0 + f; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ 1 + f; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ f - 0; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ f - 1; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ f += 0; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ f += 1; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ f -= 0; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ f -= 1; /* { dg-warning "warning: pointer to a function used in arithmetic" } */
+ p[0]; /* { dg-warning "warning: dereferencing 'void \\*' pointer" } */
+ /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" "array 1" { target *-*-* } 33 } */
+ 0[p]; /* { dg-warning "warning: dereferencing 'void \\*' pointer" } */
+ /* { dg-warning "warning: pointer of type 'void \\*' used in arithmetic" "array 1" { target *-*-* } 35 } */
+ f[0]; /* { dg-error "error: subscripted value is neither array nor pointer" } */
+ 0[f]; /* { dg-error "error: subscripted value is neither array nor pointer" } */
+ p - p; /* { dg-warning "warning: pointer of type 'void \\*' used in subtraction" } */
+ f - f; /* { dg-warning "warning: pointer to a function used in subtraction" } */
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-arith-4.c b/gcc/testsuite/gcc.dg/pointer-arith-4.c
new file mode 100644
index 00000000000..3e577fc1cb5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-arith-4.c
@@ -0,0 +1,41 @@
+/* Test diagnostics for arithmetic on void and function pointers.
+ Test with -pedantic-errors. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors" } */
+
+void *p;
+void (*f)(void);
+
+void
+g (void)
+{
+ p + 0; /* { dg-error "error: pointer of type 'void \\*' used in arithmetic" } */
+ p + 1; /* { dg-error "error: pointer of type 'void \\*' used in arithmetic" } */
+ 0 + p; /* { dg-error "error: pointer of type 'void \\*' used in arithmetic" } */
+ 1 + p; /* { dg-error "error: pointer of type 'void \\*' used in arithmetic" } */
+ p - 0; /* { dg-error "error: pointer of type 'void \\*' used in arithmetic" } */
+ p - 1; /* { dg-error "error: pointer of type 'void \\*' used in arithmetic" } */
+ p += 0; /* { dg-error "error: pointer of type 'void \\*' used in arithmetic" } */
+ p += 1; /* { dg-error "error: pointer of type 'void \\*' used in arithmetic" } */
+ p -= 0; /* { dg-error "error: pointer of type 'void \\*' used in arithmetic" } */
+ p -= 1; /* { dg-error "error: pointer of type 'void \\*' used in arithmetic" } */
+ f + 0; /* { dg-error "error: pointer to a function used in arithmetic" } */
+ f + 1; /* { dg-error "error: pointer to a function used in arithmetic" } */
+ 0 + f; /* { dg-error "error: pointer to a function used in arithmetic" } */
+ 1 + f; /* { dg-error "error: pointer to a function used in arithmetic" } */
+ f - 0; /* { dg-error "error: pointer to a function used in arithmetic" } */
+ f - 1; /* { dg-error "error: pointer to a function used in arithmetic" } */
+ f += 0; /* { dg-error "error: pointer to a function used in arithmetic" } */
+ f += 1; /* { dg-error "error: pointer to a function used in arithmetic" } */
+ f -= 0; /* { dg-error "error: pointer to a function used in arithmetic" } */
+ f -= 1; /* { dg-error "error: pointer to a function used in arithmetic" } */
+ p[0]; /* { dg-warning "warning: dereferencing 'void \\*' pointer" } */
+ /* { dg-error "error: pointer of type 'void \\*' used in arithmetic" "array 1" { target *-*-* } 33 } */
+ 0[p]; /* { dg-warning "warning: dereferencing 'void \\*' pointer" } */
+ /* { dg-error "error: pointer of type 'void \\*' used in arithmetic" "array 1" { target *-*-* } 35 } */
+ f[0]; /* { dg-error "error: subscripted value is neither array nor pointer" } */
+ 0[f]; /* { dg-error "error: subscripted value is neither array nor pointer" } */
+ p - p; /* { dg-error "error: pointer of type 'void \\*' used in subtraction" } */
+ f - f; /* { dg-error "error: pointer to a function used in subtraction" } */
+}
diff --git a/gcc/testsuite/gcc.dg/switch-5.c b/gcc/testsuite/gcc.dg/switch-5.c
new file mode 100644
index 00000000000..7c1c3d49715
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/switch-5.c
@@ -0,0 +1,75 @@
+/* Test diagnostics for switch statements and labels therein. Test
+ with no special options. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void
+f (int a, double d, void *p)
+{
+ switch (d) /* { dg-error "error: switch quantity not an integer" } */
+ {
+ }
+ switch (p) /* { dg-error "error: switch quantity not an integer" } */
+ {
+ }
+ switch (a)
+ {
+ case (void *)0: ; /* { dg-error "error: pointers are not permitted as case values" } */
+ }
+ switch (a)
+ {
+ case (double)0: ; /* { dg-error "error: case label does not reduce to an integer constant" } */
+ }
+ switch (a)
+ {
+ case (char)0: ;
+ }
+ switch (a)
+ {
+ case 0 ... 0: ;
+ }
+ switch (a)
+ {
+ case 0 ... -1: ; /* { dg-warning "warning: empty range specified" } */
+ }
+ switch (a)
+ {
+ case 0 ... -2: ; /* { dg-warning "warning: empty range specified" } */
+ }
+ switch (a)
+ {
+ case 0:
+ default: /* { dg-error "error: this is the first default label" } */
+ case 1:
+ default: ; /* { dg-error "error: multiple default labels in one switch" } */
+ }
+ switch (a)
+ {
+ case 0: /* { dg-error "error: previously used here" } */
+ case 1:
+ case 0: ; /* { dg-error "error: duplicate case value" } */
+ }
+ case 1: ; /* { dg-error "error: case label not within a switch statement" } */
+ default: ; /* { dg-error "error: 'default' label not within a switch statement" } */
+ break; /* { dg-error "error: break statement not within loop or switch" } */
+ continue; /* { dg-error "error: continue statement not within a loop" } */
+ switch (a)
+ {
+ case a: ; /* { dg-error "error: case label does not reduce to an integer constant" } */
+ }
+ switch (a)
+ {
+ case 0: /* { dg-error "error: this is the first entry overlapping that value" } */
+ case -1 ... 1: /* { dg-error "error: duplicate \\(or overlapping\\) case value" } */
+ case 2 ... 3: /* { dg-error "error: previously used here" } */
+ case 2: /* { dg-error "error: duplicate case value" } */
+ case 4 ... 7: /* { dg-error "error: this is the first entry overlapping that value" } */
+ case 6 ... 9: ; /* { dg-error "error: duplicate \\(or overlapping\\) case value" } */
+ }
+ switch (a)
+ {
+ case 0:
+ continue; /* { dg-error "error: continue statement not within a loop" } */
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/switch-6.c b/gcc/testsuite/gcc.dg/switch-6.c
new file mode 100644
index 00000000000..70cc1882a4f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/switch-6.c
@@ -0,0 +1,14 @@
+/* Test diagnostics for switch statements and labels therein. Test
+ for case ranges with -pedantic. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-pedantic" } */
+
+void
+f (int a)
+{
+ switch (a)
+ {
+ case 0 ... 0: ; /* { dg-warning "warning: range expressions in switch statements are non-standard" } */
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/switch-7.c b/gcc/testsuite/gcc.dg/switch-7.c
new file mode 100644
index 00000000000..d3fdfb4c381
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/switch-7.c
@@ -0,0 +1,14 @@
+/* Test diagnostics for switch statements and labels therein. Test
+ for case ranges with -pedantic-errors. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors" } */
+
+void
+f (int a)
+{
+ switch (a)
+ {
+ case 0 ... 0: ; /* { dg-error "error: range expressions in switch statements are non-standard" } */
+ }
+}