aboutsummaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
authorJoel Hutton <Joel.Hutton@arm.com>2019-07-31 08:56:35 +0000
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>2019-07-31 08:56:35 +0000
commitf0efd92502a0eb33c8f8f9e1ea03b25a714b2d72 (patch)
tree07a1f2d0cb396e93b11d345531d37071cc7a521b /libgcc
parentce52e0ffb4f1ea7bd4fb99aea5dda75d260e438f (diff)
downloadgcc-f0efd92502a0eb33c8f8f9e1ea03b25a714b2d72.zip
gcc-f0efd92502a0eb33c8f8f9e1ea03b25a714b2d72.tar.gz
gcc-f0efd92502a0eb33c8f8f9e1ea03b25a714b2d72.tar.bz2
[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. From-SVN: r273924
Diffstat (limited to 'libgcc')
-rw-r--r--libgcc/ChangeLog5
-rw-r--r--libgcc/config/arm/cmse.c1
2 files changed, 6 insertions, 0 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index 7997ad8..c9aea1d 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,8 @@
+2019-07-31 Joel Hutton <Joel.Hutton@arm.com>
+
+ * config/arm/cmse.c (cmse_check_address_range): Add
+ warn_unused_result attribute.
+
2019-07-22 Martin Liska <mliska@suse.cz>
* config/pa/stublib.c: Remove stub symbol __gnu_lto_v1.
diff --git a/libgcc/config/arm/cmse.c b/libgcc/config/arm/cmse.c
index 34a46fd..0c5a3ea 100644
--- a/libgcc/config/arm/cmse.c
+++ b/libgcc/config/arm/cmse.c
@@ -30,6 +30,7 @@
address range. See ACLE changes for ARMv8-M. */
void *
+__attribute__ ((warn_unused_result))
cmse_check_address_range (void *p, size_t size, int flags)
{
cmse_address_info_t permb, perme;