[llvm-bugs] [Bug 50600] New: clang detects dollars in macro arguments instead of identifiers.

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 7 05:21:58 PDT 2021


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

            Bug ID: 50600
           Summary: clang detects dollars in macro arguments instead of
                    identifiers.
           Product: clang
           Version: 12.0
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: pjb at informatimago.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

clang detects a dollar in identifier, when there is no such
identifier, but only a string, as per the macro.  It should do that after
macro-expansion, not before.

Makefile:
```
all:
        clang -Wdollar-in-identifier-extension -o pgm gcc-dollar-bug.c
        ./pgm
```

gcc-dollar-bug.c:
```
#include <stdio.h>

#define S(x) #x

int main(void){
    printf("Good string: %s\n",S($HELLO));
    return 0;}
```

```
[pjb at despina org.xquartz:0 gcc-dollar-bug 23Gi]$ make
clang -Wdollar-in-identifier-extension -o pgm gcc-dollar-bug.c
gcc-dollar-bug.c:6:34: warning: '$' in identifier
[-Wdollar-in-identifier-extension]
    printf("Good string: %s\n",S($HELLO));
                                 ^
1 warning generated.
./pgm
Good string: $HELLO
[pjb at despina org.xquartz:0 gcc-dollar-bug 23Gi]$

#+END_EXAMPLE
```

-- 
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/20210607/50a135ac/attachment.html>


More information about the llvm-bugs mailing list