]> git.ipfire.org Git - thirdparty/gcc.git/commit
target: missing -Whardened with -fcf-protection=none [PR114606]
authorMarek Polacek <polacek@redhat.com>
Fri, 5 Apr 2024 16:37:19 +0000 (12:37 -0400)
committerMarek Polacek <polacek@redhat.com>
Wed, 10 Apr 2024 21:27:38 +0000 (17:27 -0400)
commitb8b148bc22673689fda19711b428b544462be2e4
tree8fd7381dbafde56ad43fefc10215cfae3eb8bb7c
parent4a94551d7eaaf7a75c5195fc0bf4af94185a04c7
target: missing -Whardened with -fcf-protection=none [PR114606]

-Whardened warns when -fhardened couldn't enable a hardening option
because that option was disabled on the command line, e.g.:

$ ./cc1plus -quiet g.C -fhardened -O2 -fstack-protector
cc1plus: warning: '-fstack-protector-strong' is not enabled by '-fhardened' because it was specified on the command line [-Whardened]

but it doesn't work as expected with -fcf-protection=none:

$ ./cc1plus -quiet g.C -fhardened -O2 -fcf-protection=none

because we're checking == CF_NONE which doesn't distinguish between nothing
and -fcf-protection=none.  I should have used opts_set, like below.

PR target/114606

gcc/ChangeLog:

* config/i386/i386-options.cc (ix86_option_override_internal): Use
opts_set rather than checking == CF_NONE.

gcc/testsuite/ChangeLog:

* gcc.target/i386/fhardened-1.c: New test.
* gcc.target/i386/fhardened-2.c: New test.

Reviewed-by: Jakub Jelinek <jakub@redhat.com>
gcc/config/i386/i386-options.cc
gcc/testsuite/gcc.target/i386/fhardened-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/fhardened-2.c [new file with mode: 0644]