* [C++ PATCH] 71406, 77508 scoped template_ids
@ 2017-01-23 19:18 Nathan Sidwell
2017-01-23 20:19 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Sidwell @ 2017-01-23 19:18 UTC (permalink / raw)
To: Jason Merrill; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 372 bytes --]
This patch fixes 71406 and 77508, which are both ICEs dealing with
'X::Foo<...>'. finish_class_member_access_expr wasn't prepared to
handle SCOPE_REF (TEMPLATE_ID_EXPR (...)), which is what it was being
fed. Fixed by moving the SCOPE_REF splitting to before the
TEMPLATE_ID_EXPR handling, but leaving the scope checking where it was.
ok?
nathan
--
Nathan Sidwell
[-- Attachment #2: tp-71406.diff --]
[-- Type: text/x-patch, Size: 2655 bytes --]
2017-01-23 Nathan Sidwell <nathan@acm.org>
PR c++/71406 - ICE with scope-ref'd template id exprs
PR c++/77508
* typeck.c (finish_class_member_access_expr): Break up SCOPE_REF
before breaking up TEMPLATE_ID_EXPR.
PR c++/71406
PR c++/77508
* g++.dg/template/pr71406.C: New.
Index: cp/typeck.c
===================================================================
--- cp/typeck.c (revision 244819)
+++ cp/typeck.c (working copy)
@@ -2730,19 +2730,9 @@ finish_class_member_access_expr (cp_expr
{
bool is_template_id = false;
tree template_args = NULL_TREE;
- tree scope;
+ tree scope = NULL_TREE;
- if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
- {
- is_template_id = true;
- template_args = TREE_OPERAND (name, 1);
- name = TREE_OPERAND (name, 0);
-
- if (TREE_CODE (name) == OVERLOAD)
- name = DECL_NAME (get_first_fn (name));
- else if (DECL_P (name))
- name = DECL_NAME (name);
- }
+ access_path = object_type;
if (TREE_CODE (name) == SCOPE_REF)
{
@@ -2761,9 +2751,25 @@ finish_class_member_access_expr (cp_expr
scope, name, object_type);
return error_mark_node;
}
+ }
+
+ if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
+ {
+ is_template_id = true;
+ template_args = TREE_OPERAND (name, 1);
+ name = TREE_OPERAND (name, 0);
+ if (TREE_CODE (name) == OVERLOAD)
+ name = DECL_NAME (get_first_fn (name));
+ else if (DECL_P (name))
+ name = DECL_NAME (name);
+ }
+
+ if (scope)
+ {
if (TREE_CODE (scope) == ENUMERAL_TYPE)
{
+ gcc_assert (!is_template_id);
/* Looking up a member enumerator (c++/56793). */
if (!TYPE_CLASS_SCOPE_P (scope)
|| !DERIVED_FROM_P (TYPE_CONTEXT (scope), object_type))
@@ -2812,11 +2818,6 @@ finish_class_member_access_expr (cp_expr
return error_mark_node;
}
}
- else
- {
- scope = NULL_TREE;
- access_path = object_type;
- }
if (TREE_CODE (name) == BIT_NOT_EXPR)
{
Index: testsuite/g++.dg/template/pr71406.C
===================================================================
--- testsuite/g++.dg/template/pr71406.C (revision 0)
+++ testsuite/g++.dg/template/pr71406.C (working copy)
@@ -0,0 +1,28 @@
+// { dg-do compile }
+// PR c++/71406 ICE with X::template Name
+
+template < typename T >
+struct C : T
+{
+ void foo () { this->C::template bar <>; }
+};
+
+template < typename T >
+struct A
+{
+ template < void (T::*Fn) () > void f () {}
+};
+
+template < typename T > struct B : A < B < T > >
+{
+ void g ()
+ {
+ this->B::template f < &B < T >::g > ();
+ }
+};
+
+void Foo ()
+{
+ B < int > b;
+ b.g ();
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C++ PATCH] 71406, 77508 scoped template_ids
2017-01-23 19:18 [C++ PATCH] 71406, 77508 scoped template_ids Nathan Sidwell
@ 2017-01-23 20:19 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2017-01-23 20:19 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: GCC Patches
OK.
On Mon, Jan 23, 2017 at 1:53 PM, Nathan Sidwell <nathan@acm.org> wrote:
> This patch fixes 71406 and 77508, which are both ICEs dealing with
> 'X::Foo<...>'. finish_class_member_access_expr wasn't prepared to handle
> SCOPE_REF (TEMPLATE_ID_EXPR (...)), which is what it was being fed. Fixed
> by moving the SCOPE_REF splitting to before the TEMPLATE_ID_EXPR handling,
> but leaving the scope checking where it was.
>
> ok?
>
> nathan
> --
> Nathan Sidwell
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-23 20:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-23 19:18 [C++ PATCH] 71406, 77508 scoped template_ids Nathan Sidwell
2017-01-23 20:19 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).