From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 507 invoked by alias); 7 Apr 2008 10:53:30 -0000 Received: (qmail 356 invoked by uid 48); 7 Apr 2008 10:52:44 -0000 Date: Mon, 07 Apr 2008 10:53:00 -0000 Message-ID: <20080407105244.355.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/35758] [4.3/4.4 Regression] vector_size attribute lost in function arguments for templates In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jakub at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-04/txt/msg00543.txt.bz2 ------- Comment #15 from jakub at gcc dot gnu dot org 2008-04-07 10:52 ------- I've tried the first step - putting the attributes that require type to TYPE_ATTRIBUTES rather than DECL_ATTRIBUTES, see below. Unfortunately tsubst doesn't call apply_late_template_attributes in that case (the only place which calls it on TYPE_ATTRIBUTES is instantiate_class_template on the fn type). So I'm giving up on this. The patch was: --- decl2.c.jj 2008-03-25 23:31:25.000000000 +0100 +++ decl2.c 2008-04-07 12:40:19.000000000 +0200 @@ -1041,12 +1041,13 @@ is_late_template_attribute (tree attr, t at instantiation time. */ static tree -splice_template_attributes (tree *attr_p, tree decl) +splice_template_attributes (tree *attr_p, tree *type_attr_p, tree decl) { tree *p = attr_p; tree late_attrs = NULL_TREE; tree *q = &late_attrs; + *type_attr_p = NULL_TREE; if (!p) return NULL_TREE; @@ -1054,11 +1055,28 @@ splice_template_attributes (tree *attr_p { if (is_late_template_attribute (*p, decl)) { - ATTR_IS_DEPENDENT (*p) = 1; - *q = *p; + const struct attribute_spec *spec + = lookup_attribute_spec (TREE_PURPOSE (*p)); + + /* Put attributes that require type into TYPE_ATTRIBUTES, + rather than DECL_ATTRIBUTES. */ + if (DECL_P (decl) + && spec + && spec->type_required + && !CLASS_TYPE_P (TREE_TYPE (decl))) + { + *type_attr_p = *p; + type_attr_p = &TREE_CHAIN (*type_attr_p); + *type_attr_p = NULL_TREE; + } + else + { + ATTR_IS_DEPENDENT (*p) = 1; + *q = *p; + q = &TREE_CHAIN (*q); + *q = NULL_TREE; + } *p = TREE_CHAIN (*p); - q = &TREE_CHAIN (*q); - *q = NULL_TREE; } else p = &TREE_CHAIN (*p); @@ -1071,12 +1089,17 @@ splice_template_attributes (tree *attr_p DECL_P. */ static void -save_template_attributes (tree *attr_p, tree *decl_p) +save_template_attributes (tree *attr_p, tree *decl_p, int flags) { - tree late_attrs = splice_template_attributes (attr_p, *decl_p); + tree type_attrs; + tree late_attrs = splice_template_attributes (attr_p, &type_attrs, *decl_p); tree *q; tree old_attrs = NULL_TREE; + if (type_attrs) + cplus_decl_attributes (&TREE_TYPE (*decl_p), type_attrs, + flags & ~(int) ATTR_FLAG_TYPE_IN_PLACE); + if (!late_attrs) return; @@ -1135,7 +1158,7 @@ cplus_decl_attributes (tree *decl, tree if (check_for_bare_parameter_packs (attributes)) return; - save_template_attributes (&attributes, decl); + save_template_attributes (&attributes, decl, flags); if (attributes == NULL_TREE) return; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35758