diff options
author | Jason Merrill <jason@redhat.com> | 2025-05-01 09:42:40 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2025-05-07 12:04:03 -0400 |
commit | fa55a6c92b50543352fef16e962511984998f123 (patch) | |
tree | 555f12de2da66d038226fc5a0689bafc5d80b871 /gcc | |
parent | 77780c31485eeb71e9fabf8ea9d4b1af0c3be595 (diff) | |
download | gcc-fa55a6c92b50543352fef16e962511984998f123.zip gcc-fa55a6c92b50543352fef16e962511984998f123.tar.gz gcc-fa55a6c92b50543352fef16e962511984998f123.tar.bz2 |
c++: let plain -Wabi warn about future changes
c_common_post_options limits flag_abi_version and flag_abi_compat_version to
actual ABI version numbers, but let's not do that for warn_abi_version; we
might want to add a warning relative to a future ABI version that isn't
available in the current release, such backporting the PR120012 warning.
Also allow plain -Wabi to include such a warning without complaining that
it's useless.
Also warn about an unsupported -fabi-version argument.
gcc/c-family/ChangeLog:
* c-opts.cc (c_common_post_options): Let plain -Wabi warn
about changes in a future version.
(cherry picked from commit 11e62bc6d9f8109a98facd1f90d4602869eb12e7)
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-family/c-opts.cc | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index d43b3ae..108eaab 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -1085,12 +1085,21 @@ c_common_post_options (const char **pfilename) /* Change flag_abi_version to be the actual current ABI level, for the benefit of c_cpp_builtins, and to make comparison simpler. */ const int latest_abi_version = 20; + /* Possibly different for non-default ABI fixes within a release. */ + const int default_abi_version = latest_abi_version; /* Generate compatibility aliases for ABI v13 (8.2) by default. */ const int abi_compat_default = 13; + if (flag_abi_version > latest_abi_version) + warning (0, "%<-fabi-version=%d%> is not supported, using =%d", + flag_abi_version, latest_abi_version); + + SET_OPTION_IF_UNSET (&global_options, &global_options_set, + flag_abi_version, default_abi_version); + #define clamp(X) if (X == 0 || X > latest_abi_version) X = latest_abi_version clamp (flag_abi_version); - clamp (warn_abi_version); + /* Don't clamp warn_abi_version, let it be 0 or out of bounds. */ clamp (flag_abi_compat_version); #undef clamp @@ -1101,24 +1110,17 @@ c_common_post_options (const char **pfilename) flag_abi_compat_version = warn_abi_version; else if (warn_abi_version == -1 && flag_abi_compat_version == -1) { - warn_abi_version = latest_abi_version; - if (flag_abi_version == latest_abi_version) - { - auto_diagnostic_group d; - if (warning (OPT_Wabi, "%<-Wabi%> won%'t warn about anything")) - { - inform (input_location, "%<-Wabi%> warns about differences " - "from the most up-to-date ABI, which is also used " - "by default"); - inform (input_location, "use e.g. %<-Wabi=11%> to warn about " - "changes from GCC 7"); - } - flag_abi_compat_version = abi_compat_default; - } + warn_abi_version = 0; + if (flag_abi_version == default_abi_version) + flag_abi_compat_version = abi_compat_default; else flag_abi_compat_version = latest_abi_version; } + /* Allow warnings vs ABI versions beyond what we currently support. */ + if (warn_abi_version == 0) + warn_abi_version = 1000; + /* By default, enable the new inheriting constructor semantics along with ABI 11. New and old should coexist fine, but it is a change in what artificial symbols are generated. */ |