[cfe-dev] Line directives in Clang vs GCC
Justin Bogner
mail at justinbogner.com
Fri Jul 10 21:53:58 PDT 2015
kirbyfan64sos <rymg19 at gmail.com> writes:
> I posted this on Stack Overflow
> <http://stackoverflow.com/questions/31352011/clang-line-directive> , but I
> just got 1 downvote (technically 2, but I also got 1 upvote) and 3 close
> votes. So...yeah. :/
>
> Basically, I have ln.x:
>
> abc
>
> And ln.cpp
>
> #line 1 "ln.x"
> (
>
> GCC prints the corresponding line of ln.x:
>
> ln.x:1:1: error: expected unqualified-id at end of input
> abc
> ^
> ln.x:1:1: error: expected ‘)’ at end of input
>
> But Clang simply prints the line in ln.cpp:
>
> ln.x:1:2: error: expected unqualified-id
> (
> ^
> ln.x:1:2: error: expected ')'
> ln.x:1:1: note: to match this '('
> (
> ^
> 2 errors generated.
>
> Is there a way to achieve the GCC behavior in Clang?
What do you expect here? Something like:
ln.x:1:2: error: expected unqualified-id
abc
^
ln.x:1:2: error: expected ')'
ln.x:1:1: note: to match this '('
abc
^
?
That doesn't make sense - obviously the line directive isn't accurate.
As far as I can tell this is a GCC bug. You can't get this behaviour in
clang.
More information about the cfe-dev
mailing list