This is an archive of the discontinued LLVM Phabricator instance.

[cmake] Enable Clang warnings about redundant semicolons
ClosedPublic

Authored by mstorsjo on Mar 19 2021, 4:51 AM.

Details

Summary

This matches what GCC warns about when -pedantic is enabled.

This should avoid such redundant semicolons creeping into the codebase.

Diff Detail

Event Timeline

mstorsjo created this revision.Mar 19 2021, 4:51 AM
mstorsjo requested review of this revision.Mar 19 2021, 4:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2021, 4:51 AM

Shouldn’t we rather add that warning to -pedantic in Clang as well?

cc @aaron.ballman @rsmith

Shouldn’t we rather add that warning to -pedantic in Clang as well?

cc @aaron.ballman @rsmith

Maybe; Clang does warn about it if building with -std=c++98, in the form warning: extra ';' outside of a function is a C++11 extension [-Wc++11-extra-semi] though. But in C++11 mode, it only warns about it if this option is added, warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]. I'd say the Clang behaviour in itself makes sense (it's a new feature and you're supposed to be able to use it), so GCC is the odd one out there.

aaron.ballman accepted this revision.Mar 19 2021, 8:47 AM

Shouldn’t we rather add that warning to -pedantic in Clang as well?

cc @aaron.ballman @rsmith

I think GCC's behavior is not particularly helpful -- pedantically, the code is correct (in C++11 and later mode).

LGTM with a small tweak!

llvm/cmake/modules/HandleLLVMOptions.cmake
675
This revision is now accepted and ready to land.Mar 19 2021, 8:47 AM
mstorsjo added inline comments.Mar 19 2021, 9:35 AM
llvm/cmake/modules/HandleLLVMOptions.cmake
675

Thanks! Will fix that before pushing.

This revision was automatically updated to reflect the committed changes.

I think one of the buildbots is failing with this IIUC?
https://lab.llvm.org/buildbot/#/builders/4/builds/8255
/b/1/openmp-gcc-x86_64-linux-debian/llvm.src/openmp/runtime/src/kmp_i18n.h:173:2: warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]

Looks like a straightforward fix, though that code hasn't changed recently, and this change went in over a month ago.

I think one of the buildbots is failing with this IIUC?
https://lab.llvm.org/buildbot/#/builders/4/builds/8255
/b/1/openmp-gcc-x86_64-linux-debian/llvm.src/openmp/runtime/src/kmp_i18n.h:173:2: warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]

Looks like a straightforward fix, though that code hasn't changed recently, and this change went in over a month ago.

It doesn't seem like it's failing over that to me? But it does indeed seem to spam a number of warnings in that setup. I pushed a commit to get rid of those redundant semicolons at least, in rG01d27fc40836 - thanks for noticing!