Commit efcc66f0 by Joseph Myers Committed by Joseph Myers

c99-flex-array-5.c, [...]: New tests.

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

From-SVN: r90637
parent 50922820
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*.
......
/* 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" } */
/* 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" } */
;
}
/* 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: ;
}
/* 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: ;
}
/* 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: ;
}
/* 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" } */
}
/* 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;
}
/* 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" } */
}
/* 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" } */
}
/* 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" } */
}
/* 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" } */
}
}
/* 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" } */
}
}
/* 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" } */
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment