diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2002-10-01 19:11:07 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2002-10-01 19:11:07 +0000 |
commit | 73a737681502c4880bee7b1825a4ff0c30f97e79 (patch) | |
tree | 4d8138cc11bddd48062039b3be6a93ad7ecb8eff /gcc/testsuite/gcc.dg/alias-1.c | |
parent | 0645ba8f0b34dbbce7a57dcf712cd0cb261edcc2 (diff) | |
download | gcc-73a737681502c4880bee7b1825a4ff0c30f97e79.zip gcc-73a737681502c4880bee7b1825a4ff0c30f97e79.tar.gz gcc-73a737681502c4880bee7b1825a4ff0c30f97e79.tar.bz2 |
re PR c/8083 (GCC does not warn for aliasing violations)
PR c/8083
* c-typeck.c (build_c_cast): Warn about type punning which breaks
type based aliasing.
testsuite:
* gcc.dg/alias-1.c: New test.
From-SVN: r57698
Diffstat (limited to 'gcc/testsuite/gcc.dg/alias-1.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/alias-1.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/alias-1.c b/gcc/testsuite/gcc.dg/alias-1.c new file mode 100644 index 0000000..71056e9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/alias-1.c @@ -0,0 +1,28 @@ +// { dg-do compile } +// { dg-options "-W -fstrict-aliasing" } + +// Copyright (C) 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Sep 2002 <nathan@codesourcery.com> + +// 8083. warn about odd casts + +typedef int YYSTYPE; +typedef struct tDefEntry +{ + unsigned t; + +} tDefEntry; +struct incomplete; + + +YYSTYPE + addSibMacro( + YYSTYPE list ) + { + tDefEntry** ppT = (tDefEntry**)&list; // { dg-warning "type punning cast" "" } + + struct incomplete *p = (struct incomplete *)&list; // { dg-warning "type punning to incomplete" "" } + + return list; + } + |