RFR: 8325163: Enable -Wpedantic on clang

Julian Waters jwaters at openjdk.org
Mon Feb 5 07:30:01 UTC 2024


On Mon, 5 Feb 2024 03:21:35 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Inspired by (the later backed-out) [JDK-8296115](https://bugs.openjdk.org/browse/JDK-8296115), I propose to enable `-Wpedantic` for clang. This has already found some irregularities in the code, like mistakenly using `#import` instead of `#include`. In this patch, I disable warnings for these individual buggy or badly written files, but I intend to post follow-up issues on the respective teams to have them properly fixed.
>> 
>> Unfortunately, it is not possible to enable `-Wpedantic` on gcc, since individual warnings in `-Wpedantic` cannot be disabled. This means that code like this:
>> 
>> 
>> #define DEBUG_ONLY(code) code;
>> 
>> DEBUG_ONLY(foo());
>> 
>> 
>> will result in a `; ;`. This breaks the C standard, but is benign, and we use it all over the place. On clang, we can ignore this by `-Wno-extra-semi`, but this is not available on gcc.
>
>> Inspired by (the later backed-out) [JDK-8296115](https://bugs.openjdk.org/browse/JDK-8296115), I propose to enable `-Wpedantic` for clang. This has already found some irregularities in the code, like mistakenly using `#import` instead of `#include`. In this patch, I disable warnings for these individual buggy or badly written files, but I intend to post follow-up issues on the respective teams to have them properly fixed.
> 
> Rather than first turning on pedantic warnings and then (maybe) going back and perhaps fixing things, I'd really prefer
> things be done in the other order.  (That's how I handled the recent `-Wparentheses` changes, for example.)

@kimbarrett quoting the gcc maintainers

> Yes because the C++ defect report was only for `Spurious semicolons at namespace scope should be allowed`.  See https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#569 .
> 
> 
> ```
> struct f
> {
>   int t;  ;
> };
> ```
> 
> Is not allowed by the C++ standard currently and is a GCC extension, maybe it should have a seperate flag to control that but I am not 100% sure.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17687#issuecomment-1926372614


More information about the build-dev mailing list