builtin-choose-expr-2.c, [...]: New tests.

* gcc.dg/builtin-choose-expr-2.c, gcc.dg/cast-1.c,
	gcc.dg/cast-2.c, gcc.dg/cast-3.c, gcc.dg/format/opt-1.c,
	gcc.dg/format/opt-2.c, gcc.dg/format/opt-3.c,
	gcc.dg/format/opt-4.c, gcc.dg/format/opt-5.c,
	gcc.dg/format/opt-6.c, gcc.dg/pointer-arith-5.c,
	gcc.dg/pointer-arith-6.c, gcc.dg/pointer-arith-7.c,
	gcc.dg/pointer-arith-8.c: New tests.

From-SVN: r91405
This commit is contained in:
Joseph Myers 2004-11-28 02:16:57 +00:00 committed by Joseph Myers
parent 69b7944b0d
commit c48cb43994
15 changed files with 255 additions and 0 deletions

View File

@ -1,3 +1,13 @@
2004-11-28 Joseph S. Myers <joseph@codesourcery.com>
* gcc.dg/builtin-choose-expr-2.c, gcc.dg/cast-1.c,
gcc.dg/cast-2.c, gcc.dg/cast-3.c, gcc.dg/format/opt-1.c,
gcc.dg/format/opt-2.c, gcc.dg/format/opt-3.c,
gcc.dg/format/opt-4.c, gcc.dg/format/opt-5.c,
gcc.dg/format/opt-6.c, gcc.dg/pointer-arith-5.c,
gcc.dg/pointer-arith-6.c, gcc.dg/pointer-arith-7.c,
gcc.dg/pointer-arith-8.c: New tests.
2004-11-27 Bud Davis <bdavis9659@comcast.net>
PR fortran/18364

View File

@ -0,0 +1,12 @@
/* Test diagnostic for invalid use of __builtin_choose_expr. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "" } */
int a, b, c, d;
void
f (void)
{
a = __builtin_choose_expr (b, c, d); /* { dg-error "error: first argument to '__builtin_choose_expr' not a constant" } */
}

View File

@ -0,0 +1,41 @@
/* Test diagnostics for bad or doubtful casts. Test with no special
options. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
struct s { int a; } sv;
union u { int a; } uv;
int i;
long l;
char c;
void *p;
float fv;
void
f (void)
{
(int []) p; /* { dg-error "error: cast specifies array type" } */
(int ()) p; /* { dg-error "error: cast specifies function type" } */
(struct s) sv;
(union u) uv;
(struct s) i; /* { dg-error "error: conversion to non-scalar type requested" } */
(union u) i;
(union u) l; /* { dg-error "error: cast to union type from type not present in union" } */
(int) sv; /* { dg-error "error: aggregate value used where an integer was expected" } */
(int) uv; /* { dg-error "error: aggregate value used where an integer was expected" } */
(float) sv; /* { dg-error "error: aggregate value used where a float was expected" } */
(float) uv; /* { dg-error "error: aggregate value used where a float was expected" } */
(_Complex double) sv; /* { dg-error "error: aggregate value used where a complex was expected" } */
(_Complex double) uv; /* { dg-error "error: aggregate value used where a complex was expected" } */
(void *) sv; /* { dg-error "error: cannot convert to a pointer type" } */
(void *) uv; /* { dg-error "error: cannot convert to a pointer type" } */
(_Bool) sv; /* { dg-error "error: used struct type value where scalar is required" } */
(_Bool) uv; /* { dg-error "error: used union type value where scalar is required" } */
(void) sv;
(const void) uv;
(void *) c; /* { dg-warning "warning: cast to pointer from integer of different size" } */
(void *) (char) 1;
(char) p; /* { dg-warning "warning: cast from pointer to integer of different size" } */
(char) (void *) 1;
}

View File

