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.
This commit is contained in:
parent
8a15cd3396
commit
6e4d5300c1
2 changed files with 22 additions and 0 deletions
|
@ -20438,6 +20438,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),
|
||||
|
|
21
gcc/testsuite/g++.dg/cpp1z/constexpr-if37.C
Normal file
21
gcc/testsuite/g++.dg/cpp1z/constexpr-if37.C
Normal file
|
@ -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>();
|
||||
}
|
Loading…
Add table
Reference in a new issue