Hi,
On 13/01/2017 18:33, Jason Merrill wrote:
On Fri, Jan 13, 2017 at 11:42 AM, Paolo Carlini
<paolo.carl...@oracle.com> wrote:
Hi,
On 13/01/2017 15:51, Nathan Sidwell wrote:
On 01/13/2017 09:45 AM, Paolo Carlini wrote:
Hi,
in this error recovery issue get_underlying_template crashes when
TYPE_TEMPLATE_INFO_MAYBE_ALIAS is applied to a null orig_type. Simply
checking for that condition appears to solve the issue in a
straightforward way. Tested x86_64-linux.
Wouldn't it be better if a scrogged alias got error_mark_node as the
underlying type? (I have no idea whether that's an easy thing to
accomplish)
Your reply, Nathan, led me to investigate where exactly DECL_ORIGINAL_TYPE
becomes null, and turns out that in tsubst_decl we have code actively doing
that. That same code, a few lines below, only sets TYPE_DEPENDENT_P_VALID to
false if type != error_mark_node. I cannot say to fully understand yet all
the details, but certainly the patchlet below also passes testing. Do you
have comments about this too?
The clearing of DECL_ORIGINAL_TYPE is to allow set_underlying_type to
then set it to something more appropriate. That function currently
avoids setting DECL_ORIGINAL_TYPE to error_mark_node, perhaps that
should be changed.
I see, thanks a lot. The below passes testing on x86_64-linux.
Paolo.
///////////////////////
Index: c-family/c-common.c
===================================================================
--- c-family/c-common.c (revision 244405)
+++ c-family/c-common.c (working copy)
@@ -7419,16 +7419,18 @@ set_underlying_type (tree x)
if (TYPE_NAME (TREE_TYPE (x)) == 0)
TYPE_NAME (TREE_TYPE (x)) = x;
}
- else if (TREE_TYPE (x) != error_mark_node
- && DECL_ORIGINAL_TYPE (x) == NULL_TREE)
+ else if (DECL_ORIGINAL_TYPE (x) == NULL_TREE)
{
tree tt = TREE_TYPE (x);
DECL_ORIGINAL_TYPE (x) = tt;
- tt = build_variant_type_copy (tt);
- TYPE_STUB_DECL (tt) = TYPE_STUB_DECL (DECL_ORIGINAL_TYPE (x));
- TYPE_NAME (tt) = x;
- TREE_USED (tt) = TREE_USED (x);
- TREE_TYPE (x) = tt;
+ if (tt != error_mark_node)
+ {
+ tt = build_variant_type_copy (tt);
+ TYPE_STUB_DECL (tt) = TYPE_STUB_DECL (DECL_ORIGINAL_TYPE (x));
+ TYPE_NAME (tt) = x;
+ TREE_USED (tt) = TREE_USED (x);
+ TREE_TYPE (x) = tt;
+ }
}
}
Index: testsuite/g++.dg/cpp0x/pr71737.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr71737.C (revision 0)
+++ testsuite/g++.dg/cpp0x/pr71737.C (working copy)
@@ -0,0 +1,13 @@
+// PR c++/78765
+// { dg-do compile { target c++11 } }
+
+template <template <typename ...> class TT>
+struct quote {
+ template <typename ...Ts>
+ using apply = TT<Ts...>; // { dg-error "pack expansion" }
+};
+
+template <typename>
+using to_int_t = int;
+
+using t = quote<quote<to_int_t>::apply>::apply<int>;