@ -0,0 +1,41 @@
/* Test diagnostics for bad or doubtful casts. Test with
-pedantic. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -pedantic" } */
struct s { int a; } sv;
union u { int a; } uv;
int i;
long l;
char c;
void *p;
float fv;
void
f (void)
{
(int []) p; /* { dg-error "error: cast specifies array type" } */
(int ()) p; /* { dg-error "error: cast specifies function type" } */
(struct s) sv; /* { dg-warning "warning: ISO C forbids casting nonscalar to the same type" } */
(union u) uv; /* { dg-warning "warning: ISO C forbids casting nonscalar to the same type" } */
(struct s) i; /* { dg-error "error: conversion to non-scalar type requested" } */
(union u) i; /* { dg-warning "warning: ISO C forbids casts to union type" } */
(union u) l; /* { dg-error "error: cast to union type from type not present in union" } */
(int) sv; /* { dg-error "error: aggregate value used where an integer was expected" } */
(int) uv; /* { dg-error "error: aggregate value used where an integer was expected" } */
(float) sv; /* { dg-error "error: aggregate value used where a float was expected" } */
(float) uv; /* { dg-error "error: aggregate value used where a float was expected" } */
(_Complex double) sv; /* { dg-error "error: aggregate value used where a complex was expected" } */
(_Complex double) uv; /* { dg-error "error: aggregate value used where a complex was expected" } */
(void *) sv; /* { dg-error "error: cannot convert to a pointer type" } */
(void *) uv; /* { dg-error "error: cannot convert to a pointer type" } */
(_Bool) sv; /* { dg-error "error: used struct type value where scalar is required" } */
(_Bool) uv; /* { dg-error "error: used union type value where scalar is required" } */
(void) sv;
(const void) uv;
(void *) c; /* { dg-warning "warning: cast to pointer from integer of different size" } */
(void *) (char) 1;
(char) p; /* { dg-warning "warning: cast from pointer to integer of different size" } */
(char) (void *) 1;
}

View File

@ -0,0 +1,41 @@
/* Test diagnostics for bad or doubtful casts. Test with
-pedantic-errors. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -pedantic-errors" } */
struct s { int a; } sv;
union u { int a; } uv;
int i;
long l;
char c;
void *p;
float fv;
void
f (void)
{
(int []) p; /* { dg-error "error: cast specifies array type" } */
(int ()) p; /* { dg-error "error: cast specifies function type" } */
(struct s) sv; /* { dg-error "error: ISO C forbids casting nonscalar to the same type" } */
(union u) uv; /* { dg-error "error: ISO C forbids casting nonscalar to the same type" } */
(struct s) i; /* { dg-error "error: conversion to non-scalar type requested" } */
(union u) i; /* { dg-error "error: ISO C forbids casts to union type" } */
(union u) l; /* { dg-error "error: cast to union type from type not present in union" } */
(int) sv; /* { dg-error "error: aggregate value used where an integer was expected" } */
(int) uv; /* { dg-error "error: aggregate value used where an integer was expected" } */
(float) sv; /* { dg-error "error: aggregate value used where a float was expected" } */
(float) uv; /* { dg-error "error: aggregate value used where a float was expected" } */
(_Complex double) sv; /* { dg-error "error: aggregate value used where a complex was expected" } */
(_Complex double) uv; /* { dg-error "error: aggregate value used where a complex was expected" } */
(void *) sv; /* { dg-error "error: cannot convert to a pointer type" } */
(void *) uv; /* { dg-error "error: cannot convert to a pointer type" } */
(_Bool) sv; /* { dg-error "error: used struct type value where scalar is required" } */
(_Bool) uv; /* { dg-error "error: used union type value where scalar is required" } */
(void) sv;
(const void) uv;
(void *) c; /* { dg-warning "warning: cast to pointer from integer of different size" } */
(void *) (char) 1;
(char) p; /* { dg-warning "warning: cast from pointer to integer of different size" } */
(char) (void *) 1;
}

