From 43dc123f52541ec779e4b56541203cec16c18d80 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Mon, 25 Aug 2003 15:47:43 +0000 Subject: [PATCH] re PR target/8795 ([PPC] Altivec related bugs concerning gcc 3.3 and mainline) PR c++/8795 * tree.h (build_method_type_directly): Declare. * c-common.c (handle_vector_size_attributes): Handle METHOD_TYPEs. (vector_size_helper): Likewise. * tree.c (build_method_type_directly): New function. (build_method_type): Use it. PR c++/8795 * cp-tree.h (build_cplus_method_type): Remove. * call.c (standard_conversion): Use build_method_type_directly instead of build_cplus_method_type. * class.c (build_clone): Likewise. (adjust_clone_args): Likewise. * decl.c (build_ptrmem_type): Likewise. (grokdeclarator): Likewise. (check_function_type): Likewise. * decl2.c (grok_method_quals): Likewise. (maybe_retrofit_in_chrg): Likewise. * pt.c (copy_default_args_to_explicit_spec): Likewise. (tsubst_function_type): Likewise. (tsubst): Likewise. * tree.c (build_cplus_method_type): Remove. * typeck.c (merge_types): Use build_method_type_directly. PR c++/8795 * g++.dg/ext/altivec-1.C: New test. From-SVN: r70773 --- gcc/ChangeLog | 9 +++++++ gcc/c-common.c | 12 +++++++-- gcc/cp/ChangeLog | 19 ++++++++++++++ gcc/cp/call.c | 5 ++-- gcc/cp/class.c | 12 ++++----- gcc/cp/cp-tree.h | 1 - gcc/cp/decl.c | 31 +++++++++++++---------- gcc/cp/decl2.c | 12 ++++----- gcc/cp/pt.c | 16 ++++++------ gcc/cp/tree.c | 37 ---------------------------- gcc/cp/typeck.c | 4 +-- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/ext/altivec-1.C | 15 +++++++++++ gcc/tree.h | 1 + 14 files changed, 102 insertions(+), 77 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/altivec-1.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 440fcdc1c40..8563818e949 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2003-08-25 Mark Mitchell + + PR c++/8795 + * tree.h (build_method_type_directly): Declare. + * c-common.c (handle_vector_size_attributes): Handle METHOD_TYPEs. + (vector_size_helper): Likewise. + * tree.c (build_method_type_directly): New function. + (build_method_type): Use it. + 2003-08-24 Richard Henderson * config/i386.i386.c (ix86_return_in_memory): Reformat. Return true diff --git a/gcc/c-common.c b/gcc/c-common.c index 3089e5dbed8..b4151faf765 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -5086,6 +5086,7 @@ handle_vector_size_attribute (tree *node, tree name, tree args, while (POINTER_TYPE_P (type) || TREE_CODE (type) == FUNCTION_TYPE + || TREE_CODE (type) == METHOD_TYPE || TREE_CODE (type) == ARRAY_TYPE) type = TREE_TYPE (type); @@ -5216,12 +5217,19 @@ vector_size_helper (tree type, tree bottom) else if (TREE_CODE (type) == ARRAY_TYPE) { inner = vector_size_helper (TREE_TYPE (type), bottom); - outer = build_array_type (inner, TYPE_VALUES (type)); + outer = build_array_type (inner, TYPE_DOMAIN (type)); } else if (TREE_CODE (type) == FUNCTION_TYPE) { inner = vector_size_helper (TREE_TYPE (type), bottom); - outer = build_function_type (inner, TYPE_VALUES (type)); + outer = build_function_type (inner, TYPE_ARG_TYPES (type)); + } + else if (TREE_CODE (type) == METHOD_TYPE) + { + inner = vector_size_helper (TREE_TYPE (type), bottom); + outer = build_method_type_directly (TYPE_METHOD_BASETYPE (type), + inner, + TYPE_ARG_TYPES (type)); } else return bottom; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5ae0891f7c1..fc987c82631 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,22 @@ +2003-08-25 Mark Mitchell + + PR c++/8795 + * cp-tree.h (build_cplus_method_type): Remove. + * call.c (standard_conversion): Use build_method_type_directly + instead of build_cplus_method_type. + * class.c (build_clone): Likewise. + (adjust_clone_args): Likewise. + * decl.c (build_ptrmem_type): Likewise. + (grokdeclarator): Likewise. + (check_function_type): Likewise. + * decl2.c (grok_method_quals): Likewise. + (maybe_retrofit_in_chrg): Likewise. + * pt.c (copy_default_args_to_explicit_spec): Likewise. + (tsubst_function_type): Likewise. + (tsubst): Likewise. + * tree.c (build_cplus_method_type): Remove. + * typeck.c (merge_types): Use build_method_type_directly. + 2003-08-23 Kriang Lerdsuwanakij PR c++/3765 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 4bda8da36fc..8440344689a 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -758,8 +758,9 @@ standard_conversion (tree to, tree from, tree expr) return 0; from = cp_build_qualified_type (tbase, cp_type_quals (fbase)); - from = build_cplus_method_type (from, TREE_TYPE (fromfn), - TREE_CHAIN (TYPE_ARG_TYPES (fromfn))); + from = build_method_type_directly (from, + TREE_TYPE (fromfn), + TREE_CHAIN (TYPE_ARG_TYPES (fromfn))); from = build_ptrmemfunc_type (build_pointer_type (from)); conv = build_conv (PMEM_CONV, from, conv); } diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 302b714f30c..3cf161b1e30 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3833,9 +3833,9 @@ build_clone (tree fn, tree name) /* If this is subobject constructor or destructor, add the vtt parameter. */ TREE_TYPE (clone) - = build_cplus_method_type (basetype, - TREE_TYPE (TREE_TYPE (clone)), - parmtypes); + = build_method_type_directly (basetype, + TREE_TYPE (TREE_TYPE (clone)), + parmtypes); if (exceptions) TREE_TYPE (clone) = build_exception_variant (TREE_TYPE (clone), exceptions); @@ -4012,9 +4012,9 @@ adjust_clone_args (tree decl) clone_parms); TREE_TYPE (clone_parms) = TREE_TYPE (orig_clone_parms); } - type = build_cplus_method_type (basetype, - TREE_TYPE (TREE_TYPE (clone)), - clone_parms); + type = build_method_type_directly (basetype, + TREE_TYPE (TREE_TYPE (clone)), + clone_parms); if (exceptions) type = build_exception_variant (type, exceptions); TREE_TYPE (clone) = type; diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 025277e6fae..e1ad9df35e7 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4170,7 +4170,6 @@ extern tree build_min (enum tree_code, tree, extern tree build_min_nt (enum tree_code, ...); extern tree build_cplus_new (tree, tree); extern tree get_target_expr (tree); -extern tree build_cplus_method_type (tree, tree, tree); extern tree build_cplus_staticfn_type (tree, tree, tree); extern tree build_cplus_array_type (tree, tree); extern tree hash_tree_cons (tree, tree, tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index dc3495f42ef..d89ec9161c6 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -9259,9 +9259,9 @@ build_ptrmem_type (tree class_type, tree member_type) (class_type, cp_type_quals (TREE_TYPE (TREE_VALUE (arg_types))))); member_type - = build_cplus_method_type (class_type, - TREE_TYPE (member_type), - TREE_CHAIN (arg_types)); + = build_method_type_directly (class_type, + TREE_TYPE (member_type), + TREE_CHAIN (arg_types)); return build_ptrmemfunc_type (build_pointer_type (member_type)); } else @@ -10933,7 +10933,9 @@ grokdeclarator (tree declarator, else if (TREE_CODE (type) == FUNCTION_TYPE) { if (current_class_type == NULL_TREE || friendp) - type = build_cplus_method_type (ctype, TREE_TYPE (type), + type + = build_method_type_directly (ctype, + TREE_TYPE (type), TYPE_ARG_TYPES (type)); else { @@ -10975,8 +10977,9 @@ grokdeclarator (tree declarator, /* In this case, we will deal with it later. */ ; else if (TREE_CODE (type) == FUNCTION_TYPE) - type = build_cplus_method_type (ctype, TREE_TYPE (type), - TYPE_ARG_TYPES (type)); + type = build_method_type_directly (ctype, + TREE_TYPE (type), + TYPE_ARG_TYPES (type)); } } break; @@ -11412,8 +11415,9 @@ grokdeclarator (tree declarator, } } else if (staticp < 2) - type = build_cplus_method_type (ctype, TREE_TYPE (type), - TYPE_ARG_TYPES (type)); + type = build_method_type_directly (ctype, + TREE_TYPE (type), + TYPE_ARG_TYPES (type)); } /* Tell grokfndecl if it needs to set TREE_PUBLIC on the node. */ @@ -11649,8 +11653,9 @@ grokdeclarator (tree declarator, } } else if (TREE_CODE (type) == FUNCTION_TYPE && staticp < 2) - type = build_cplus_method_type (ctype, TREE_TYPE (type), - TYPE_ARG_TYPES (type)); + type = build_method_type_directly (ctype, + TREE_TYPE (type), + TYPE_ARG_TYPES (type)); /* Record presence of `static'. */ publicp = (ctype != NULL_TREE @@ -13317,9 +13322,9 @@ check_function_type (tree decl, tree current_function_parms) { tree ctype = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype))); TREE_TYPE (decl) - = build_cplus_method_type (ctype, - void_type_node, - FUNCTION_ARG_CHAIN (decl)); + = build_method_type_directly (ctype, + void_type_node, + FUNCTION_ARG_CHAIN (decl)); } else TREE_TYPE (decl) diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 4eb5c0e6dae..d74f2907424 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -154,10 +154,10 @@ grok_method_quals (tree ctype, tree function, tree quals) ? "member function" : "type"); ctype = cp_build_qualified_type (ctype, type_quals); - fntype = build_cplus_method_type (ctype, TREE_TYPE (fntype), - (TREE_CODE (fntype) == METHOD_TYPE - ? TREE_CHAIN (TYPE_ARG_TYPES (fntype)) - : TYPE_ARG_TYPES (fntype))); + fntype = build_method_type_directly (ctype, TREE_TYPE (fntype), + (TREE_CODE (fntype) == METHOD_TYPE + ? TREE_CHAIN (TYPE_ARG_TYPES (fntype)) + : TYPE_ARG_TYPES (fntype))); if (raises) fntype = build_exception_variant (fntype, raises); @@ -309,8 +309,8 @@ maybe_retrofit_in_chrg (tree fn) TREE_CHAIN (DECL_ARGUMENTS (fn)) = parms; /* And rebuild the function type. */ - fntype = build_cplus_method_type (basetype, TREE_TYPE (TREE_TYPE (fn)), - arg_types); + fntype = build_method_type_directly (basetype, TREE_TYPE (TREE_TYPE (fn)), + arg_types); if (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn))) fntype = build_exception_variant (fntype, TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn))); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d6ea8cc8203..45bec17520c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1382,9 +1382,9 @@ copy_default_args_to_explicit_spec (tree decl) TREE_VALUE (in_charge), new_spec_types); - new_type = build_cplus_method_type (object_type, - TREE_TYPE (old_type), - new_spec_types); + new_type = build_method_type_directly (object_type, + TREE_TYPE (old_type), + new_spec_types); } else new_type = build_function_type (TREE_TYPE (old_type), @@ -6293,8 +6293,8 @@ tsubst_function_type (tree t, return error_mark_node; } - fntype = build_cplus_method_type (r, return_type, TREE_CHAIN - (arg_types)); + fntype = build_method_type_directly (r, return_type, + TREE_CHAIN (arg_types)); } fntype = cp_build_qualified_type_real (fntype, TYPE_QUALS (t), complain); fntype = build_type_attribute_variant (fntype, TYPE_ATTRIBUTES (t)); @@ -6761,9 +6761,9 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) */ tree method_type; - method_type = build_cplus_method_type (TYPE_MAIN_VARIANT (r), - TREE_TYPE (type), - TYPE_ARG_TYPES (type)); + method_type = build_method_type_directly (TYPE_MAIN_VARIANT (r), + TREE_TYPE (type), + TYPE_ARG_TYPES (type)); return build_ptrmemfunc_type (build_pointer_type (method_type)); } else diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index cd1ea240c49..532d8b97837 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -373,43 +373,6 @@ get_target_expr (tree init) } -/* Construct, lay out and return the type of methods belonging to class - BASETYPE and whose arguments are described by ARGTYPES and whose values - are described by RETTYPE. If each type exists already, reuse it. */ - -tree -build_cplus_method_type (tree basetype, tree rettype, tree argtypes) -{ - register tree t; - tree ptype; - int hashcode; - - /* Make a node of the sort we want. */ - t = make_node (METHOD_TYPE); - - TYPE_METHOD_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype); - TREE_TYPE (t) = rettype; - ptype = build_pointer_type (basetype); - - /* The actual arglist for this function includes a "hidden" argument - which is "this". Put it into the list of argument types. */ - argtypes = tree_cons (NULL_TREE, ptype, argtypes); - TYPE_ARG_TYPES (t) = argtypes; - TREE_SIDE_EFFECTS (argtypes) = 1; /* Mark first argtype as "artificial". */ - - /* If we already have such a type, use the old one and free this one. - Note that it also frees up the above cons cell if found. */ - hashcode = TYPE_HASH (basetype) + TYPE_HASH (rettype) + - type_hash_list (argtypes); - - t = type_hash_canon (hashcode, t); - - if (!COMPLETE_TYPE_P (t)) - layout_type (t); - - return t; -} - static tree build_cplus_array_type_1 (tree elt_type, tree index_type) { diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index ed9b6b9450f..65ce8a06c6b 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -708,8 +708,8 @@ merge_types (tree t1, tree t2) t2 = build_function_type (TREE_TYPE (t2), TREE_CHAIN (TYPE_ARG_TYPES (t2))); t3 = merge_types (t1, t2); - t3 = build_cplus_method_type (basetype, TREE_TYPE (t3), - TYPE_ARG_TYPES (t3)); + t3 = build_method_type_directly (basetype, TREE_TYPE (t3), + TYPE_ARG_TYPES (t3)); t1 = build_exception_variant (t3, raises); break; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5ed33546919..1a6f848121e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-08-25 Mark Mitchell + + PR c++/8795 + * g++.dg/ext/altivec-1.C: New test. + 2003-08-24 Richard Henderson * g++.dg/eh/simd-2.C: Add -w for x86. diff --git a/gcc/testsuite/g++.dg/ext/altivec-1.C b/gcc/testsuite/g++.dg/ext/altivec-1.C new file mode 100644 index 00000000000..b7e3af30009 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/altivec-1.C @@ -0,0 +1,15 @@ +// { dg-do compile { target powerpc-*-* } } */ +/* { dg-options "-maltivec" } */ + +#include + +int main() +{ + return 0; +} + +class F32vec4 { +public: + vector float val; + vector float operator++(void) { return val;} +}; diff --git a/gcc/tree.h b/gcc/tree.h index 7bc44c7ce84..6bceb7cc1d4 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -2107,6 +2107,7 @@ extern tree build_index_2_type (tree, tree); extern tree build_array_type (tree, tree); extern tree build_function_type (tree, tree); extern tree build_function_type_list (tree, ...); +extern tree build_method_type_directly (tree, tree, tree); extern tree build_method_type (tree, tree); extern tree build_offset_type (tree, tree); extern tree build_complex_type (tree); -- 2.30.2