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

Suppress shift warning for IAR compiler as well #7264

Merged
merged 1 commit into from Jun 20, 2018

Conversation

Projects
None yet
5 participants
@deepikabhavnani
Contributor

deepikabhavnani commented Jun 19, 2018

Description

Compiler gives invalid warning for shift operation, more details at https://github.com/ARMmbed/mbed-os/blob/master/drivers/MbedCRC.h#L23

Suppressing the warning for IAR compiler as well.

Pull request type

[X] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change

Issue: #7251

@cmonr

cmonr approved these changes Jun 20, 2018

LGTM.

@@ -32,6 +32,8 @@ but we check for ( width < 8) before performing shift, so it should not be an is
#elif defined ( __GNUC__ )
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshift-count-negative"
#elif defined (__ICCARM__)
#pragma diag_suppress=Pe062 // Shift count is negative

This comment has been minimized.

@cmonr

cmonr Jun 20, 2018

Contributor

+1 for the comment.

@cmonr cmonr added the needs: CI label Jun 20, 2018

@cmonr

This comment has been minimized.

Contributor

cmonr commented Jun 20, 2018

/morph build

@cmonr

This comment has been minimized.

Contributor

cmonr commented Jun 20, 2018

@ARMmbed/mbed-os-maintainers So far, this is the second PR withing the last couple of days that I've seen resort to disabling warnings instead of updating code. It's fine, but it feels a bit risky imo.

Do we want to start doing something different in regards to these types of PRs, or just continue as is?

@mbed-ci

This comment has been minimized.

mbed-ci commented Jun 20, 2018

Build : SUCCESS

Build number : 2393
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7264/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci

This comment has been minimized.

@kjbracey-arm

This comment has been minimized.

Contributor

kjbracey-arm commented Jun 20, 2018

You've got to look at it case-by-case.

This one is absolutely a useful warning, so you definitely wouldn't want to disable it globally, but the particular code technique used here - achieving effective conditional compilation via if - triggers it. There's already a kill of the same warning present for another toolchain there, and the code is elegant and clear, and I wouldn't want to change it just to satisfy a machine that generates a spurious warning. (The observed negative shift can never actually be executed, so the total code is legal, but the warning is generated in the expression parser before it figures out the flowgraph).

My general feeling is that if the code gets less elegant or you start being coerced into poorer coding style because of a purely-advisory warning, the warning should go. Whether that's killed locally or globally depends on general utility of the warning versus how common false positives are.

Compilers can generate so many possible warnings, but their utility can range from "C required diagnostic, cos this isn't valid C" (so why not an error?) to "I've detected a real logic anomaly" (thanks!) to "this C code wouldn't be valid C++" (so?).

@mbed-ci

This comment has been minimized.

@0xc0170 0xc0170 added ready for merge and removed needs: CI labels Jun 20, 2018

@cmonr cmonr merged commit 585558c into ARMmbed:master Jun 20, 2018

14 checks passed

AWS-CI uVisor Build & Test Success
Details
ci-morph-build build completed
Details
ci-morph-exporter build completed
Details
ci-morph-mbed2-build build completed
Details
ci-morph-test test completed
Details
continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
travis-ci/astyle Passed, 919 files
Details
travis-ci/docs Local docs testing has passed
Details
travis-ci/events Passed, runtime is 9947 cycles (+351 cycles)
Details
travis-ci/gitattributestest Local gitattributestest testing has passed
Details
travis-ci/licence_check Local licence_check testing has passed
Details
travis-ci/littlefs Passed, code size is 9964B (+0.00%)
Details
travis-ci/tools-py2.7 Local tools-py2.7 testing has passed
Details

@deepikabhavnani deepikabhavnani deleted the deepikabhavnani:crc_warn branch Jun 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment