[cfe-dev] line number of matching curly

Chris Lattner clattner at apple.com
Thu Sep 9 11:30:30 PDT 2010


On Sep 8, 2010, at 5:49 PM, Niklas Angare wrote:

> 
> "Chris Lattner" wrote:
>> On Aug 31, 2010, at 4:57 PM, Glenn Kasten wrote:
>> 
>>> Can you please add the line number of the matching open curly
>>> for the expected close curly (in this case line 2)?
>> 
>> Makes sense, fixed in r112709.  Thanks,
> 
> Sorry to barge in, but I'm wondering what the likelihood is of the compiler 
> actually pointing to the correct left brace.
> 
> I'm pretty sure it will point to the wrong one in this case:
> 
> void test(int i)
> {
> 	if(i > 3)
> 	{
> 		i *= 2;
> 	//} <-- missing brace
> 
> 	fudge(i);
> }
> 
> If it points to the incorrect one a lot of times I'd say it does more harm 
> than good.

You're right that the compiler doesn't know what you meant... the idea of pointing out the opening braces is so that *you* know what the compiler is "thinking".

In any case, it's the right thing to do for consistency with other diagnostics in clang.

-Chris



More information about the cfe-dev mailing list