]> gcc.gnu.org Git - gcc.git/commit
c++: failure to suppress -Wsizeof-array-div in template [PR114983]
authorMarek Polacek <polacek@redhat.com>
Wed, 8 May 2024 21:02:49 +0000 (17:02 -0400)
committerMarek Polacek <polacek@redhat.com>
Thu, 9 May 2024 19:25:06 +0000 (15:25 -0400)
commit646db3d30bd071a1b671b4f91c9ea2ab7f2be21c
treef34b59a7cbc524be0c68f64d914ea9897b21b8d0
parente02b5683e77c2b4317b23be72e43b6e6cc6c8e5b
c++: failure to suppress -Wsizeof-array-div in template [PR114983]

-Wsizeof-array-div offers a way to suppress the warning by wrapping
the second operand of the division in parens:

  sizeof (samplesBuffer) / (sizeof(unsigned char))

but this doesn't work in a template, because we fail to propagate
the suppression bits.  Do it, then.

The finish_parenthesized_expr hunk is not needed because suppress_warning
isn't very fine-grained.  But I think it makes sense to be explicit and
not rely on OPT_Wparentheses also suppressing OPT_Wsizeof_array_div.

PR c++/114983

gcc/cp/ChangeLog:

* pt.cc (tsubst_expr) <case SIZEOF_EXPR>: Use copy_warning.
* semantics.cc (finish_parenthesized_expr): Also suppress
-Wsizeof-array-div.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wsizeof-array-div3.C: New test.
gcc/cp/pt.cc
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/warn/Wsizeof-array-div3.C [new file with mode: 0644]
This page took 0.084174 seconds and 6 git commands to generate.