[LLVMbugs] [Bug 23356] New: Wrong comment parsing with -std=c89

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Apr 26 23:45:34 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=23356

            Bug ID: 23356
           Summary: Wrong comment parsing with -std=c89
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: abramo.bagnara at bugseng.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 14257
  --> https://llvm.org/bugs/attachment.cgi?id=14257&action=edit
Patch to fix C89 comment parsing

In general clang cannot parse line comments when they are not enabled,
otherwise valid code is seen as invalid. I've attached patch to fix that.

$ cat p.c
#define str_(x) #x
#define str(x) str_(x)
char *s = str(//);
$ clang-3.5 -std=c89 -c p.c
p.c:3:11: error: unterminated function-like macro invocation
char *s = str(//);
          ^
p.c:2:9: note: macro 'str' defined here
#define str(x) str_(x)
        ^
p.c:3:19: error: expected expression
char *s = str(//);
                  ^
p.c:3:10: error: expected ';' after top level declarator
char *s = str(//);
         ^
         ;
3 errors generated.
$ gcc -std=c89 -c p.c
$

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150427/07780dd2/attachment.html>


More information about the llvm-bugs mailing list