Commit 4653cae5 by Richard Guenther Committed by Richard Biener

alias.c (get_alias_set): Use the element alias-set for arrays.

2008-06-11  Richard Guenther  <rguenther@suse.de>

	* alias.c (get_alias_set): Use the element alias-set for arrays.
	(record_component_aliases): For arrays and vectors do nothing.
	* c-common.c (strict_aliasing_warning): Handle the cases
	of alias set zero explicitly.
	* Makefile.in (dfp.o-warn): Add -Wno-error.

From-SVN: r136679
parent 8981c15b
2008-06-11 Richard Guenther <rguenther@suse.de>
* alias.c (get_alias_set): Use the element alias-set for arrays.
(record_component_aliases): For arrays and vectors do nothing.
* c-common.c (strict_aliasing_warning): Handle the cases
of alias set zero explicitly.
* Makefile.in (dfp.o-warn): Add -Wno-error.
2008-06-11 Joseph Myers <joseph@codesourcery.com> 2008-06-11 Joseph Myers <joseph@codesourcery.com>
* config.gcc (all_defaults): Add arch_32 arch_64 cpu_32 cpu_64 * config.gcc (all_defaults): Add arch_32 arch_64 cpu_32 cpu_64
......
...@@ -187,6 +187,8 @@ GCC_WARN_CFLAGS = $(LOOSE_WARN) $($(@D)-warn) $(NOCOMMON_FLAG) $($@-warn) ...@@ -187,6 +187,8 @@ GCC_WARN_CFLAGS = $(LOOSE_WARN) $($(@D)-warn) $(NOCOMMON_FLAG) $($@-warn)
build/gengtype-lex.o-warn = -Wno-error build/gengtype-lex.o-warn = -Wno-error
# SYSCALLS.c misses prototypes # SYSCALLS.c misses prototypes
SYSCALLS.c.X-warn = -Wno-strict-prototypes -Wno-error SYSCALLS.c.X-warn = -Wno-strict-prototypes -Wno-error
# dfp.c contains alias violations
dfp.o-warn = -Wno-error
# All warnings have to be shut off in stage1 if the compiler used then # All warnings have to be shut off in stage1 if the compiler used then
# isn't gcc; configure determines that. WARN_CFLAGS will be either # isn't gcc; configure determines that. WARN_CFLAGS will be either
......
...@@ -640,6 +640,18 @@ get_alias_set (tree t) ...@@ -640,6 +640,18 @@ get_alias_set (tree t)
else if (TREE_CODE (t) == VECTOR_TYPE) else if (TREE_CODE (t) == VECTOR_TYPE)
set = get_alias_set (TREE_TYPE (t)); set = get_alias_set (TREE_TYPE (t));
/* Unless the language specifies otherwise, treat array types the
same as their components. This avoids the asymmetry we get
through recording the components. Consider accessing a
character(kind=1) through a reference to a character(kind=1)[1:1].
Or consider if we want to assign integer(kind=4)[0:D.1387] and
integer(kind=4)[4] the same alias set or not.
Just be pragmatic here and make sure the array and its element
type get the same alias set assigned. */
else if (TREE_CODE (t) == ARRAY_TYPE
&& !TYPE_NONALIASED_COMPONENT (t))
set = get_alias_set (TREE_TYPE (t));
else else
/* Otherwise make a new alias set for this type. */ /* Otherwise make a new alias set for this type. */
set = new_alias_set (); set = new_alias_set ();
...@@ -747,11 +759,6 @@ record_component_aliases (tree type) ...@@ -747,11 +759,6 @@ record_component_aliases (tree type)
switch (TREE_CODE (type)) switch (TREE_CODE (type))
{ {
case ARRAY_TYPE:
if (!TYPE_NONALIASED_COMPONENT (type))
record_alias_subset (superset, get_alias_set (TREE_TYPE (type)));
break;
case RECORD_TYPE: case RECORD_TYPE:
case UNION_TYPE: case UNION_TYPE:
case QUAL_UNION_TYPE: case QUAL_UNION_TYPE:
...@@ -775,6 +782,9 @@ record_component_aliases (tree type) ...@@ -775,6 +782,9 @@ record_component_aliases (tree type)
record_alias_subset (superset, get_alias_set (TREE_TYPE (type))); record_alias_subset (superset, get_alias_set (TREE_TYPE (type)));
break; break;
/* VECTOR_TYPE and ARRAY_TYPE share the alias set with their
element type. */
default: default:
break; break;
} }
......
...@@ -1093,7 +1093,8 @@ strict_aliasing_warning (tree otype, tree type, tree expr) ...@@ -1093,7 +1093,8 @@ strict_aliasing_warning (tree otype, tree type, tree expr)
get_alias_set (TREE_TYPE (TREE_OPERAND (expr, 0))); get_alias_set (TREE_TYPE (TREE_OPERAND (expr, 0)));
alias_set_type set2 = get_alias_set (TREE_TYPE (type)); alias_set_type set2 = get_alias_set (TREE_TYPE (type));
if (!alias_sets_conflict_p (set1, set2)) if (set1 != set2 && set2 != 0
&& (set1 == 0 || !alias_sets_conflict_p (set1, set2)))
{ {
warning (OPT_Wstrict_aliasing, "dereferencing type-punned " warning (OPT_Wstrict_aliasing, "dereferencing type-punned "
"pointer will break strict-aliasing rules"); "pointer will break strict-aliasing rules");
......
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