Commit bbee4b64 by Richard Guenther Committed by Richard Biener

c-common.c (strict_aliasing_warning): Handle all component-ref like accesses.

2005-11-28  Richard Guenther  <rguenther@suse.de>

	* c-common.c (strict_aliasing_warning): Handle all
	component-ref like accesses.

	* gcc.dg/alias-9.c: New testcase.
	* g++.dg/warn/Wstrict-aliasing-7.C: Likewise.

From-SVN: r107598
parent d531830f
2005-11-28 Richard Guenther <rguenther@suse.de>
* c-common.c (strict_aliasing_warning): Handle all
component-ref like accesses.
2005-11-28 Roger Sayle <roger@eyesopen.com> 2005-11-28 Roger Sayle <roger@eyesopen.com>
Uros Bizjak <uros@kss-loka.si> Uros Bizjak <uros@kss-loka.si>
......
...@@ -966,7 +966,7 @@ strict_aliasing_warning(tree otype, tree type, tree expr) ...@@ -966,7 +966,7 @@ strict_aliasing_warning(tree otype, tree type, tree expr)
&& POINTER_TYPE_P (type) && POINTER_TYPE_P (otype) && POINTER_TYPE_P (type) && POINTER_TYPE_P (otype)
&& TREE_CODE (expr) == ADDR_EXPR && TREE_CODE (expr) == ADDR_EXPR
&& (DECL_P (TREE_OPERAND (expr, 0)) && (DECL_P (TREE_OPERAND (expr, 0))
|| TREE_CODE (TREE_OPERAND (expr, 0)) == COMPONENT_REF) || handled_component_p (TREE_OPERAND (expr, 0)))
&& !VOID_TYPE_P (TREE_TYPE (type))) && !VOID_TYPE_P (TREE_TYPE (type)))
{ {
/* Casting the address of an object to non void pointer. Warn /* Casting the address of an object to non void pointer. Warn
......
2005-11-28 Richard Guenther <rguenther@suse.de>
* gcc.dg/alias-9.c: New testcase.
* g++.dg/warn/Wstrict-aliasing-7.C: Likewise.
2005-11-28 Roger Sayle <roger@eyesopen.com> 2005-11-28 Roger Sayle <roger@eyesopen.com>
Uros Bizjak <uros@kss-loka.si> Uros Bizjak <uros@kss-loka.si>
/* { dg-do compile } */
/* { dg-options "-Wstrict-aliasing -O2" } */
int a[2];
double *foo1(void)
{
return (double *)a; /* { dg-warning "strict-aliasing" } */
}
double *foo2(void)
{
return (double *)&a[0]; /* { dg-warning "strict-aliasing" } */
}
__complex__ double x;
int *bar(void)
{
return (int *)&__imag__ x; /* { dg-warning "strict-aliasing" } */
}
/* { dg-do compile } */
/* { dg-options "-Wstrict-aliasing -O2" } */
int a[2];
double *foo1(void)
{
return (double *)a; /* { dg-warning "strict-aliasing" } */
}
double *foo2(void)
{
return (double *)&a[0]; /* { dg-warning "strict-aliasing" } */
}
_Complex x;
int *bar(void)
{
return (int *)&__imag x; /* { dg-warning "strict-aliasing" } */
}
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