Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

When I added -fcontracts to -std=c++26 in r16-8176, I forgot to also have it
imply -lstdc++exp.

gcc/cp/ChangeLog:

        * g++spec.cc (lang_specific_driver): Also set need_experimental
        for C++26 and C++29.

gcc/c-family/ChangeLog:

        * c-opts.cc (c_common_post_options): Adjust comment.
---
 gcc/c-family/c-opts.cc | 2 +-
 gcc/cp/g++spec.cc      | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index d27cf3fa6d5..9d275e60d35 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -1261,7 +1261,7 @@ c_common_post_options (const char **pfilename)
   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
                       flag_range_for_ext_temps, cxx_dialect >= cxx23);
 
-  /* Contracts are in C++26.  */
+  /* Contracts are in C++26.  Keep lang_specific_driver in sync.  */
   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
                       flag_contracts, cxx_dialect >= cxx26);
 
diff --git a/gcc/cp/g++spec.cc b/gcc/cp/g++spec.cc
index f8043244913..6a616faaa49 100644
--- a/gcc/cp/g++spec.cc
+++ b/gcc/cp/g++spec.cc
@@ -166,7 +166,13 @@ lang_specific_driver (struct cl_decoded_option 
**in_decoded_options,
 
       switch (decoded_options[i].opt_index)
        {
+         /* Contracts support requires -lstdc++exp, and c_common_post_options
+            enables it by default in C++26 and above.  */
        case OPT_fcontracts:
+       case OPT_std_c__26:
+       case OPT_std_c__29:
+       case OPT_std_gnu__26:
+       case OPT_std_gnu__29:
          need_experimental = true;
          break;
 

base-commit: f2977b445ea1bb99556061ce687eda21960b4f59
-- 
2.56.0

Reply via email to