Bug 27572 - [4.0/4.1/4.2 regression] ICE on typedef in parameter declaration
Summary: [4.0/4.1/4.2 regression] ICE on typedef in parameter declaration
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P4 normal
Target Milestone: 4.0.4
Assignee: Volker Reichelt
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: error-recovery, ice-on-invalid-code, monitored, patch
Depends on:
Blocks:
 
Reported: 2006-05-12 09:44 UTC by Volker Reichelt
Modified: 2006-07-25 01:55 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-05-12 19:36:31


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-05-12 09:44:13 UTC
The C++ frontend currently chokes on invalid typedefs in parameter
declarations for both functions and templates.
One can generate ICEs in many different places like the following
examples show:

======================================
void foo(typedef) {}
======================================

bug.cc:1: error: ISO C++ forbids declaration of 'parameter' with no type
bug.cc:1: error: typedef declaration invalid in parameter declaration
bug.cc: In function 'void foo(int)':
bug.cc:1: internal compiler error: tree check: expected tree that contains 'decl with RTL' structure, have 'type_decl'  in set_decl_rtl, at emit-rtl.c:949
Please submit a full bug report, [etc.]

======================================
void foo(typedef x[]) {}
======================================

ICE in pop_binding, at cp/name-lookup.c:380

======================================
template<typedef> void foo();

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

ICE in instantiate_decl, at cp/pt.c:11703

======================================
template<typedef,int> struct A;
======================================

tree check ICE: expected template_type_parm or template_template_parm or bound_template_template_parm, have integer_type in process_template_parm, at cp/pt.c:2336

======================================
template<typedef> struct A
{
  void foo();
  void bar();
};

A<int> a;
======================================

ICE in finish_member_declaration, at cp/semantics.c:2212

======================================
template<typedef> struct A
{
  friend void foo();
};

A<int> a;
======================================

ICE in tsubst_decl, at cp/pt.c:6263

Some of these examples crash since GCC 2.95.3, but some (like the first
and last) since 3.4.0, so this is a regression.

Patch to follow.
Comment 1 patchapp@dberlin.org 2006-05-12 09:47:53 UTC
Subject: Bug number PR c++/27572

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-05/msg00502.html
Comment 2 patchapp@dberlin.org 2006-07-24 14:15:15 UTC
Subject: Bug number PR c++/27572

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-07/msg01036.html
Comment 3 Volker Reichelt 2006-07-25 00:57:24 UTC
Subject: Bug 27572

Author: reichelt
Date: Tue Jul 25 00:57:10 2006
New Revision: 115729

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115729
Log:
	PR c++/27572
	* decl.c (grokdeclarator): Return error_mark_node after invalid
	typedef.

	* g++.dg/other/typedef1.C: New test.
	* g++.dg/template/typedef4.C: New test.
	* g++.dg/template/typedef5.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/other/typedef1.C
    trunk/gcc/testsuite/g++.dg/template/typedef4.C
    trunk/gcc/testsuite/g++.dg/template/typedef5.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 Volker Reichelt 2006-07-25 01:02:18 UTC
Subject: Bug 27572

Author: reichelt
Date: Tue Jul 25 01:02:08 2006
New Revision: 115730

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115730
Log:
	PR c++/27572
	* decl.c (grokdeclarator): Return error_mark_node after invalid
	typedef.

	* g++.dg/other/typedef1.C: New test.
	* g++.dg/template/typedef4.C: New test.
	* g++.dg/template/typedef5.C: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/other/typedef1.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/typedef4.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/typedef5.C
Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/decl.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 5 Volker Reichelt 2006-07-25 01:06:23 UTC
Subject: Bug 27572

Author: reichelt
Date: Tue Jul 25 01:06:15 2006
New Revision: 115731

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115731
Log:
	PR c++/27572
	* decl.c (grokdeclarator): Return error_mark_node after invalid
	typedef.

	* g++.dg/other/typedef1.C: New test.
	* g++.dg/template/typedef4.C: New test.
	* g++.dg/template/typedef5.C: New test.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/other/typedef1.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/template/typedef4.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/template/typedef5.C
Modified:
    branches/gcc-4_0-branch/gcc/cp/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/decl.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog

Comment 6 Volker Reichelt 2006-07-25 01:55:12 UTC
Fixed on mainline, 4.1 branch, and 4.0 branch.

Some of the testcases still crash, but they crash in get_innermost_template_args.
This problem is tracked in PR 27397.