This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
patch: c++ support for vector opaque types
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 26 Jun 2003 21:17:11 -0400
- Subject: patch: c++ support for vector opaque types
I don't know if the old parser had support, or if I totally forgot
to add C++ support last time around.
Anyhow, here's the patch and the test case.
Tested on x86-linux.
Ok?
2003-06-26 Aldy Hernandez <aldyh@redhat.com>
* cp/Make-lang.in (cp/call.o): Add dependency for target.h.
* cp/call.c (standard_conversion): Support opaque types.
Include target.h.
* cp/typeck.c (convert_for_assignment): Support opaque types.
* testsuite/g++.dg/other/opaque.C: New.
Index: cp/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/Make-lang.in,v
retrieving revision 1.154
diff -c -p -r1.154 Make-lang.in
*** cp/Make-lang.in 23 Jun 2003 20:52:12 -0000 1.154
--- cp/Make-lang.in 27 Jun 2003 01:07:38 -0000
*************** cp/typeck.o: cp/typeck.c $(CXX_TREE_H) $
*** 248,254 ****
diagnostic.h
cp/class.o: cp/class.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h $(RTL_H) $(TARGET_H)
cp/call.o: cp/call.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h $(RTL_H) $(EXPR_H) \
! diagnostic.h intl.h gt-cp-call.h
cp/friend.o: cp/friend.c $(CXX_TREE_H) $(TM_H) flags.h $(RTL_H) toplev.h $(EXPR_H)
cp/init.o: cp/init.c $(CXX_TREE_H) $(TM_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \
except.h
--- 248,254 ----
diagnostic.h
cp/class.o: cp/class.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h $(RTL_H) $(TARGET_H)
cp/call.o: cp/call.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h $(RTL_H) $(EXPR_H) \
! diagnostic.h intl.h gt-cp-call.h target.h
cp/friend.o: cp/friend.c $(CXX_TREE_H) $(TM_H) flags.h $(RTL_H) toplev.h $(EXPR_H)
cp/init.o: cp/init.c $(CXX_TREE_H) $(TM_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \
except.h
Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.393
diff -c -p -r1.393 call.c
*** cp/call.c 26 Jun 2003 15:23:54 -0000 1.393
--- cp/call.c 27 Jun 2003 01:07:38 -0000
*************** Boston, MA 02111-1307, USA. */
*** 37,42 ****
--- 37,43 ----
#include "expr.h"
#include "diagnostic.h"
#include "intl.h"
+ #include "target.h"
static tree build_field_call (tree, tree, tree);
static struct z_candidate * tourney (struct z_candidate *);
*************** standard_conversion (tree to, tree from,
*** 767,772 ****
--- 768,778 ----
return conv;
}
+
+ if (fcode == VECTOR_TYPE && tcode == VECTOR_TYPE
+ && ((*targetm.vector_opaque_p) (from)
+ || (*targetm.vector_opaque_p) (to)))
+ return conv;
if (same_type_p (from, to))
return conv;
Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.468
diff -c -p -r1.468 typeck.c
*** cp/typeck.c 26 Jun 2003 00:06:58 -0000 1.468
--- cp/typeck.c 27 Jun 2003 01:07:38 -0000
*************** convert_for_assignment (tree type, tree
*** 6013,6018 ****
--- 6013,6023 ----
rhstype = TREE_TYPE (rhs);
coder = TREE_CODE (rhstype);
+ if (codel == VECTOR_TYPE && coder == VECTOR_TYPE
+ && ((*targetm.vector_opaque_p) (type)
+ || (*targetm.vector_opaque_p) (rhstype)))
+ return convert (type, rhs);
+
if (rhs == error_mark_node || rhstype == error_mark_node)
return error_mark_node;
if (TREE_CODE (rhs) == TREE_LIST && TREE_VALUE (rhs) == error_mark_node)
Index: testsuite/g++.dg/other/opaque.C
===================================================================
RCS file: testsuite/g++.dg/other/opaque.C
diff -N testsuite/g++.dg/other/opaque.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/other/opaque.C 27 Jun 2003 01:07:38 -0000
***************
*** 0 ****
--- 1,19 ----
+ /* { dg-do compile { target powerpc-*-eabispe* } } */
+
+ #define __vector __attribute__((vector_size(8)))
+
+ typedef float __vector __ev64_fs__;
+ typedef int __vector __ev64_opaque__;
+
+ __ev64_opaque__ *p1;
+ __ev64_fs__ *p2;
+ int *x;
+
+ extern void f (__ev64_opaque__ *);
+
+ void test (void)
+ {
+ f (x); /* { dg-warning "incompatible pointer type" } */
+ f (p1);
+ f (p2);
+ }