Poor Clang diagnostic for string literal concatenation with undefined macro
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Example:
```
#define BAR "bar"
const char *s = "foo" BAAR;
```
The author intended to concatenate "foo" with the string defined by the `BAR` macro but misspelled it. The diagnostic doesn't even mentioned the misspelled (and therefore undefined) macro though:
```
$ build/bin/clang -c /tmp/a.c
/tmp/a.c:2:22: error: expected ';' after top level declarator
2 | const char *s = "foo" BAAR;
| ^
| ;
1 error generated.
```
Other compilers have similar output (https://godbolt.org/z/o1GqPYdrG), but maybe Clang could do better?
Contributor guide
Research direction
Reproduce the diagnostic with build/bin/clang -c /tmp/a.c using the example in the issue, then compare the output with the compiler results linked on Godbolt. Trace the diagnostic path for the adjacent string literal and BAAR tokens. Done means Clang reports the undefined or misspelled macro rather than only suggesting a missing semicolon.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100