Jason,
Bug 71710 is a crash on 'decltype (a)', where 'a' is a FIELD_DECL wth
dependent type. finish_class_member_access_expr barfs on that. The
earlier sequence of if..elses has a check for FIELD_DECL, but that's in
the shadow of a type_dependent_expression_p (object) check. The field's
type is the main template type, so it does have a type dependent object.
But there's no reason it shouldn't go through the usual
finish_non_static_data_member processing.
Fixed by moving the FIELD_DECL check earlier.
ok?
nathan
--
Nathan Sidwell
2017-01-23 Nathan Sidwell <nat...@acm.org>
PR c++/71710 - template using directive of field
* pt.c (tsubst_copy_and_build [COMPONENT_REF]): Move FIELD_DECL
check earlier.
PR C++/71710
* g++.dg/template/pr71710.C: New.
Index: cp/pt.c
===================================================================
--- cp/pt.c (revision 244815)
+++ cp/pt.c (working copy)
@@ -17470,7 +17470,14 @@ tsubst_copy_and_build (tree t,
if (member == error_mark_node)
RETURN (error_mark_node);
- if (type_dependent_expression_p (object))
+ if (TREE_CODE (member) == FIELD_DECL)
+ {
+ r = finish_non_static_data_member (member, object, NULL_TREE);
+ if (TREE_CODE (r) == COMPONENT_REF)
+ REF_PARENTHESIZED_P (r) = REF_PARENTHESIZED_P (t);
+ RETURN (r);
+ }
+ else if (type_dependent_expression_p (object))
/* We can't do much here. */;
else if (!CLASS_TYPE_P (object_type))
{
@@ -17535,13 +17542,6 @@ tsubst_copy_and_build (tree t,
}
RETURN (error_mark_node);
}
- else if (TREE_CODE (member) == FIELD_DECL)
- {
- r = finish_non_static_data_member (member, object, NULL_TREE);
- if (TREE_CODE (r) == COMPONENT_REF)
- REF_PARENTHESIZED_P (r) = REF_PARENTHESIZED_P (t);
- RETURN (r);
- }
r = finish_class_member_access_expr (object, member,
/*template_p=*/false,
Index: testsuite/g++.dg/template/pr71710.C
===================================================================
--- testsuite/g++.dg/template/pr71710.C (revision 0)
+++ testsuite/g++.dg/template/pr71710.C (working copy)
@@ -0,0 +1,10 @@
+// { dg-do compile { target c++11 } }
+// PR C++/71710 ICE with decltype & using
+
+template < typename > struct A
+{
+ A a;
+ template < int > using B = decltype (a);
+ B < 0 > b;
+ template < int C > B < C > foo ();
+};