public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4223] c++: contracts fixes Date: Tue, 22 Nov 2022 01:26:26 +0000 (GMT) [thread overview] Message-ID: <20221122012627.58839385841A@sourceware.org> (raw) https://gcc.gnu.org/g:b20a3854c9f2923ac02c26385dac0c68f4df1e66 commit r13-4223-gb20a3854c9f2923ac02c26385dac0c68f4df1e66 Author: Jason Merrill <jason@redhat.com> Date: Mon Nov 21 17:58:07 2022 -0500 c++: contracts fixes Fixing -Wunused-parm warnings and link errors depending on where -fcontracts appears on the command line. gcc/cp/ChangeLog: * contracts.cc (build_contract_condition_function): Set DECL_ARTIFICIAL on return value parm. * g++spec.cc (lang_specific_driver): Add -lstdc++exp just before -lstdc++. Diff: --- gcc/cp/contracts.cc | 1 + gcc/cp/g++spec.cc | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc index 26396439361..f3afcc62ba0 100644 --- a/gcc/cp/contracts.cc +++ b/gcc/cp/contracts.cc @@ -1434,6 +1434,7 @@ build_contract_condition_function (tree fndecl, bool pre) tree name = get_identifier ("__r"); tree parm = build_lang_decl (PARM_DECL, name, value_type); DECL_CONTEXT (parm) = fn; + DECL_ARTIFICIAL (parm) = true; DECL_ARGUMENTS (fn) = chainon (DECL_ARGUMENTS (fn), parm); *last = build_tree_list (NULL_TREE, value_type); diff --git a/gcc/cp/g++spec.cc b/gcc/cp/g++spec.cc index 257e49b7f3f..e599ac906f6 100644 --- a/gcc/cp/g++spec.cc +++ b/gcc/cp/g++spec.cc @@ -128,6 +128,9 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, /* By default, we throw on the math library if we have one. */ int need_math = (MATH_LIBRARY[0] != '\0'); + /* By default, we don't add -lstdc++exp. */ + bool need_experimental = false; + /* True if we saw -static. */ int static_link = 0; @@ -161,8 +164,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, switch (decoded_options[i].opt_index) { case OPT_fcontracts: - args[i] |= EXPERIMENTAL; - ++added; + need_experimental = true; break; case OPT_nostdlib: @@ -292,7 +294,8 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, #endif /* Add one for shared_libgcc or extra static library. */ - num_args = argc + added + need_math + (library > 0) * 4 + 1; + num_args = (argc + added + need_math + need_experimental + + (library > 0) * 4 + 1); /* For libc++, on most platforms, the ABI library (usually called libc++abi) is provided as a separate DSO, which we must also append. However, a platform might have the ability to forward the ABI library @@ -355,11 +358,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, &new_decoded_options[j]); } - if ((args[i] & EXPERIMENTAL) - && which_library == USE_LIBSTDCXX) - generate_option (OPT_l, "stdc++exp", 1, CL_DRIVER, - &new_decoded_options[++j]); - if ((args[i] & SKIPOPT) != 0) --j; @@ -370,6 +368,12 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, /* Add `-lstdc++' if we haven't already done so. */ if (library > 0) { + if (need_experimental && which_library == USE_LIBSTDCXX) + { + generate_option (OPT_l, "stdc++exp", 1, CL_DRIVER, + &new_decoded_options[j++]); + ++added_libraries; + } #ifdef HAVE_LD_STATIC_DYNAMIC if (library > 1 && !static_link) {
reply other threads:[~2022-11-22 1:26 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221122012627.58839385841A@sourceware.org \ --to=jason@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).