diff options
author | Jason Merrill <jason@redhat.com> | 2006-08-22 14:27:26 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2006-08-22 14:27:26 -0400 |
commit | 8e30dcf34530478bd343bce3771bb0c0f979ed73 (patch) | |
tree | 6306d10d6d16b88e1187af65ac4605d5caa13f87 /gcc | |
parent | 6d3c5221567ee9a9a75ef9388ebfa42b9bb566f6 (diff) | |
download | gcc-8e30dcf34530478bd343bce3771bb0c0f979ed73.zip gcc-8e30dcf34530478bd343bce3771bb0c0f979ed73.tar.gz gcc-8e30dcf34530478bd343bce3771bb0c0f979ed73.tar.bz2 |
re PR c++/28659 (ICE (segfault) while compiling kdelibs 4.0 snapshot)
PR c++/28659
* typeck.c (merge_types): If either of the types have the right
attributes, return that one.
* tree.c (cp_build_type_attribute_variant): Make sure we aren't
doing this to class types.
* typeck.c (original_type): Deal with type quals properly.
From-SVN: r116329
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/tree.c | 4 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/attrib26.C | 14 |
4 files changed, 37 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fa7d6bc..22dbdba 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2006-08-22 Jason Merrill <jason@redhat.com> + + PR c++/28659 + * typeck.c (merge_types): If either of the types have the right + attributes, return that one. + + * tree.c (cp_build_type_attribute_variant): Make sure we aren't + doing this to class types. + * typeck.c (original_type): Deal with type quals properly. + 2006-08-21 Jason Merrill <jason@redhat.com> PR c++/27115 diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index bb579a6..1cedec5 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1936,6 +1936,10 @@ cp_build_type_attribute_variant (tree type, tree attributes) != TYPE_RAISES_EXCEPTIONS (type))) new_type = build_exception_variant (new_type, TYPE_RAISES_EXCEPTIONS (type)); + + /* Making a new main variant of a class type is broken. */ + gcc_assert (!CLASS_TYPE_P (type) || new_type == type); + return new_type; } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index f337328..c07a78d 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -228,6 +228,7 @@ commonparms (tree p1, tree p2) static tree original_type (tree t) { + int quals = cp_type_quals (t); while (t != error_mark_node && TYPE_NAME (t) != NULL_TREE) { @@ -239,7 +240,7 @@ original_type (tree t) break; t = x; } - return t; + return cp_build_qualified_type (t, quals); } /* T1 and T2 are arithmetic or enumeration types. Return the type @@ -730,7 +731,13 @@ merge_types (tree t1, tree t2) default:; } - return cp_build_type_attribute_variant (t1, attributes); + + if (attribute_list_equal (TYPE_ATTRIBUTES (t1), attributes)) + return t1; + else if (attribute_list_equal (TYPE_ATTRIBUTES (t2), attributes)) + return t2; + else + return cp_build_type_attribute_variant (t1, attributes); } /* Return the common type of two types. diff --git a/gcc/testsuite/g++.dg/ext/attrib26.C b/gcc/testsuite/g++.dg/ext/attrib26.C new file mode 100644 index 0000000..dedf43a --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib26.C @@ -0,0 +1,14 @@ +// PR c++/28659 +// The attribute was causing us to get confused in merge_types when +// combining the template type with an uninstantiated version. + +template<class T> +struct __attribute__((aligned(1))) A +{ + A& operator=(const A &t); +}; + +template<class T> +A<T>& A<T>::operator=(const A<T> &t) +{ +} |