From b233ee70e19a5efa32bca3e7bc56b93bcce349c5 Mon Sep 17 00:00:00 2001 From: dodji Date: Fri, 5 Feb 2010 08:28:24 +0000 Subject: [PATCH] Fix PR c++/42915 gcc/cp/ChangeLog: PR c++/42915 * typeck.c (get_template_parms_of_dependent_type): Try getting the template parameters fromt the type itself first. gcc/testsuite/ChangeLog: PR c++/42915 g++.dg/other/crash-9.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156514 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/typeck.c | 6 +++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/other/crash-9.C | 15 +++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/other/crash-9.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5ae5ac6ca12..893bd9d00e4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-02-05 Dodji Seketeli + + PR c++/42915 + * typeck.c (get_template_parms_of_dependent_type): Try getting + the template parameters fromt the type itself first. + 2010-02-03 Jason Merrill PR c++/4926 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 36f306558d3..18d56f4bfa3 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1106,9 +1106,13 @@ get_template_parms_of_dependent_type (tree t) { tree tinfo = NULL_TREE, tparms = NULL_TREE; + /* First, try the obvious case of getting the + template info from T itself. */ + if ((tinfo = get_template_info (t))) + ; /* If T1 is a typedef or whatever has a template info associated to its context, get the template parameters from that context. */ - if (typedef_variant_p (t) + else if (typedef_variant_p (t) && DECL_CONTEXT (TYPE_NAME (t)) && !NAMESPACE_SCOPE_P (TYPE_NAME (t))) tinfo = get_template_info (DECL_CONTEXT (TYPE_NAME (t))); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 94ccbc4266a..c8a911a63b6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-02-05 Dodji Seketeli + + PR c++/42915 + g++.dg/other/crash-9.C: New test. + 2010-02-05 Paul Thomas PR fortran/42309 diff --git a/gcc/testsuite/g++.dg/other/crash-9.C b/gcc/testsuite/g++.dg/other/crash-9.C new file mode 100644 index 00000000000..0953fcbc46b --- /dev/null +++ b/gcc/testsuite/g++.dg/other/crash-9.C @@ -0,0 +1,15 @@ +// Origin: PR c++/42915 +// { dg-do compile } + +template +class A +{ + template + class B + { + B foo(); + }; +}; +template template +A::B A::B::foo() {} + -- 2.11.4.GIT