This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
__attribute__ in types
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: 08 Dec 2001 18:35:11 -0800
- Subject: __attribute__ in types
currently, __attributes__ in types is unsupported. this means you can't
do casts like this:
#define vector __attribute__((vector_size(16)))
vector int foo;
vector float bar;
void b();
void b()
{
foo = (vector int) bar;
}
here is a patch to add support to the front end.
the testcase is for altivec, although this is not exactly an altivec
fix. the problem is that i can't trigger the error for other
__attribute__'s in casts. if someone can think of a better, non vector
oriented case, feel free.
ok?
--
Aldy Hernandez E-mail: aldyh@redhat.com
Professional Gypsy
Red Hat, Inc.
2001-12-08 Aldy Hernandez <aldyh@redhat.com>
* testsuite/gcc.dg/altivec-3.c: New.
* c-parse.in (typename): Do not split attributes.
Remove unsupported attributes warning.
* c-decl.c (groktypename): Apply attributes.
Index: c-parse.in
===================================================================
RCS file: /cvs/uberbaum/gcc/c-parse.in,v
retrieving revision 1.120
diff -c -p -r1.120 c-parse.in
*** c-parse.in 2001/12/08 22:34:54 1.120
--- c-parse.in 2001/12/09 02:28:09
*************** enumerator:
*** 1875,1887 ****
typename:
declspecs_nosc
! { tree specs, attrs;
! pending_xref_error ();
! split_specs_attrs ($1, &specs, &attrs);
! /* We don't yet support attributes here. */
! if (attrs != NULL_TREE)
! warning ("attributes on type name ignored");
! $<ttype>$ = specs; }
absdcl
{ $$ = build_tree_list ($<ttype>2, $3); }
;
--- 1875,1882 ----
typename:
declspecs_nosc
! { pending_xref_error ();
! $<ttype>$ = $1; }
absdcl
{ $$ = build_tree_list ($<ttype>2, $3); }
;
Index: c-decl.c
===================================================================
RCS file: /cvs/uberbaum/gcc/c-decl.c,v
retrieving revision 1.282
diff -c -p -r1.282 c-decl.c
*** c-decl.c 2001/12/07 22:19:47 1.282
--- c-decl.c 2001/12/09 02:28:10
*************** tree
*** 3359,3369 ****
groktypename (typename)
tree typename;
{
if (TREE_CODE (typename) != TREE_LIST)
return typename;
! return grokdeclarator (TREE_VALUE (typename),
! TREE_PURPOSE (typename),
! TYPENAME, 0);
}
/* Return a PARM_DECL node for a given pair of specs and declarator. */
--- 3359,3377 ----
groktypename (typename)
tree typename;
{
+ tree specs, attrs;
+
if (TREE_CODE (typename) != TREE_LIST)
return typename;
!
! split_specs_attrs (TREE_PURPOSE (typename), &specs, &attrs);
!
! typename = grokdeclarator (TREE_VALUE (typename), specs, TYPENAME, 0);
!
! /* Apply attributes. */
! decl_attributes (&typename, attrs, 0);
!
! return typename;
}
/* Return a PARM_DECL node for a given pair of specs and declarator. */
Index: testsuite/gcc.dg/altivec-3.c
===================================================================
RCS file: altivec-3.c
diff -N altivec-3.c
*** /dev/null Tue May 5 13:32:27 1998
--- altivec-3.c Sat Dec 8 18:28:10 2001
***************
*** 0 ****
--- 1,17 ----
+ /* { dg-do compile { target powerpc-*-* } } */
+ /* { dg-options "-maltivec -O0 -Wall" } */
+
+ /* This tests attributed types. */
+
+ #define vector __attribute__((vector_size(16)))
+
+ vector int foo;
+ vector float bar;
+
+ void b ();
+
+ void
+ b()
+ {
+ foo = (vector int) bar;
+ }