public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] FIx PR C/30427 ~ vector float is accepted
@ 2007-08-13  0:09 Andrew Pinski
  2007-08-13 20:00 ` Joseph S. Myers
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Pinski @ 2007-08-13  0:09 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 616 bytes --]

Hi,
  The C front-end allows a vector float argument to bit-complement
currently.  This seems wrong as it does not make sense as a scalar
real is not accepted for a bit-complement and real does not have a
nice bit pattern to be able to be bitwise-complemented.  Note this is
rejected by the C++ front-end already.

This patch adds a check for a vector float type to make sure this gets rejected.

OK? Bootstrapped and tested on i386-apple-darwin8.10 with no regressions.

Thanks,
Andrew Pinski

ChangeLog:
* c-typeck.c (build_unary_op <case BIT_NOT_EXPR>): Reject vector float
types.

* gcc.dg/vector-1.c: New test.

[-- Attachment #2: fixpr30427.diff.txt --]
[-- Type: text/plain, Size: 1028 bytes --]

Index: testsuite/gcc.dg/vector-1.c
===================================================================
--- testsuite/gcc.dg/vector-1.c	(revision 0)
+++ testsuite/gcc.dg/vector-1.c	(revision 0)
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+/* Check for application of ~ on vector types.  */
+
+#define vector __attribute__((vector_size(16) ))
+
+vector float a;
+vector int a1;
+
+int f(void)
+{
+ a =  ~a; /* { dg-error "" } */
+ a1 =  ~a1;
+}
Index: c-typeck.c
===================================================================
--- c-typeck.c	(revision 127385)
+++ c-typeck.c	(working copy)
@@ -2832,7 +2832,10 @@ build_unary_op (enum tree_code code, tre
       break;
 
     case BIT_NOT_EXPR:
-      if (typecode == INTEGER_TYPE || typecode == VECTOR_TYPE)
+      /* ~ works on integer types and non float vectors. */
+      if (typecode == INTEGER_TYPE
+	  || (typecode == VECTOR_TYPE
+	      && !VECTOR_FLOAT_TYPE_P (TREE_TYPE (arg))))
 	{
 	  if (!noconvert)
 	    arg = default_conversion (arg);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] FIx PR C/30427 ~ vector float is accepted
  2007-08-13  0:09 [PATCH] FIx PR C/30427 ~ vector float is accepted Andrew Pinski
@ 2007-08-13 20:00 ` Joseph S. Myers
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph S. Myers @ 2007-08-13 20:00 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Patches

On Sun, 12 Aug 2007, Andrew Pinski wrote:

> Hi,
>   The C front-end allows a vector float argument to bit-complement
> currently.  This seems wrong as it does not make sense as a scalar
> real is not accepted for a bit-complement and real does not have a
> nice bit pattern to be able to be bitwise-complemented.  Note this is
> rejected by the C++ front-end already.
> 
> This patch adds a check for a vector float type to make sure this gets rejected.
> 
> OK? Bootstrapped and tested on i386-apple-darwin8.10 with no regressions.

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-13 20:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-13  0:09 [PATCH] FIx PR C/30427 ~ vector float is accepted Andrew Pinski
2007-08-13 20:00 ` Joseph S. Myers

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).