View File

@ -0,0 +1,7 @@
/* Test diagnostics for options used on their own without
-Wformat. -Wformat-extra-args. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-Wformat-extra-args" } */
/* { dg-warning "warning: -Wformat-extra-args ignored without -Wformat" "ignored" { target *-*-* } 0 } */

View File

@ -0,0 +1,7 @@
/* Test diagnostics for options used on their own without
-Wformat. -Wformat-nonliteral. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-Wformat-nonliteral" } */
/* { dg-warning "warning: -Wformat-nonliteral ignored without -Wformat" "ignored" { target *-*-* } 0 } */

View File

@ -0,0 +1,7 @@
/* Test diagnostics for options used on their own without
-Wformat. -Wformat-security. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-Wformat-security" } */
/* { dg-warning "warning: -Wformat-security ignored without -Wformat" "ignored" { target *-*-* } 0 } */

View File

@ -0,0 +1,7 @@
/* Test diagnostics for options used on their own without
-Wformat. -Wformat-y2k. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-Wformat-y2k" } */
/* { dg-warning "warning: -Wformat-y2k ignored without -Wformat" "ignored" { target *-*-* } 0 } */

View File

@ -0,0 +1,7 @@
/* Test diagnostics for options used on their own without
-Wformat. -Wformat-zero-length. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-Wformat-zero-length" } */
/* { dg-warning "warning: -Wformat-zero-length ignored without -Wformat" "ignored" { target *-*-* } 0 } */

View File

@ -0,0 +1,7 @@
/* Test diagnostics for options used on their own without
-Wformat. -Wmissing-format-attribute. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-Wmissing-format-attribute" } */
/* { dg-warning "warning: -Wmissing-format-attribute ignored without -Wformat" "ignored" { target *-*-* } 0 } */

View File

@ -0,0 +1,17 @@
/* Test diagnostics for sizeof on void and function types. Test with
no special options. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "" } */
extern const void v;
void f(void);
void
g (void)
{
sizeof (v);
sizeof (void);
sizeof (f);
sizeof (void (void));
}

View File

@ -0,0 +1,17 @@
/* Test diagnostics for sizeof on void and function types. Test with
-Wpointer-arith. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-Wpointer-arith" } */
extern const void v;
void f(void);
void
g (void)
{
sizeof (v); /* { dg-warning "warning: invalid application of 'sizeof' to a void type" } */
sizeof (void); /* { dg-warning "warning: invalid application of 'sizeof' to a void type" } */
sizeof (f); /* { dg-warning "warning: invalid application of 'sizeof' to a function type" } */
sizeof (void (void)); /* { dg-warning "warning: invalid application of 'sizeof' to a function type" } */
}

View File

@ -0,0 +1,17 @@
/* Test diagnostics for sizeof on void and function types. Test with
-pedantic. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-pedantic" } */
extern const void v;
void f(void);
void
g (void)
{
sizeof (v); /* { dg-warning "warning: invalid application of 'sizeof' to a void type" } */
sizeof (void); /* { dg-warning "warning: invalid application of 'sizeof' to a void type" } */
sizeof (f); /* { dg-warning "warning: invalid application of 'sizeof' to a function type" } */
sizeof (void (void)); /* { dg-warning "warning: invalid application of 'sizeof' to a function type" } */
}

View File

@ -0,0 +1,17 @@
/* Test diagnostics for sizeof on void and function types. Test with
-pedantic-errors. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-pedantic-errors" } */
extern const void v;
void f(void);
void
g (void)
{
sizeof (v); /* { dg-error "error: invalid application of 'sizeof' to a void type" } */
sizeof (void); /* { dg-error "error: invalid application of 'sizeof' to a void type" } */
sizeof (f); /* { dg-error "error: invalid application of 'sizeof' to a function type" } */
sizeof (void (void)); /* { dg-error "error: invalid application of 'sizeof' to a function type" } */
}