Bug 28114 - [4.0/4.1/4.2 regression] ICE with struct definition in argument of template function
Summary: [4.0/4.1/4.2 regression] ICE with struct definition in argument of template f...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.0.4
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, error-recovery, ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2006-06-20 21:11 UTC by Volker Reichelt
Modified: 2006-07-13 13:02 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-06-24 01:53:09


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-06-20 21:11:52 UTC
The following invalid testcase causes an ICE since GCC 4.0.0:

===========================================
template<int> void foo(struct {}*);

void bar()
{
  foo<0>(0);
}
===========================================

bug.cc:1: error: template class without a name
bug.cc:1: error: types may not be defined in parameter types
bug.cc:5: error: conflicting declaration 'struct<anonymous>'
bug.cc:5: error: 'struct<anonymous>' has a previous declaration as 'struct<anonymous>'
bug.cc: In function 'void bar()':
bug.cc:5: internal compiler error: tree check: expected tree that contains 'decl minimal' structure, have 'error_mark'  in pushtag, at cp/name-lookup.c:4865
Please submit a full bug report, [etc.]

Moreover only the second line of the error message makes sense.
The "conflicting declaration" message is completely bogus, and the
first line looks bogus to me, too.
Comment 1 Steve Ellcey 2006-06-22 16:38:53 UTC
Proposed patch at http://gcc.gnu.org/ml/gcc-patches/2006-06/msg01234.html
Comment 2 Steve Ellcey 2006-06-23 21:58:34 UTC
Subject: Bug 28114

Author: sje
Date: Fri Jun 23 21:58:25 2006
New Revision: 114953

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114953
Log:
	PR c++/28114
	* name-lookup.c (pushtag): Return if we have error_mark_node.

Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/name-lookup.c

Comment 3 Andrew Pinski 2006-06-24 01:53:09 UTC
Confirmed, fixed at least on the mainline.
Comment 4 Steve Ellcey 2006-06-26 21:25:32 UTC
Subject: Bug 28114

Author: sje
Date: Mon Jun 26 21:25:23 2006
New Revision: 115025

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115025
Log:
	PR c++/28114
	* g++.dg/other/pr28114.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/other/pr28114.C
Modified:
    trunk/gcc/testsuite/ChangeLog

Comment 5 Steve Ellcey 2006-07-10 20:42:23 UTC
Subject: Bug 28114

Author: sje
Date: Mon Jul 10 20:42:14 2006
New Revision: 115314

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115314
Log:
	PR c++/28114
	* name-lookup.c (pushtag): Return if we have error_mark_node.

Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/name-lookup.c

Comment 6 Steve Ellcey 2006-07-10 20:43:43 UTC
Subject: Bug 28114

Author: sje
Date: Mon Jul 10 20:43:34 2006
New Revision: 115315

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115315
Log:
	PR c++/28114
	* g++.dg/other/pr28114.C: New.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/other/pr28114.C
Modified:
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 7 Steve Ellcey 2006-07-10 20:46:50 UTC
I have checked in a patch for ToT and on the 4.1 branch.  My inclination is to not fix this on the 4.0 branch because the patch doesn't apply automatically.  The same change is probably needed somewhere else for 4.0, but I don't think it is worth the trouble to find out where.  Should I close this out as  fixed in 4.1.2?
Comment 8 Volker Reichelt 2006-07-11 09:15:46 UTC
Subject: Re:  [4.0/4.1 regression] ICE with struct definition in
 argument of template function

On 10 Jul, sje at cup dot hp dot com wrote:
> 
> 
> ------- Comment #7 from sje at cup dot hp dot com  2006-07-10 20:46 -------
> I have checked in a patch for ToT and on the 4.1 branch.  My inclination is to
> not fix this on the 4.0 branch because the patch doesn't apply automatically. 
> The same change is probably needed somewhere else for 4.0, but I don't think it
> is worth the trouble to find out where.

Well, with some trivial changes (whitespace, different number of
parameters for pushdecl_with_scope) the patch applies to the 4.0 branch:

===================================================================
--- gcc/gcc/cp/name-lookup.c	(revision 115324)
+++ gcc/gcc/cp/name-lookup.c	(working copy)
@@ -4666,7 +4666,11 @@ pushtag (tree name, tree type, tag_scope
 		pushdecl_class_level (decl);
 	    }
 	  else if (b->kind != sk_template_parms)
-	    decl = pushdecl_with_scope (decl, b);
+	    {
+	      decl = pushdecl_with_scope (decl, b);
+	      if (decl == error_mark_node)
+		POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl);
+	    }
 
 	  /* FIXME what if it gets a name from typedef?  */
 	  if (ANON_AGGRNAME_P (name))
===================================================================

Would you mind testing this on the 4.0 branch? Or should I do that?

> Should I close this out as  fixed in 4.1.2?


Comment 9 Steve Ellcey 2006-07-11 20:56:58 UTC
I am testing on the 4.0 branch now.
Comment 10 Steve Ellcey 2006-07-12 21:46:51 UTC
Subject: Bug 28114

Author: sje
Date: Wed Jul 12 21:46:43 2006
New Revision: 115397

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115397
Log:
	PR c++/28114
	* name-lookup.c (pushtag): Return if we have error_mark_node.

Modified:
    branches/gcc-4_0-branch/gcc/cp/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/name-lookup.c

Comment 11 Steve Ellcey 2006-07-12 21:48:06 UTC
Subject: Bug 28114

Author: sje
Date: Wed Jul 12 21:47:58 2006
New Revision: 115398

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115398
Log:
	PR c++/28114
	* g++.dg/other/pr28114.C: New.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/other/pr28114.C
Modified:
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog

Comment 12 Volker Reichelt 2006-07-13 13:02:25 UTC
Fixed on mainline, 4.1 branch, and 4.0 branch.