-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update gcc rules to 14.2 #2815
Update gcc rules to 14.2 #2815
Conversation
@cmorve-te Normally, the sensors support all the rules of the current version and also those of the previous versions. I would not deviate from this in 2.1.x. With 2.2.x we can think about cleaning up and removing outdated rules (this PR is for 2.2). For me, the decisive factor is always which version of the tool is included in larger Linux distributions. These rules should at least be supported. |
To be clear, do you want me to modify this PR? If so, there are a) Fortran-only warnings 'a' has been generated by gcc, but only for Fortran programs Do you want me to keep all of them, even the wrong ones? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comments
@@ -115,7 +115,21 @@ protected String alignId(@Nullable String id) { | |||
if (id == null || "".equals(id)) { | |||
id = DEFAULT_ID; | |||
} | |||
return id.replaceAll("=$", ""); | |||
id = id.replaceAll("=$", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regex are slow, could also be:
if (id.charAt(id.length() - 1) == '=') {
id = id.substring(0, str.length() - 1);
}
return id.replaceAll("=$", ""); | ||
id = id.replaceAll("=$", ""); | ||
|
||
if (id.equals("-Wc++0x-compat")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chain of if/if else: would use a switch
@cmorve-te No I like to verify which gcc version is part of current CI/CD systems
In case it's an older one we should discuss if it makes sense to support also these old rules? |
11.2.0 -> https://packages.ubuntu.com/jammy/gcc
10.2.1 -> https://packages.debian.org/bullseye/gcc
There is the embedded world, which has a tendency to use old versions. Some references
|
@cmorve-te same here. All rules starting from 10.2.1 should be in the XML, older rules can be deleted. |
I would rather keep anything down to gcc 5.0. As mentioned, it's not an uncommon version in the embedded world, and we specifically do build with it. |
The Fortran-only aliasing, align-commons, ampersand, array-temporaries, character-truncation, conversion-extra, function-elimination, implicit-interface, implicit-procedure, intrinsic-shadow, intrinsics-std, line-truncation, real-q-constant, surprising, underflow and unused-dummy-argument warnings have been removed. -Wsystem-headers has also been removed since it's not a warning, it's an option that affects whether warnings in system headers are reported. -Wno-aggressive-loop-optimizations and -Wno-builtin-declaration-mismatch have been replaced with the correct -Waggressive-loop-optimizations and -Wbuiltin-declaration-mismatch.
I have not actually measured, but regexs are slow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hope did the comparision this time right. Below were in the old XML but no more in the new one:
-Waliasing
-Walign-commons
-Wampersand
-Warray-temporaries
-Wc++0x-compat
-Wc++1z-compat
-Wcharacter-truncation
-Wconversion-extra
-Wfunction-elimination
-Wimplicit-interface
-Wimplicit-procedure
-Wintrinsic-shadow
-Wintrinsics-std
-Wline-truncation
-Wmissing-format-attribute
-Wmissing-noreturn
-Wno-aggressive-loop-optimizations
-Wno-builtin-declaration-mismatch
-Wreal-q-constant
-Wsurprising
-Wsystem-headers
-Wunderflow
-Wunused-dummy-argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, all expected
-Waliasing (Fortran-only)
-Walign-commons (Fortran-only)
-Wampersand (Fortran-only)
-Warray-temporaries (Fortran-only)
-Wc++0x-compat (alias for -Wc++11-compat)
-Wc++1z-compat (alias for -Wc++17-compat)
-Wcharacter-truncation (Fortran-only)
-Wconversion-extra (Fortran-only)
-Wfunction-elimination (Fortran-only)
-Wimplicit-interface (Fortran-only)
-Wimplicit-procedure (Fortran-only)
-Wintrinsic-shadow (Fortran-only)
-Wintrinsics-std (Fortran-only)
-Wline-truncation (Fortran-only)
-Wmissing-format-attribute (alias for -Wsuggest-attribute=format)
-Wmissing-noreturn (alias for -Wsuggest-attribute=noreturn)
-Wno-aggressive-loop-optimizations (wrong, it's -Waggressive-loop-optimizations)
-Wno-builtin-declaration-mismatch (wrong, it's -Wbuiltin-declaration-mismatch)
-Wreal-q-constant (Fortran-only)
-Wsurprising (Fortran-only)
-Wsystem-headers (not a real warning)
-Wunderflow (Fortran-only)
-Wunused-dummy-argument (Fortran-only)
I left the Objective-C/Objective-C++-only warnings. But didn't include the Fortran-only since it's seemed too unrelated for a C++ plugin? The warnings are documented literally in a different place, e.g. https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gfortran/Error-and-Warning-Options.html#index-Waliasing (vs https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html).
I am not familiar with Fortran, though. Happy to readd them if you would rather keep them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cmorve-te thx then we can merge it.
Do you like to fix the 2 findings above or should I do it as part of technical debt clean-up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the changes. I just wanted to test them first, and got busy with something else. Will try to push them later today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not going to get the chance to test it, but I have pushed it anyway.
I am not a Java guy, to the point I didn't know you could use switch with strings... but I want to think I have not been able to break this: https://github.com/SonarOpenCommunity/sonar-cxx/compare/b024e9c3748d7c16c58edd5093b7b00969c4b489..0c7b6c307393de5b08c02b16fe6cc93e465a000c.
b024e9c
to
0c7b6c3
Compare
@cmorve-te thx for providing this PR |
- fix/complete SonarOpenCommunity#2815
The Fortran-only aliasing, align-commons, ampersand, array-temporaries, character-truncation, conversion-extra, function-elimination, implicit-interface, implicit-procedure, intrinsic-shadow, intrinsics-std, line-truncation, real-q-constant, surprising, underflow and unused-dummy-argument warnings have been removed.
-Wsystem-headers has also been removed since it's not a warning, it's an option that affects whether warnings in system headers are reported.
-Wno-aggressive-loop-optimizations and -Wno-builtin-declaration-mismatch have been replaced with the correct -Waggressive-loop-optimizations and -Wbuiltin-declaration-mismatch.
I have not tried to keep the original format, since
This is actually one I did even before #2814, but it was blocked by my employer's review process. I have just rebased it and done a quick sanity check, hopefully I have not missed anything.
This change is