This is a follow-up patch for Sandra Loosemore's patch in this
thread: "reimplement -fstrict-volatile-bitfields, v3".

It was already posted a few weeks ago, but in the wrong thread.
Therefore I re-post it herewith.

It was initially suggested by Hans-Peter Nilsson, and I had much
help from him in putting everything together. Thanks again H-P.

Here is a short specification:

The -Wportable-volatility warning is an optional warning, to warn
about code for which separate incompatbile definitions on different
platforms (or between C and C++) exist even within gcc.
It will be usable for driver code you want to be portable on different
architectures.

This warning should only be emitted if the code is significantly
different when -fstrict-volatile-bitfields is used or not.

It should not be emitted for the code which is not affected by this
option.

In other words, it should be emitted on all bit-fields when the
definition or the context is volatile, except when the whole
structure is not AAPCS ABI compliant, i.e. packed or unaligned.

On the other hand you should always get the same
warnings if you combine -Wportable-volatility with
-fstrict-volatile-bitfields or not. And of course it should not
depend on the specific target that is used to compile.

I boot-strapped this on a i686-pc-linux-gnu and all Wportable-volatility
test cases are passed for C and C++.

Additionally I used a cross-compiler for arm-eabi to manually cross-check
that the warnings are independent of the target platform.

Regards
Bernd Edlinger                                    
2013-09-03  Bernd Edlinger  <bernd.edlin...@hotmail.de>

        Implement -Wportable-volatility warning to warn about
        code which accesses volatile structure members for
        which different ABI specifications exist.
        * expr.c (check_portable_volatility): New function.
        (expand_assignment): call check_portable_volatility.
        (expand_real_expr_1): Likewise.
        * fold-const.c (optimize_bit_field_compare): Handle
        warn_portable_volatility. Removed if-statement, because
        condition "flag_strict_volatile_bitfields > 0" is always false.
        * stor-layout.c (layout_decl): Handle warn_portable_volatility.
        * c-family/c.opt: Add -Wportable-volatility option.
        * doc/invoke.texi: Add documentation about -Wportable-volatility.

testsuite:
        c-c++-common/
        * Wportable-volatility-1.c: New testcase.
        * Wportable-volatility-2.c: New testcase.

Attachment: patch-portable-volatility.diff
Description: Binary data

Reply via email to