gcc - GNU Compiler Collection (original) (raw)

author Jason Merrill jason@redhat.com 2025-05-01 09:42:40 -0400
committer Jason Merrill jason@redhat.com 2025-05-03 09:30:19 -0400
commit 11e62bc6d9f8109a98facd1f90d4602869eb12e7 (patch)
tree f9fbab479ff43807f7b7e67a1ea22310c5152dde
parent c++: add fixed testcase [PR85944] (diff)

c++: let plain -Wabi warn about future changesHEADtrunkmaster

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.

-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.ccindex 40163821948b..f1c276f07cda 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)
1085 /* Change flag_abi_version to be the actual current ABI level, for the 1085 /* Change flag_abi_version to be the actual current ABI level, for the
1086 benefit of c_cpp_builtins, and to make comparison simpler. */ 1086 benefit of c_cpp_builtins, and to make comparison simpler. */
1087 const int latest_abi_version = 21; 1087 const int latest_abi_version = 21;
1088 /* Possibly different for non-default ABI fixes within a release. */
1089 const int default_abi_version = latest_abi_version;
1088 /* Generate compatibility aliases for ABI v18 (GCC 13) by default. */ 1090 /* Generate compatibility aliases for ABI v18 (GCC 13) by default. */
1089 const int abi_compat_default = 18; 1091 const int abi_compat_default = 18;
1090 1092
1093 if (flag_abi_version > latest_abi_version)
1094 warning (0, "%<-fabi-version=%d%> is not supported, using =%d",
1095 flag_abi_version, latest_abi_version);
1096
1097 SET_OPTION_IF_UNSET (&global_options, &global_options_set,
1098 flag_abi_version, default_abi_version);
1099
1091 #define clamp(X) if (X == 0 | X > latest_abi_version) X = latest_abi_version 1100
1092 clamp (flag_abi_version); 1101 clamp (flag_abi_version);
1093 clamp (warn_abi_version); 1102 /* Don't clamp warn_abi_version, let it be 0 or out of bounds. */
1094 clamp (flag_abi_compat_version); 1103 clamp (flag_abi_compat_version);
1095 #undef clamp 1104 #undef clamp
1096 1105
@@ -1101,24 +1110,17 @@ c_common_post_options (const char **pfilename)
1101 flag_abi_compat_version = warn_abi_version; 1110 flag_abi_compat_version = warn_abi_version;
1102 else if (warn_abi_version == -1 && flag_abi_compat_version == -1) 1111 else if (warn_abi_version == -1 && flag_abi_compat_version == -1)
1103 { 1112 {
1104 warn_abi_version = latest_abi_version; 1113 warn_abi_version = 0;
1105 if (flag_abi_version == latest_abi_version) 1114 if (flag_abi_version == default_abi_version)
1106 { 1115 flag_abi_compat_version = abi_compat_default;
1107 auto_diagnostic_group d;
1108 if (warning (OPT_Wabi, "%<-Wabi%> won%'t warn about anything"))
1109 {
1110 inform (input_location, "%<-Wabi%> warns about differences "
1111 "from the most up-to-date ABI, which is also used "
1112 "by default");
1113 inform (input_location, "use e.g. %<-Wabi=11%> to warn about "
1114 "changes from GCC 7");
1115 }
1116 flag_abi_compat_version = abi_compat_default;
1117 }
1118 else 1116 else
1119 flag_abi_compat_version = latest_abi_version; 1117 flag_abi_compat_version = latest_abi_version;
1120 } 1118 }
1121 1119
1120 /* Allow warnings vs ABI versions beyond what we currently support. */
1121 if (warn_abi_version == 0)
1122 warn_abi_version = 1000;
1123
1122 /* By default, enable the new inheriting constructor semantics along with ABI 1124 /* By default, enable the new inheriting constructor semantics along with ABI
1123 11. New and old should coexist fine, but it is a change in what 1125 11. New and old should coexist fine, but it is a change in what
1124 artificial symbols are generated. */ 1126 artificial symbols are generated. */