Wrong comment parsing with -std=c89

Abramo Bagnara abramo.bagnara at bugseng.com
Tue May 5 01:43:13 PDT 2015


(filed as https://llvm.org/bugs/show_bug.cgi?id=23356, sent here for
patch review)

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
$


-- 
Abramo Bagnara

BUGSENG srl - http://bugseng.com
mailto:abramo.bagnara at bugseng.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0032-Fixed_c89_comment_parsing.patch
Type: text/x-patch
Size: 1384 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150505/05a9cd14/attachment.bin>


More information about the cfe-commits mailing list