llvm/llvm-project

missing parenthesis for function-like macro invocation could have better diagnostic

Open

#123.038 geöffnet am 15. Jan. 2025

Auf GitHub ansehen
 (4 Kommentare) (0 Reaktionen) (1 zugewiesene Person)C++ (10.782 Forks)batch import
clang:diagnosticsgood first issue

Repository-Metriken

Stars
 (26.378 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 1T 2h) (1.000 gemergte PRs in 30 T)

Beschreibung

Consider:

$ cat /tmp/a.c
#define FOO() 42
int x = FOO;

The compiler will error because we forgot to use parens for FOO:

$ clang -c /tmp/a.c
/tmp/a.c:2:9: error: use of undeclared identifier 'FOO'
    2 | int x = FOO;
      |         ^
1 error generated.

It would be nice if the compiler diagnostic included a note pointing out that FOO does exist, but as a function-like macro it requires parenthesis.

Contributor Guide