aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-typeck.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2005-06-09 11:36:12 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2005-06-09 11:36:12 +0000
commit5878b92f9edefa7c60d5508fbba8441dc1358df9 (patch)
tree787ca8df932d5209b49a6b6917d989cc4a5c0b20 /gcc/c-typeck.c
parent9df3d545d50e1c6440491c48f01840edd4346a19 (diff)
downloadgcc-5878b92f9edefa7c60d5508fbba8441dc1358df9.zip
gcc-5878b92f9edefa7c60d5508fbba8441dc1358df9.tar.gz
gcc-5878b92f9edefa7c60d5508fbba8441dc1358df9.tar.bz2
c-typeck.c (build_c_cast): Check type punning on COMPONENT_REF too.
/: * c-typeck.c (build_c_cast): Check type punning on COMPONENT_REF too. testsuite: * gcc.dg/alias-8.c: New. From-SVN: r100799
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r--gcc/c-typeck.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index a1c7e56..9429b73 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -3304,14 +3304,15 @@ build_c_cast (tree type, tree expr)
&& !TREE_CONSTANT (value))
warning (0, "cast to pointer from integer of different size");
- if (TREE_CODE (type) == POINTER_TYPE
+ if (flag_strict_aliasing && warn_strict_aliasing
+ && TREE_CODE (type) == POINTER_TYPE
&& TREE_CODE (otype) == POINTER_TYPE
&& TREE_CODE (expr) == ADDR_EXPR
- && DECL_P (TREE_OPERAND (expr, 0))
- && flag_strict_aliasing && warn_strict_aliasing
+ && (DECL_P (TREE_OPERAND (expr, 0))
+ || TREE_CODE (TREE_OPERAND (expr, 0)) == COMPONENT_REF)
&& !VOID_TYPE_P (TREE_TYPE (type)))
{
- /* Casting the address of a decl to non void pointer. Warn
+ /* Casting the address of an object to non void pointer. Warn
if the cast breaks type based aliasing. */
if (!COMPLETE_TYPE_P (TREE_TYPE (type)))
warning (0, "type-punning to incomplete type might break strict-aliasing rules");