From 024da3094e3bac0ed63bf0955e70557e61fc17f9 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 8 Oct 2014 16:27:11 -0400 Subject: [PATCH] re PR c++/63485 (ICE: canonical types differ for identical types A::type and const char_type [3]) PR c++/63485 * tree.c (build_cplus_array_type): Look for a type with no typedef-name or attributes. From-SVN: r216012 --- gcc/cp/ChangeLog | 4 ++ gcc/cp/tree.c | 4 +- gcc/testsuite/g++.dg/template/array29.C | 56 +++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/array29.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c70de7e22ed..975193d6a12 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2014-10-08 Jason Merrill + PR c++/63485 + * tree.c (build_cplus_array_type): Look for a type with no + typedef-name or attributes. + * call.c (call_copy_ctor): New. (build_over_call): Use it to avoid infinite recursion on invalid code. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index cfb0ed8c299..5b11d5cc8f0 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -853,7 +853,9 @@ build_cplus_array_type (tree elt_type, tree index_type) { tree m = t; for (t = m; t; t = TYPE_NEXT_VARIANT (t)) - if (TREE_TYPE (t) == elt_type) + if (TREE_TYPE (t) == elt_type + && TYPE_NAME (t) == NULL_TREE + && TYPE_ATTRIBUTES (t) == NULL_TREE) break; if (!t) { diff --git a/gcc/testsuite/g++.dg/template/array29.C b/gcc/testsuite/g++.dg/template/array29.C new file mode 100644 index 00000000000..e43cb9d965a --- /dev/null +++ b/gcc/testsuite/g++.dg/template/array29.C @@ -0,0 +1,56 @@ +// PR c++/63485 + +template struct A +{ + typedef C type; +}; +template class B +{ +}; +template void as_literal (Range &); +template struct C +{ + typedef wchar_t char_type; + const char_type on_full_year_placeholder[3]; + void + on_extended_iso_date () + { + B::type> a; + as_literal (on_full_year_placeholder); + } +}; +template struct date_time_format_parser_callback : C +{ +}; +template struct D +{ + typedef typename BaseT::char_type char_type; + char_type + parse (const char_type *, const char_type *, + typename BaseT::callback_type p3) + { + p3.on_extended_iso_date (); + } +}; +struct F +{ + typedef date_time_format_parser_callback callback_type; + typedef wchar_t char_type; +}; +template +void +parse_format (CharT *p1, ParserT p2, CallbackT p3) +{ + CharT p = p2.parse (&p, p1, p3); +} +template +void +parse_date_time_format (const CharT *, const CharT *p2, + date_time_format_parser_callback &p3) +{ + D b; + parse_format (p2, b, p3); +} +template void +parse_date_time_format (const wchar_t *, const wchar_t *, + date_time_format_parser_callback &); -- 2.30.2