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 r12-8510] c++: -Waddress and value-dependent expr [PR105885] Date: Thu, 23 Jun 2022 15:45:59 +0000 (GMT) [thread overview] Message-ID: <20220623154559.69603385380D@sourceware.org> (raw) https://gcc.gnu.org/g:b96b64bec37c3dddf1f0f93c27ceb4fd5685c70a commit r12-8510-gb96b64bec37c3dddf1f0f93c27ceb4fd5685c70a Author: Jason Merrill <jason@redhat.com> Date: Wed Jun 22 23:50:23 2022 -0400 c++: -Waddress and value-dependent expr [PR105885] We already suppress various warnings for code that would be tautological if written directly, but not when it's the result of template substitution. It seems we need to do this for -Waddress as well. PR c++/105885 gcc/cp/ChangeLog: * pt.cc (tsubst_copy_and_build): Also suppress -Waddress for comparison of dependent operands. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/constexpr-if37.C: New test. Diff: --- gcc/cp/pt.cc | 1 + gcc/testsuite/g++.dg/cpp1z/constexpr-if37.C | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 67238000109..e8bf1692c74 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -20364,6 +20364,7 @@ tsubst_copy_and_build (tree t, warning_sentinel s2(warn_div_by_zero, was_dep); warning_sentinel s3(warn_logical_op, was_dep); warning_sentinel s4(warn_tautological_compare, was_dep); + warning_sentinel s5(warn_address, was_dep); tree r = build_x_binary_op (input_location, TREE_CODE (t), diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-if37.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-if37.C new file mode 100644 index 00000000000..e11e02cfa0e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-if37.C @@ -0,0 +1,21 @@ +// PR c++/105885 +// { dg-do compile { target c++17 } } +// { dg-additional-options -Wall } + +int i; + +template<const char* ARG = nullptr> +void test() { + if constexpr(ARG == nullptr) { + ++i; + } else { + --i; + } +} + +const char CONSTSTR[] = {'\n', '\t', ' ', '\0'}; + +int main() { + test(); + test<CONSTSTR>(); +}
reply other threads:[~2022-06-23 15:45 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=20220623154559.69603385380D@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).