check_cxx_compiler_flag broken for -fstack-clash-protection, clang 11, aarch64
On aarch64 and clang 11, the -fstack-clash-protection is accepted but with a diagnostic:
# clang++ -fstack-clash-protection simple.cc
clang-11: warning: argument unused during compilation: '-fstack-clash-protection' [-Wunused-command-line-argument]
# echo $?
0
However, check_cxx_compiler_flag thinks the flag is supported. This is because "argument unused during compilation" is checked for Objective C and Objective C++ sources, but ignored for C and C++ sources:
if(_lang STREQUAL "C")
set(_lang_src "int main(void) { return 0; }")
set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C")
elseif(_lang STREQUAL "CXX")
set(_lang_src "int main() { return 0; }")
set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C\\+\\+")
...
elseif(_lang STREQUAL "OBJC")
set(_lang_src [=[
#ifndef __OBJC__
# error "Not an Objective-C compiler"
#endif
int main(void) { return 0; }]=])
set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for Objective-C" # GNU
FAIL_REGEX "argument unused during compilation: .*") # Clang
elseif(_lang STREQUAL "OBJCXX")
set(_lang_src [=[
#ifndef __OBJC__
# error "Not an Objective-C++ compiler"
#endif
int main(void) { return 0; }]=])
set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for Objective-C\\+\\+" # GNU
FAIL_REGEX "argument unused during compilation: .*") # Clang