Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] use of hasMultipleArgs() in TemplateIdStrategy

Hi,

I'm investigating bug 445177, where CDT fails to parse the following declaration:

a<b<c,b<c>::*member;

The only valid parse here is 

a<(b<c),(b<c)>::*member, 

i.e. the first '<' starts a template-parameter-list while other two '<' are less-than operators.

However, CDT does not consider this parse. The reason is that in TemplateIdStrategy, we skip over the alternative that would interpret the first '<' as opening a template-parameter-list but the second '<' as less-than.

This is because in setNextAlternative(), the code that would consider the second '<' as less-than is conditioned on '!hasMultipleArgs(names[--nameLen])', where 'names[--nameLen]' in this case is the first 'b', and 'hasMultipleArgs()' checks whether the name is part of a template-id with multiple template arguments.

As it happens, the check fails, because while considering the previous alternative, the first 'b' was parsed as part of the template-id 'b<c,(b<c)>', which has two arguments.

I see that the use of hasMultipleArgs() was added in bug 363609 for performance reasons. However, is there a correctness argument for conditioning on hasMultipleArgs() here? The above example would lead me to believe 'no', but perhaps I'm missing something.

cc'ing Markus, who originally wrote this code.

Thanks,
Nate
 		 	   		  

Back to the top