https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126822

            Bug ID: 126822
           Summary: -fhardened target warning cannot be controlled by
                    -Whardened
           Product: gcc
           Version: 16.1.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hello at bjornpagen dot com
  Target Milestone: ---
              Host: aarch64-apple-darwin24
            Target: aarch64-apple-darwin24
             Build: aarch64-apple-darwin24

On Darwin, -fhardened emits a target-support warning that has no warning
option. -Wno-hardened does not suppress it. -Wno-error=hardened does not demote
it under -Werror. GCC should classify this diagnostic as -Whardened.

Testcase:
int main(){return 0;}

Command:
g++-16 -fhardened -Whardened -Werror -c hardened.cc

Compiler output:
cc1plus: error: '-fhardened' not supported for this target [-Werror]
cc1plus: all warnings being treated as errors

Command:
g++-16 -fhardened -Whardened -Werror -Wno-error=hardened -c hardened.cc

Compiler output:
cc1plus: error: '-fhardened' not supported for this target [-Werror]
cc1plus: all warnings being treated as errors

Command:
g++-16 -fhardened -Wno-hardened -c hardened.cc

Compiler output:
cc1plus: warning: '-fhardened' not supported for this target

Expected result:
-Wno-hardened suppresses the warning. -Wno-error=hardened demotes it when
-Werror is active.

Versions tested:
GCC 16.1.0 reproduces the defect on aarch64-apple-darwin24.
GCC master commit 475e9efffaf8de781d7e17b687faf1807e104b01 was inspected, not
run on Darwin. The target-support diagnostic still uses warning class 0 in
gcc/toplev.cc.
No official Darwin GCC build is available.

Environment:
Using built-in specs.
COLLECT_GCC=g++-16
COLLECT_LTO_WRAPPER=/Users/bjorn/.gcc/versions/16.1.0/libexec/gcc/aarch64-apple-darwin24/16.1.0/lto-wrapper
Target: aarch64-apple-darwin24
Configured with: ../gcc-16.1.0/configure
--prefix=/Users/bjorn/.gcc/versions/16.1.0 --enable-languages=c,c++
--disable-nls --enable-checking=release --program-suffix=-16 --with-system-zlib
--build=aarch64-apple-darwin24
--with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 16.1.0 (GCC)

PR 117967 covers the driver-side version of this warning-class problem. This
report covers the separate cc1 diagnostic in gcc/toplev.cc.

Reply via email to