This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/36369] [4.3/4.4 Regression] may_alias broken with previous uses of non attributed type in some cases
- From: "jakub at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 May 2008 13:54:17 -0000
- Subject: [Bug c++/36369] [4.3/4.4 Regression] may_alias broken with previous uses of non attributed type in some cases
- References: <bug-36369-87@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from jakub at gcc dot gnu dot org 2008-05-29 13:54 -------
Quick hack that fixes this:
--- gcc/alias.c.jj 2008-05-18 22:14:23.000000000 +0200
+++ gcc/alias.c 2008-05-29 15:47:30.000000000 +0200
@@ -605,6 +605,8 @@ get_alias_set (tree t)
/* Variant qualifiers don't affect the alias set, so get the main
variant. If this is a type with a known alias set, return it. */
+ if (TYPE_ALIAS_SET_KNOWN_P (t))
+ return TYPE_ALIAS_SET (t);
t = TYPE_MAIN_VARIANT (t);
if (TYPE_ALIAS_SET_KNOWN_P (t))
return TYPE_ALIAS_SET (t);
--- gcc/c-common.c.jj 2008-05-29 10:20:11.000000000 +0200
+++ gcc/c-common.c 2008-05-29 15:46:29.000000000 +0200
@@ -568,6 +568,7 @@ static tree handle_vector_size_attribute
bool *);
static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *);
static tree handle_nothrow_attribute (tree *, tree, tree, int, bool *);
+static tree handle_may_alias_attribute (tree *, tree, tree, int, bool *);
static tree handle_cleanup_attribute (tree *, tree, tree, int, bool *);
static tree handle_warn_unused_result_attribute (tree *, tree, tree, int,
bool *);
@@ -663,7 +664,8 @@ const struct attribute_spec c_common_att
handle_nonnull_attribute },
{ "nothrow", 0, 0, true, false, false,
handle_nothrow_attribute },
- { "may_alias", 0, 0, false, true, false, NULL },
+ { "may_alias", 0, 0, false, true, false,
+ handle_may_alias_attribute },
{ "cleanup", 1, 1, true, false, false,
handle_cleanup_attribute },
{ "warn_unused_result", 0, 0, false, true, true,
@@ -6396,6 +6398,18 @@ handle_nothrow_attribute (tree *node, tr
return NULL_TREE;
}
+/* Handle a "may_alias" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_may_alias_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags),
+ bool *ARG_UNUSED (no_add_attrs))
+{
+ TYPE_ALIAS_SET (*node) = 0;
+ return NULL_TREE;
+}
+
/* Handle a "cleanup" attribute; arguments as in
struct attribute_spec.handler. */
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36369