diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-11-28 02:16:57 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-11-28 02:16:57 +0000 |
commit | 10bed881860e3b30140099a483cf4aaa1f84c342 (patch) | |
tree | 87cb5c2422aa38c268152d7f12a18fc52fcf83a1 /gcc/testsuite/gcc.dg/cast-1.c | |
parent | 27122e39581a8fc5574528ebab3a9f879ffc3ae6 (diff) | |
download | gcc-10bed881860e3b30140099a483cf4aaa1f84c342.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@91405 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/cast-1.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/cast-1.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/cast-1.c b/gcc/testsuite/gcc.dg/cast-1.c new file mode 100644 index 00000000000..e3d79db6be2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cast-1.c @@ -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; +} |