This is the mail archive of the gcc-patches@gcc.gnu.org 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++/27572: ICE on typedef in parameter declaration


On 14 May, Mark Mitchell wrote:
> Volker Reichelt wrote:
> 
>> The patch is mostly mechanical, as it replaces all uses of
>> "declspecs->specs[(int)ds_typedef]" by "typedefp". The only interesting
>> part is the third hunk where typedefp is reset for parameters.
> 
> Why not just return error_mark_node at that point?

Because then the following will cause an ICE:

template<typedef> struct A {};
A<int> a;

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:1: internal compiler error: tree check: accessed elt 1 of tree_vec with 0 elts in get_innermost_template_args, at cp/pt.c:490
Please submit a full bug report, [etc.]

Btw, there are more PRs (PR26938, PR27397, PR27493, PR27494) with
invalid accesses of elts of tree_vecs. Maybe one can get away returning
error_mark_node once these get fixed, but I haven't looked into them.

Do you want to have a look?

>> Btw, "typedefp" is now the sixth variable to track the status of
>> declspecs locally in grokdeclarator. Wouldn't it make more sense in
>> the long run to skip the "const" in "declspecs" and modify the
>> original specs direcly?
> 
> IIRC, the point is that the same specifiers are reused for multiple
> declarators, in something like "static const int i, *j;" and we want to
> avoid modifying the behavior on the second declarator.

Makes sense. (I only thought of function decls.)

> You could indeed
> make a copy of the specs in grokdeclarator, and use that.

If we have to make a copy anyway, we might be better off with the
local variables. Maybe we can convert the predicates from int to bool
sometimes to better reflect their intention.

Regards,
Volker



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