This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ Patch] PR 30659
- From: Paolo Carlini <pcarlini at suse dot de>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 28 Oct 2007 18:41:19 +0100
- Subject: Re: [C++ Patch] PR 30659
- References: <46F3B782.3060701@suse.de> <47216174.9080909@codesourcery.com> <4724BB10.4090800@suse.de>
... so I think a more correct fix is the below, which uses
CP_DECL_CONTEXT. In fact, DECL_CONTEXT is documented as being NULL_TREE
in case of global namespace. Also, I checked that the crash would not
happen for the same broken declaration inside an user defined namespace.
Tested x86_64-linux. Ok?
Paolo.
//////////////////
cp/
2007-10-28 Paolo Carlini <pcarlini@suse.de>
PR c++/30659
* pt.c (do_decl_instantiation): Use CP_DECL_CONTEXT.
testsuite/
2007-10-28 Paolo Carlini <pcarlini@suse.de>
PR c++/30659
* g++.dg/template/crash71.C: New.
Index: testsuite/g++.dg/template/crash71.C
===================================================================
*** testsuite/g++.dg/template/crash71.C (revision 0)
--- testsuite/g++.dg/template/crash71.C (revision 0)
***************
*** 0 ****
--- 1,3 ----
+ // PR c++/30659
+
+ extern "C" template A<char> foo(); // { dg-error "forbids|template|expected" }
Index: cp/pt.c
===================================================================
*** cp/pt.c (revision 129697)
--- cp/pt.c (working copy)
*************** do_decl_instantiation (tree decl, tree s
*** 13882,13888 ****
VAR_DECLs so we do the lookup here. Probably, grokdeclarator
should handle VAR_DECLs as it currently handles
FUNCTION_DECLs. */
! result = lookup_field (DECL_CONTEXT (decl), DECL_NAME (decl), 0, false);
if (!result || TREE_CODE (result) != VAR_DECL)
{
error ("no matching template for %qD found", decl);
--- 13882,13889 ----
VAR_DECLs so we do the lookup here. Probably, grokdeclarator
should handle VAR_DECLs as it currently handles
FUNCTION_DECLs. */
! result = lookup_field (CP_DECL_CONTEXT (decl), DECL_NAME (decl),
! 0, false);
if (!result || TREE_CODE (result) != VAR_DECL)
{
error ("no matching template for %qD found", decl);