This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PING, PATCH, rs6000] Fix "volatile vector" types
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: pinskia at gmail dot com (Andrew Pinski)
- Cc: gcc-patches at gcc dot gnu dot org, dje at watson dot ibm dot com
- Date: Tue, 19 Aug 2008 01:47:22 +0200 (CEST)
- Subject: Re: [PING, PATCH, rs6000] Fix "volatile vector" types
Andrew Pinski wrote:
> On Mon, Aug 18, 2008 at 12:20 PM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> >
> > [PATCH, rs6000] Fix "volatile vector" types
> > http://gcc.gnu.org/ml/gcc-patches/2008-08/msg00604.html
>
> How about adding a testcase something like:
> /* { dg-do compile } */
> /* { dg-options "-maltivec" } */
> #include <altivec.h>
> vector float *f(volatile vector float *a)
> {
> return a; /* { dg-warning "discards qualifiers" } */
> }
Nice. I had been wondering how to test for the effects of
volatile, but this is certainly a good way of doing that!
Updated patch including test case is appended.
OK for mainline and 4.3?
Bye,
Ulrich
ChangeLog:
* config/rs6000/rs6000.c (rs6000_handle_altivec_attribute): Propagate
all type qualifiers from element type to vector type.
testsuite/ChangeLog:
* gcc.target/powerpc/altivec-volatile.c: New test.
diff -crNp -x .svn gcc-head-orig/gcc/config/rs6000/rs6000.c gcc-head/gcc/config/rs6000/rs6000.c
*** gcc-head-orig/gcc/config/rs6000/rs6000.c 2008-08-12 14:59:27.000000000 +0200
--- gcc-head/gcc/config/rs6000/rs6000.c 2008-08-19 01:35:17.000000000 +0200
*************** rs6000_handle_altivec_attribute (tree *n
*** 20294,20301 ****
default: break;
}
! if (result && result != type && TYPE_READONLY (type))
! result = build_qualified_type (result, TYPE_QUAL_CONST);
*no_add_attrs = true; /* No need to hang on to the attribute. */
--- 20294,20303 ----
default: break;
}
! /* Propagate qualifiers attached to the element type
! onto the vector type. */
! if (result && result != type && TYPE_QUALS (type))
! result = build_qualified_type (result, TYPE_QUALS (type));
*no_add_attrs = true; /* No need to hang on to the attribute. */
diff -crNp -x .svn gcc-head-orig/gcc/testsuite/gcc.target/powerpc/altivec-volatile.c gcc-head/gcc/testsuite/gcc.target/powerpc/altivec-volatile.c
*** gcc-head-orig/gcc/testsuite/gcc.target/powerpc/altivec-volatile.c 1970-01-01 01:00:00.000000000 +0100
--- gcc-head/gcc/testsuite/gcc.target/powerpc/altivec-volatile.c 2008-08-19 00:02:35.000000000 +0200
***************
*** 0 ****
--- 1,13 ----
+ /* { dg-do compile { target powerpc*-*-* } } */
+ /* { dg-require-effective-target powerpc_altivec_ok } */
+ /* { dg-options "-maltivec" } */
+
+ /* Check that "volatile" type qualifier is propagated to vector type. */
+
+ #include <altivec.h>
+
+ vector float *f (volatile vector float *a)
+ {
+ return a; /* { dg-warning "discards qualifiers" } */
+ }
+
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com