Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

clang-tidy with -std=c++20 ignores -Wno-comment and -Wno-invalid-token-paste #47085

Open Quuxplusone opened 4 years ago

Quuxplusone commented 4 years ago
Bugzilla Link PR48116
Status CONFIRMED
Importance P normal
Reported by Gerbo Engels (gerbo.engels@ortec-finance.com)
Reported on 2020-11-09 01:53:41 -0800
Last modified on 2021-10-18 04:34:26 -0700
Version unspecified
Hardware PC Windows NT
CC aaron@aaronballman.com, alexfh@google.com, djasper@google.com, klimek@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
clang-tidy with -std=c++20 ignores some flags to ignore warnings (-Wno-comment
and -Wno-invalid-token-paste). With -std=c++17 works as expected (the warnings
are ignored).
Most other warnings can be ignored, regardless -std version (such as -Wno-
literal-conversion with code `int i = 2.4;`)
Found with clang 11.0.0 win64.

$ cat a.cpp
/* warning
/* nested
/* comments
*/

#define PLUS(x) +##x
void warning_invalid_token_paste() {
    3 PLUS(4);
}

$ clang-tidy a.cpp -- -std=c++17 -Wno-comment -Wno-invalid-token-paste

$ clang-tidy a.cpp -- -std=c++20 -Wno-comment -Wno-invalid-token-paste
2 warnings and 1 error generated.
Error while processing a.cpp.
a.cpp:2:1: warning: '/*' within block comment [clang-diagnostic-comment]
/* nested
^
a.cpp:3:1: warning: '/*' within block comment [clang-diagnostic-comment]
/* comments
^
a.cpp:8:7: error: pasting formed '+4', an invalid preprocessing token [clang-
diagnostic-invalid-token-paste]
    3 PLUS(4);
      ^
a.cpp:6:18: note: expanded from macro 'PLUS'
#define PLUS(x) +##x
                 ^
Found compiler error(s).
Quuxplusone commented 4 years ago

Same goes for -Wno-nonportable-include-path