This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Disallow vector_size attributes on VECTOR_TYPE (PR c/29736)


Hi!

The testcase below already gets proper diagnostics on e.g. x86_64-linux -m64
or -m32 -msse2, where the second vector_size attribute is disallowed because
orig_mode is V2SImode.  But e.g. on i?86-linux -mno-sse orig_mode is
DImode, yet the middle-end isn't prepared to see VECTOR_TYPE as the inner
type of another VECTOR_TYPE and info gcc documents:
     This attribute is only applicable to integral and float scalars,
     although arrays, pointers, and function return values are allowed
     in conjunction with this construct.
While int __attribute ((vector_size (8))) has DImode mode, I don't think
we can say that it is integral or float scalar.

Ok for 4.1/4.2/4.3?

2006-11-21  Jakub Jelinek  <jakub@redhat.com>

	PR c/29736
	* c-common.c (handle_vector_size_attribute): Disallow VECTOR_TYPE
	or UNION_TYPE inner types.

	* gcc.dg/pr29736.c: New test.

--- gcc/c-common.c.jj	2006-11-07 21:46:17.000000000 +0100
+++ gcc/c-common.c	2006-11-21 15:53:50.000000000 +0100
@@ -5337,6 +5337,8 @@ handle_vector_size_attribute (tree *node
   orig_mode = TYPE_MODE (type);
 
   if (TREE_CODE (type) == RECORD_TYPE
+      || TREE_CODE (type) == UNION_TYPE
+      || TREE_CODE (type) == VECTOR_TYPE
       || (!SCALAR_FLOAT_MODE_P (orig_mode)
 	  && GET_MODE_CLASS (orig_mode) != MODE_INT)
       || !host_integerp (TYPE_SIZE_UNIT (type), 1))
--- gcc/testsuite/gcc.dg/pr29736.c.jj	2006-11-21 16:11:27.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr29736.c	2006-11-21 16:04:30.000000000 +0100
@@ -0,0 +1,13 @@
+/* PR c/29736 */
+
+int __attribute__ ((vector_size (8), vector_size (8))) v; /* { dg-error "invalid vector type" } */
+
+extern int __attribute__ ((vector_size (8))) w;
+int __attribute__ ((vector_size (8))) w;
+
+void
+foo ()
+{
+  v = v + v;
+  w = w + w;
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]