[LLVMbugs] [Bug 6101] New: clang: preprocessor doesn't honor #line directives!

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu Jan 21 04:46:59 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=6101

           Summary: clang: preprocessor doesn't honor #line directives!
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: preprocessor
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: edwintorok at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Consider this testcase, clang -E only preserves the filenames, not the line
numbers!
int main()
{
#line 10 "foo1.c"
  printf("test\n");
#line 200 "foo2.c"
  printf("foo\n");
#line 10 "foo1.c"
}

clang -E gives:
# 1 "x.c"
# 1 "x.c" 1
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 113 "<built-in>" 3
# 113 "<command line>" 1
# 114 "<built-in>" 2
# 1 "x.c" 2
int main()
{
# 3 "foo1.c"

  printf("test\n");
# 5 "foo2.c"

  printf("foo\n");
# 7 "foo1.c"

}

gcc -E gives:
# 1 "x.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "x.c"
int main()
{
# 10 "foo1.c"
  printf("test\n");
# 200 "foo2.c"
  printf("foo\n");
# 10 "foo1.c"
}

The line numbers in #line must be honored to correctly compile output from
parser generators like bison, re2c, etc.
Otherwise warnings, and debug line numbers are all wrong.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list