From 7c5867495bbfce161cd0461b002f626f9339b78f Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 17 Feb 2017 15:28:38 -0500 Subject: [PATCH] PR c++/78690 - ICE with using and global type with same name * pt.c (type_dependent_object_expression_p): True for IDENTIFIER_NODE. From-SVN: r245549 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 4 ++++ .../g++.dg/template/dependent-scope1.C | 17 +++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/dependent-scope1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a660c434c79..2e2cd6c48c5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-02-17 Jason Merrill + PR c++/78690 - ICE with using and global type with same name + * pt.c (type_dependent_object_expression_p): True for + IDENTIFIER_NODE. + PR c++/79549 - C++17 ICE with non-type auto template parameter pack * pt.c (convert_template_argument): Just return an auto arg pack. (tsubst_template_args): Don't tsubst an auto pack type. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 04479d4d486..9e6ce8d51de 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -23932,6 +23932,10 @@ type_dependent_expression_p (tree expression) bool type_dependent_object_expression_p (tree object) { + /* An IDENTIFIER_NODE can sometimes have a TREE_TYPE, but it's still + dependent. */ + if (TREE_CODE (object) == IDENTIFIER_NODE) + return true; tree scope = TREE_TYPE (object); return (!scope || dependent_scope_p (scope)); } diff --git a/gcc/testsuite/g++.dg/template/dependent-scope1.C b/gcc/testsuite/g++.dg/template/dependent-scope1.C new file mode 100644 index 00000000000..a5c18c4629c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/dependent-scope1.C @@ -0,0 +1,17 @@ +// PR c++/78690 + +struct C; + +template +struct A +{ + struct C { static void bar (); }; +}; + +template +struct B +{ + using A::C; + void + foo () { C.bar (); } +}; -- 2.30.2