[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
This commit is contained in:
parent
ce52e0ffb4
commit
f0efd92502
|
@ -1,3 +1,9 @@
|
||||||
|
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.
|
||||||
|
|
||||||
2019-07-31 Richard Biener <rguenther@suse.de>
|
2019-07-31 Richard Biener <rguenther@suse.de>
|
||||||
|
|
||||||
PR tree-optimization/91257
|
PR tree-optimization/91257
|
||||||
|
|
|
@ -164,6 +164,7 @@ __CMSE_TT_ASM (at)
|
||||||
|
|
||||||
/* FIXME: diagnose use outside cmse_nonsecure_entry functions. */
|
/* FIXME: diagnose use outside cmse_nonsecure_entry functions. */
|
||||||
__extension__ static __inline int __attribute__ ((__always_inline__))
|
__extension__ static __inline int __attribute__ ((__always_inline__))
|
||||||
|
__attribute__ ((warn_unused_result))
|
||||||
cmse_nonsecure_caller (void)
|
cmse_nonsecure_caller (void)
|
||||||
{
|
{
|
||||||
return __builtin_arm_cmse_nonsecure_caller ();
|
return __builtin_arm_cmse_nonsecure_caller ();
|
||||||
|
@ -184,6 +185,7 @@ cmse_nonsecure_caller (void)
|
||||||
#define CMSE_MPU_READ 8
|
#define CMSE_MPU_READ 8
|
||||||
|
|
||||||
__extension__ void *
|
__extension__ void *
|
||||||
|
__attribute__ ((warn_unused_result))
|
||||||
cmse_check_address_range (void *, size_t, int);
|
cmse_check_address_range (void *, size_t, int);
|
||||||
|
|
||||||
#define cmse_check_pointed_object(p, f) \
|
#define cmse_check_pointed_object(p, f) \
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2019-07-31 Joel Hutton <Joel.Hutton@arm.com>
|
||||||
|
|
||||||
|
* gcc.target/arm/cmse/cmse-17.c: New test.
|
||||||
|
|
||||||
2019-07-30 Martin Sebor <msebor@redhat.com>
|
2019-07-30 Martin Sebor <msebor@redhat.com>
|
||||||
|
|
||||||
PR testsuite/91258
|
PR testsuite/91258
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-options "-mcmse"} */
|
||||||
|
|
||||||
|
#include <arm_cmse.h>
|
||||||
|
|
||||||
|
void foo()
|
||||||
|
{
|
||||||
|
int *data;
|
||||||
|
cmse_check_address_range((int*)data, 0, 0); /* { dg-warning "ignoring return value" } */
|
||||||
|
}
|
|
@ -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>
|
2019-07-22 Martin Liska <mliska@suse.cz>
|
||||||
|
|
||||||
* config/pa/stublib.c: Remove stub symbol __gnu_lto_v1.
|
* config/pa/stublib.c: Remove stub symbol __gnu_lto_v1.
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
address range. See ACLE changes for ARMv8-M. */
|
address range. See ACLE changes for ARMv8-M. */
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
__attribute__ ((warn_unused_result))
|
||||||
cmse_check_address_range (void *p, size_t size, int flags)
|
cmse_check_address_range (void *p, size_t size, int flags)
|
||||||
{
|
{
|
||||||
cmse_address_info_t permb, perme;
|
cmse_address_info_t permb, perme;
|
||||||
|
|
Loading…
Reference in New Issue