diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-12-18 18:52:13 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-12-18 18:52:13 +0100 |
commit | 58cc7d798875aee798ba6a5b07c9324717160a2c (patch) | |
tree | 8d372d57995156dce5e48bf2bddbd29ebf1e01fe | |
parent | 82cfbd01e4870097de5f9ccdae900141b382d70e (diff) | |
download | gcc-58cc7d798875aee798ba6a5b07c9324717160a2c.zip gcc-58cc7d798875aee798ba6a5b07c9324717160a2c.tar.gz gcc-58cc7d798875aee798ba6a5b07c9324717160a2c.tar.bz2 |
re PR c++/83300 (Segmentation fault with template and __attribute__((vector_size (sizeof(int) * N)));)
PR c++/83300
* decl2.c (save_template_attributes): Add flags argument, if
not ATTR_FLAG_TYPE_IN_PLACE, *decl_p is a type and we want to
modify TYPE_ATTRIBUTES, add them on type attribute variant.
* g++.dg/ext/vector33.C: New test.
From-SVN: r255783
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 19 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/vector33.C | 10 |
4 files changed, 38 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3885e56..b6e782a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2017-12-18 Jakub Jelinek <jakub@redhat.com> + + PR c++/83300 + * decl2.c (save_template_attributes): Add flags argument, if + not ATTR_FLAG_TYPE_IN_PLACE, *decl_p is a type and we want to + modify TYPE_ATTRIBUTES, add them on type attribute variant. + 2017-12-18 Nathan Sidwell <nathan@acm.org> PR c++/59930 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 89a940a..5a87f30 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1244,7 +1244,7 @@ splice_template_attributes (tree *attr_p, tree decl) 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 *q; @@ -1265,7 +1265,20 @@ save_template_attributes (tree *attr_p, tree *decl_p) /* Merge the late attributes at the beginning with the attribute list. */ late_attrs = merge_attributes (late_attrs, *q); - *q = late_attrs; + if (*q != late_attrs + && !DECL_P (*decl_p) + && !(flags & ATTR_FLAG_TYPE_IN_PLACE)) + { + if (!dependent_type_p (*decl_p)) + *decl_p = cp_build_type_attribute_variant (*decl_p, late_attrs); + else + { + *decl_p = build_variant_type_copy (*decl_p); + TYPE_ATTRIBUTES (*decl_p) = late_attrs; + } + } + else + *q = late_attrs; if (!DECL_P (*decl_p) && *decl_p == TYPE_MAIN_VARIANT (*decl_p)) { @@ -1466,7 +1479,7 @@ cplus_decl_attributes (tree *decl, tree attributes, int flags) if (check_for_bare_parameter_packs (attributes)) return; - save_template_attributes (&attributes, decl); + save_template_attributes (&attributes, decl, flags); } cp_check_const_attributes (attributes); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 57ef599..0963f4e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-12-18 Jakub Jelinek <jakub@redhat.com> + + PR c++/83300 + * g++.dg/ext/vector33.C: New test. + 2017-12-18 Marek Polacek <polacek@redhat.com> PR middle-end/83463 diff --git a/gcc/testsuite/g++.dg/ext/vector33.C b/gcc/testsuite/g++.dg/ext/vector33.C new file mode 100644 index 0000000..f502532 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vector33.C @@ -0,0 +1,10 @@ +// PR c++/83300 +// { dg-do compile { target c++11 } } + +template<int N> +using T = int __attribute__((vector_size (sizeof(int) * N))); + +void +f (T<4>) +{ +} |