From 9f7fb685d9173285be6507805ced732d360c09be Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 29 Apr 2015 16:51:05 -0400 Subject: [PATCH] re PR c++/50800 (Internal compiler error in finish_member_declarations, possibly related to may_alias attribute) PR c++/50800 * tree.c (apply_identity_attributes): Fix handling of classes. From-SVN: r222591 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/tree.c | 7 +++++++ gcc/testsuite/g++.dg/cpp0x/alignas3.C | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9442faa9c40..d78b22f1955 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-04-29 Jason Merrill + + PR c++/50800 + * tree.c (apply_identity_attributes): Fix handling of classes. + 2015-04-29 Thomas Schwinge * parser.c (cp_parser_oacc_enter_exit_data): Use diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index d00f0d7eab1..ec9be8c2bc4 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1187,6 +1187,13 @@ apply_identity_attributes (tree result, tree attribs, bool *remove_attributes) tree new_attribs = NULL_TREE; tree *p = &new_attribs; + if (OVERLOAD_TYPE_P (result)) + { + /* On classes and enums all attributes are ingrained. */ + gcc_assert (attribs == TYPE_ATTRIBUTES (result)); + return result; + } + for (tree a = attribs; a; a = TREE_CHAIN (a)) { const attribute_spec *as diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas3.C b/gcc/testsuite/g++.dg/cpp0x/alignas3.C new file mode 100644 index 00000000000..aa62e5afb2d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alignas3.C @@ -0,0 +1,20 @@ +// PR c++/50800 +// { dg-do compile { target c++11 } } + +template struct A; +template struct A<_Up *> { typedef _Up type; }; +template struct B { typedef typename A::type type; }; +template struct C; +template struct C { + typedef typename B::type SimpleType; +}; +template struct D { typedef int ret_type; }; +template struct F { + typedef typename D::SimpleType>::ret_type ret_type; +}; +template typename F::ret_type cast(Y &); +class CompoundStmt; +class alignas(8) Stmt { + Stmt *Children[1]; + CompoundStmt *getBlock() const { cast(Children[0]); } +}; -- 2.30.2