diff options
-rw-r--r-- | gcc/cp/call.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wlogical-op-4.C | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 5715a7c..f7c5d9d 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -7335,7 +7335,7 @@ build_new_op (const op_location_t &loc, enum tree_code code, int flags, case TRUTH_ORIF_EXPR: case TRUTH_AND_EXPR: case TRUTH_OR_EXPR: - if (complain & tf_warning) + if ((complain & tf_warning) && !processing_template_decl) warn_logical_operator (loc, code, boolean_type_node, code_orig_arg1, arg1, code_orig_arg2, arg2); diff --git a/gcc/testsuite/g++.dg/warn/Wlogical-op-4.C b/gcc/testsuite/g++.dg/warn/Wlogical-op-4.C new file mode 100644 index 0000000..745c911 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wlogical-op-4.C @@ -0,0 +1,23 @@ +// PR c++/107755 +// { dg-do compile } +// { dg-options "-Wlogical-op" } + +struct Foo +{ + operator bool() const { return false; } +}; + +bool a; +Foo b; + +template <typename ignored> +static bool Bar() +{ + return (true && (false ? a : b)); + return (false || (false ? a : b)); +} + +bool Baz() +{ + return Bar<void>(); +} |