diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-04-24 16:29:40 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-04-24 16:29:40 +0000 |
commit | d991e6e8883396dca4970a3c5bef47c68128550e (patch) | |
tree | 2b27f4fd6f66ac33d3f929db98431f16e8e12dd9 /gcc/cp | |
parent | 6c3755b57664ca16bc721677a8445ccd6146461a (diff) | |
download | gcc-d991e6e8883396dca4970a3c5bef47c68128550e.tar.gz |
PR c++/35758
* c-common.c (handle_vector_size_attribute): Call
lang_hooks.types.reconstruct_complex_type instead of
reconstruct_complex_type.
* config/rs6000/rs6000.c (rs6000_handle_altivec_attribute): Likewise.
* config/spu/spu.c (spu_handle_vector_attribute): Likewise.
* langhooks.h (struct lang_hooks_for_types): Add
reconstruct_complex_type hook.
* langhooks-def.h (LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE): Define.
(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add it.
* cp-tree.h (cp_reconstruct_complex_type): New prototype.
* cp-objcp-common.h (LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE): Define.
* decl2.c (is_late_template_attribute): Only make vector_size
late tmpl attribute if argument is type or value dependent.
(cp_reconstruct_complex_type): New function.
* g++.dg/ext/vector14.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134639 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/cp-objcp-common.h | 2 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 63 |
4 files changed, 70 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cb7e4226dce..9c116c31ef2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2008-04-24 Jakub Jelinek <jakub@redhat.com> + + PR c++/35758 + * cp-tree.h (cp_reconstruct_complex_type): New prototype. + * cp-objcp-common.h (LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE): Define. + * decl2.c (is_late_template_attribute): Only make vector_size + late tmpl attribute if argument is type or value dependent. + (cp_reconstruct_complex_type): New function. + 2008-04-24 Richard Guenther <rguenther@suse.de> * typeck.c (cp_build_function_call): Call diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h index a15b6b47a4f..b2b8405fccd 100644 --- a/gcc/cp/cp-objcp-common.h +++ b/gcc/cp/cp-objcp-common.h @@ -125,6 +125,8 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t, #define LANG_HOOKS_TYPE_PROMOTES_TO cxx_type_promotes_to #undef LANG_HOOKS_REGISTER_BUILTIN_TYPE #define LANG_HOOKS_REGISTER_BUILTIN_TYPE c_register_builtin_type +#undef LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE +#define LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE cp_reconstruct_complex_type #undef LANG_HOOKS_TO_TARGET_CHARSET #define LANG_HOOKS_TO_TARGET_CHARSET c_common_to_target_charset #undef LANG_HOOKS_GIMPLIFY_EXPR diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 27212c3c85c..8d223bc6f27 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4282,6 +4282,7 @@ extern tree grokfield (const cp_declarator *, cp_decl_specifier_seq *, tree, bool, tree, tree); extern tree grokbitfield (const cp_declarator *, cp_decl_specifier_seq *, tree); +extern tree cp_reconstruct_complex_type (tree, tree); extern void cplus_decl_attributes (tree *, tree, int); extern void finish_anon_union (tree); extern void cp_write_global_declarations (void); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 078ca99e6f8..41af32faec4 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -991,11 +991,8 @@ is_late_template_attribute (tree attr, tree decl) /* Unknown attribute. */ return false; - /* Attribute vector_size handling wants to dive into the back end array - building code, which breaks during template processing. */ - if (is_attribute_p ("vector_size", name) - /* Attribute weak handling wants to write out assembly right away. */ - || is_attribute_p ("weak", name)) + /* Attribute weak handling wants to write out assembly right away. */ + if (is_attribute_p ("weak", name)) return true; /* If any of the arguments are dependent expressions, we can't evaluate @@ -1120,6 +1117,62 @@ save_template_attributes (tree *attr_p, tree *decl_p) } } +/* Like reconstruct_complex_type, but handle also template trees. */ + +tree +cp_reconstruct_complex_type (tree type, tree bottom) +{ + tree inner, outer; + + if (TREE_CODE (type) == POINTER_TYPE) + { + inner = cp_reconstruct_complex_type (TREE_TYPE (type), bottom); + outer = build_pointer_type_for_mode (inner, TYPE_MODE (type), + TYPE_REF_CAN_ALIAS_ALL (type)); + } + else if (TREE_CODE (type) == REFERENCE_TYPE) + { + inner = cp_reconstruct_complex_type (TREE_TYPE (type), bottom); + outer = build_reference_type_for_mode (inner, TYPE_MODE (type), + TYPE_REF_CAN_ALIAS_ALL (type)); + } + else if (TREE_CODE (type) == ARRAY_TYPE) + { + inner = cp_reconstruct_complex_type (TREE_TYPE (type), bottom); + outer = build_cplus_array_type (inner, TYPE_DOMAIN (type)); + /* Don't call cp_build_qualified_type on ARRAY_TYPEs, the + element type qualification will be handled by the recursive + cp_reconstruct_complex_type call and cp_build_qualified_type + for ARRAY_TYPEs changes the element type. */ + return outer; + } + else if (TREE_CODE (type) == FUNCTION_TYPE) + { + inner = cp_reconstruct_complex_type (TREE_TYPE (type), bottom); + outer = build_function_type (inner, TYPE_ARG_TYPES (type)); + } + else if (TREE_CODE (type) == METHOD_TYPE) + { + inner = cp_reconstruct_complex_type (TREE_TYPE (type), bottom); + /* The build_method_type_directly() routine prepends 'this' to argument list, + so we must compensate by getting rid of it. */ + outer + = build_method_type_directly + (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (type))), + inner, + TREE_CHAIN (TYPE_ARG_TYPES (type))); + } + else if (TREE_CODE (type) == OFFSET_TYPE) + { + inner = cp_reconstruct_complex_type (TREE_TYPE (type), bottom); + outer = build_offset_type (TYPE_OFFSET_BASETYPE (type), inner); + } + else + return bottom; + + return cp_build_qualified_type (outer, TYPE_QUALS (type)); +} + /* Like decl_attributes, but handle C++ complexity. */ void |