Line directives in Clang vs GCC

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. :confused:

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 are you really trying to do?

kirbyfan64sos <rymg19@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. :confused:

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.

Solved! I just wrote a Perl script to rewrite the error lines
<https://github.com/kirbyfan64/reclang> .