llvm/llvm-project

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

Open

#123,038 建立於 2025年1月15日

在 GitHub 查看
 (4 留言) (0 反應) (1 負責人)C++ (10,782 fork)batch import
clang:diagnosticsgood first issue

倉庫指標

Star
 (26,378 star)
PR 合併指標
 (平均合併 1天 2小時) (30 天內合併 1,000 個 PR)

描述

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.

貢獻者指南