public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/20982] alignment attribute ignired for vector pointers types
[not found] <bug-20982-10424@http.gcc.gnu.org/bugzilla/>
@ 2007-11-16 19:33 ` manu at gcc dot gnu dot org
2009-02-07 20:47 ` manu at gcc dot gnu dot org
1 sibling, 0 replies; 2+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-11-16 19:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from manu at gcc dot gnu dot org 2007-11-16 19:32 -------
(In reply to comment #1)
> aligned can never decrease the required alignment.
>
Can we detect this and emit a diagnostic? We do it for declarations already but
not for types. I tried the following patch as a wild guess but it generates
regressions in gcc.dg/compat/struct-layout-1 and similar.
Index: gcc/testsuite/gcc.dg/pr20982.c
===================================================================
--- gcc/testsuite/gcc.dg/pr20982.c (revision 0)
+++ gcc/testsuite/gcc.dg/pr20982.c (revision 0)
@@ -0,0 +1,11 @@
+/* PR 20982 alignment attribute ignored for vector pointers types */
+/* { dg-do compile } */
+/* { dg-options "-msse " } */
+typedef float v4sf __attribute__ ((mode(V4SF),aligned(8)));
+/* { dg-warning "specifying vector types with __attribute__ ..mode.. is
deprecated" } "" { target *-*-* } 4 }*/
+/* { dg-warning " use .* instead" "" { target *-*-* } 4 } */
+/* { dg-error "alignment for .* must be at least" "" { target *-*-* } 4 } */
+
+v4sf foo(v4sf *p, v4sf *q) {
+ return *p + *q;
+}
Index: gcc/c-common.c
===================================================================
--- gcc/c-common.c (revision 130174)
+++ gcc/c-common.c (working copy)
@@ -5438,23 +5438,38 @@
}
else if (is_type)
{
- /* If we have a TYPE_DECL, then copy the type, so that we
- don't accidentally modify a builtin type. See pushdecl. */
- if (decl && TREE_TYPE (decl) != error_mark_node
- && DECL_ORIGINAL_TYPE (decl) == NULL_TREE)
- {
- tree tt = TREE_TYPE (decl);
- *type = build_variant_type_copy (*type);
- DECL_ORIGINAL_TYPE (decl) = tt;
- TYPE_NAME (*type) = decl;
- TREE_USED (*type) = TREE_USED (decl);
- TREE_TYPE (decl) = *type;
- }
- else if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
- *type = build_variant_type_copy (*type);
-
- TYPE_ALIGN (*type) = (1 << i) * BITS_PER_UNIT;
- TYPE_USER_ALIGN (*type) = 1;
+ if (TYPE_ALIGN (*type) > (unsigned) (1 << i) * BITS_PER_UNIT)
+ {
+ if (TYPE_USER_ALIGN (*type))
+ error ("alignment for %qT was previously specified as %d "
+ "and may not be decreased", *type,
+ TYPE_ALIGN (*type) / BITS_PER_UNIT);
+ else
+ error ("alignment for %qT must be at least %d", *type,
+ TYPE_ALIGN (*type) / BITS_PER_UNIT);
+ *no_add_attrs = true;
+ }
+ else
+ {
+ /* If we have a TYPE_DECL, then copy the type, so that we
+ don't accidentally modify a builtin type. See pushdecl. */
+ if (decl && TREE_TYPE (decl) != error_mark_node
+ && DECL_ORIGINAL_TYPE (decl) == NULL_TREE)
+ {
+ tree tt = TREE_TYPE (decl);
+ *type = build_variant_type_copy (*type);
+ DECL_ORIGINAL_TYPE (decl) = tt;
+ TYPE_NAME (*type) = decl;
+ TREE_USED (*type) = TREE_USED (decl);
+ TREE_TYPE (decl) = *type;
+ }
+ else if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
+ *type = build_variant_type_copy (*type);
+
+
+ TYPE_ALIGN (*type) = (1 << i) * BITS_PER_UNIT;
+ TYPE_USER_ALIGN (*type) = 1;
+ }
}
else if (! VAR_OR_FUNCTION_DECL_P (decl)
&& TREE_CODE (decl) != FIELD_DECL)
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-11-16 19:32:54
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20982
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug middle-end/20982] alignment attribute ignired for vector pointers types
[not found] <bug-20982-10424@http.gcc.gnu.org/bugzilla/>
2007-11-16 19:33 ` [Bug middle-end/20982] alignment attribute ignired for vector pointers types manu at gcc dot gnu dot org
@ 2009-02-07 20:47 ` manu at gcc dot gnu dot org
1 sibling, 0 replies; 2+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-02-07 20:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from manu at gcc dot gnu dot org 2009-02-07 20:46 -------
This is a missing diagnostic.
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Last reconfirmed|2007-11-16 19:32:54 |2009-02-07 20:46:55
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20982
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-02-07 20:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-20982-10424@http.gcc.gnu.org/bugzilla/>
2007-11-16 19:33 ` [Bug middle-end/20982] alignment attribute ignired for vector pointers types manu at gcc dot gnu dot org
2009-02-07 20:47 ` manu at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).