This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix PR c++/30156

Hi Geoff,

Apologies for the delay in getting back to you regarding this, I've
been busy getting an unrelated patch ready for submission so didn't
have time.

On 7/3/07, Geoffrey Keating <> wrote:
Hi Lee,

> cp/
> 2006-12-12  Lee Millward  <>
>        PR c++/30156
>        * parser.c (cp_parser_parenthesized_expression_list): Detect
>        and propagate invalid expressions as error_mark_node sooner.
>        (cp_parser_init_declarator): Likewise for initializations.
> testsuite/
> 2006-10-17  Lee Millward  <>
>        PR c++/30156
>        * g++.dg/template/crash60: Add new test for functions
>        returning a non-void value.

- Please add a new test rather than extending an existing one.


- The first change to cp_parser_parenthesized_expression_list appears
to contradict the comment below,

              /* Add it to the list.  We add error_mark_node
                 expressions to the list, so that we can still tell if
                 the correct form for a parenthesized expression-list
                 is found. That gives better errors.  */

Could you explain more about why it's necessary to exit earlier than
this comment contemplates?

As the date on the changelog shows, it's been a while since I created this patch and I'm no longer able to recall the reasoning why it was done the way it was. With this in mind I've gone back over the problem and would like to propose the attached patch instead.

For this testcase, cp_finish_decl (in which the ICE is triggered) is
called twice - one from inside grokfield and once from the parser in
cp_parser_init_declarator. It's this second call that ICEs when the
code tries to set DECL_INITIALIZED_BY_CONSTANT_EXPR_P on the decl. The
first call to cp_finish_decl doesn't ICE because there is a check at
the head of grokfield for invalid initialisers, setting the "init"
parameter to NULL_TREE if one is found and causing the problematic
code in cp_finish_decl to be skipped. When the parser calls
cp_finish_decl however, no such check is made to see if the parsed
initialiser is invalid so the  ICE is triggered.

The attached patch simply adds a check identical to the one in
grokfield for invalid initialisers and updates the value passed in the
"init_const_expr_p" parameter to to cp_finish_decl to take this into
consideration so that invalid intialisers for decls are ignored.

Bootstrapped and regression tested successfully on i686-pc-linux. Ok
for mainline and release branches?


2007-07-07  Lee Millward  <>
	PR c++/30156
	* parser.c (cp_parser_init_declarator): Add check for decls with
	invalid initializers for the call to cp_finish_decl.

2007-07-07  Lee Millward  <>

	PR c++/30156
	* g++.dg/template/error26.C: New test.

Attachment: pr30156.txt
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]