This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/80244, ICE with attribute in template alias
- From: Marek Polacek <polacek at redhat dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Wed, 5 Apr 2017 23:37:32 +0200
- Subject: C++ PATCH for c++/80244, ICE with attribute in template alias
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=polacek at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D90BDA3B6B
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D90BDA3B6B
We crashed on this testcase because UNDERLYING_TYPE, a C++-specific code,
got into layout_type. It wound up there via strip_typedefs -> ... ->
build_type_attribute_qual_variant and that calls type_hash_canon which
has
7129 /* The TYPE_ALIGN field of a type is set by layout_type(), so we
7130 must call that routine before comparing TYPE_ALIGNs. */
7131 layout_type (type);
I think best would be to fix this in strip_typedefs, much like how we handle
some other _TYPE nodes.
I checked in gdb what results we get and it seems that strip_typedefs now
returns what I would expect it to, i.e. an UNDERLYING_TYPE with the attribute
removed.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2017-04-05 Marek Polacek <polacek@redhat.com>
PR c++/80244 - ICE with attribute in template alias.
* tree.c (strip_typedefs): Handle UNDERLYING_TYPE.
* g++.dg/cpp0x/alias-decl-59.C: New test.
diff --git gcc/cp/tree.c gcc/cp/tree.c
index 2757af6..1f0e422 100644
--- gcc/cp/tree.c
+++ gcc/cp/tree.c
@@ -1531,6 +1531,10 @@ strip_typedefs (tree t, bool *remove_attributes)
DECLTYPE_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P (t),
tf_none));
break;
+ case UNDERLYING_TYPE:
+ type = strip_typedefs (UNDERLYING_TYPE_TYPE (t), remove_attributes);
+ result = finish_underlying_type (type);
+ break;
default:
break;
}
diff --git gcc/testsuite/g++.dg/cpp0x/alias-decl-59.C gcc/testsuite/g++.dg/cpp0x/alias-decl-59.C
index e69de29..1f5e94f 100644
--- gcc/testsuite/g++.dg/cpp0x/alias-decl-59.C
+++ gcc/testsuite/g++.dg/cpp0x/alias-decl-59.C
@@ -0,0 +1,11 @@
+// PR c++/80244
+// { dg-do compile { target c++11 } }
+
+template<typename>
+struct A {};
+
+template<typename T>
+using B = A<__underlying_type(T) [[gnu::aligned(4)]]>; // { dg-warning "ignoring attributes on template argument" }
+
+template<typename T>
+using B = A<__underlying_type(T) [[gnu::packed]]>; // { dg-warning "ignoring attributes on template argument" }
Marek