[cfe-commits] [patch] Avoid gcc warning when using the clang preprocessor

Rafael Espindola espindola at google.com
Mon Sep 28 15:05:22 PDT 2009


> Strange, can you elaborate about what the problem is?

Sure. When preprocessing a trivial file

int main(int argc, char*argv[]) {
  return 0;
}

gcc will produce
------------------------------------------------
# 1 "test.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.c"
int main(int argc, char*argv[]) {
  return 0;
}
------------------------------------------
clang will produce
----------------------------------------
# 1 "test.c"
# 1 "test.c" 1
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 105 "<built-in>" 3
# 105 "<command line>" 1
# 1 "test.c" 2
int main(int argc, char*argv[]) {
  return 0;
}
----------------------------------

If passing the clang output to gcc, it will complain:

$ gcc test.i -o test
line-map.c: file "test.c" left but not entered

gcc doesn't like the line

# 1 "test.c" 2

Which does look strange. If I understand it correctly, we would be
exiting from "command line" into test.c, but next value on teh stack
is "built-in".

>  Doing a string
> equality comparison to detect this seems expensive, is there another way to
> catch this?  Also, can you make the testcase a positive check ("grep" or
> filecheck) instead of a negative one ("not grep")?

I noticed that the proposed patch is wrong. Sorry about that. I will
try to code a proper fix.

> -Chris
>

Cheers,
-- 
Rafael Ávila de Espíndola




More information about the cfe-commits mailing list