[PATCH] Support constant expressions, including non-type template parameters, in pragma loop hints

Tyler Nowicki tnowicki at apple.com
Fri Aug 1 12:06:23 PDT 2014


>> +  SmallVector<Token, 1> ValueList;
>> +  // Read constant expression.
>> +  while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eod)) {
>> +    ValueList.push_back(Tok);
>> +    PP.Lex(Tok);
> 
> I don't think this is correct -- it won't handle constant expressions
> involving parentheses properly. Eg)
> 
> #pragma unroll((2+2)+4)
> 
> It produces:
> E:\Aaron Ballman\Desktop\test2.cpp:9:21: warning: extra tokens at end
> of '#pragma unroll' - ignored
> #pragma unroll((2+2)+4)
> 
> So that should be fixed, and you should have a test for it as well.

Oops, you are right. How about we do this incrementally? We can put this patch in now and I'll follow up with better parsing. I’ll be able work on this in a couple of weeks.

I think we need to use the BalancedDelimiterTracker to resolve this issue.

Tyler



More information about the cfe-commits mailing list