r273924 - in /trunk: gcc/ChangeLog gcc/config/a...

ktkachov@gcc.gnu.org ktkachov@gcc.gnu.org
Wed Jul 31 08:56:00 GMT 2019


Author: ktkachov
Date: Wed Jul 31 08:56:35 2019
New Revision: 273924

URL: https://gcc.gnu.org/viewcvs?rev=273924&root=gcc&view=rev
Log:
[Arm][CMSE]Add warn_unused_return attribute to cmse functions

At present it is possible to call the CMSE functions for checking
addresses (such as cmse_check_address_range) and  forget to check/use
the return value. This patch makes the interfaces more robust against
programmer error by marking these functions with the warn_unused_result
attribute. With this set, any use of these functions that does not use
the result will produce a warning.

This produces a warning on default warn levels when the result of the
cmse functions is not used.

For the following function:
void foo()
{
     int *data;
     cmse_check_address_range((int*)data, 0, 0);
}
The following warning is emitted:
warning: ignoring return value of 'cmse_check_address_range' declared
with attribute 'warn_unused_result' [-Wunused-result]
     6 |  cmse_check_address_range((int*)data, 0, 0);
        |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

gcc/ChangeLog:

2019-07-31  Joel Hutton  <Joel.Hutton@arm.com>

         * config/arm/arm_cmse.h (cmse_nonsecure_caller): Add
warn_unused_result attribute.
         (cmse_check_address_range): Add warn_unused_result attribute.

libgcc/ChangeLog:

2019-07-31  Joel Hutton  <Joel.Hutton@arm.com>

         * config/arm/cmse.c (cmse_check_address_range): Add
warn_unused_result attribute.

2019-07-31  Joel Hutton  <Joel.Hutton@arm.com>

         * gcc.target/arm/cmse/cmse-17.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/arm/cmse/cmse-17.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm_cmse.h
    trunk/gcc/testsuite/ChangeLog
    trunk/libgcc/ChangeLog
    trunk/libgcc/config/arm/cmse.c



More information about the Gcc-cvs mailing list