public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, C++, PR65882] Check tf_warning flag in build_new_op_1
@ 2015-04-26 11:11 Mikhail Maltsev
  2015-06-09  7:53 ` Marek Polacek
  2015-06-19 16:43 ` Jason Merrill
  0 siblings, 2 replies; 9+ messages in thread
From: Mikhail Maltsev @ 2015-04-26 11:11 UTC (permalink / raw)
  To: Jason Merrill, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 113 bytes --]

The attached patch was bootstrapped and regtested on
x86_64-unknown-linux-gnu.

-- 
Regards,
    Mikhail Maltsev

[-- Attachment #2: pr-65882.cl.txt --]
[-- Type: text/plain, Size: 260 bytes --]

gcc/cp/ChangeLog:

2015-04-26  Mikhail Maltsev  <maltsevm@gmail.com>

	* call.c (build_new_op_1): Check tf_warning flag in all cases

gcc/testsuite/ChangeLog:

2015-04-26  Mikhail Maltsev  <maltsevm@gmail.com>

	* g++.dg/diagnostic/inhibit-warn.C: New test.



[-- Attachment #3: pr-65882.patch --]
[-- Type: text/plain, Size: 1927 bytes --]

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 7bdf236..689d542 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -5677,8 +5677,9 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1,
     case TRUTH_ORIF_EXPR:
     case TRUTH_AND_EXPR:
     case TRUTH_OR_EXPR:
-      warn_logical_operator (loc, code, boolean_type_node,
-			     code_orig_arg1, arg1, code_orig_arg2, arg2);
+      if (complain & tf_warning)
+	warn_logical_operator (loc, code, boolean_type_node,
+			       code_orig_arg1, arg1, code_orig_arg2, arg2);
       /* Fall through.  */
     case GT_EXPR:
     case LT_EXPR:
@@ -5686,8 +5687,9 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1,
     case LE_EXPR:
     case EQ_EXPR:
     case NE_EXPR:
-      if ((code_orig_arg1 == BOOLEAN_TYPE)
-	  ^ (code_orig_arg2 == BOOLEAN_TYPE))
+      if ((complain & tf_warning)
+	  && ((code_orig_arg1 == BOOLEAN_TYPE)
+	      ^ (code_orig_arg2 == BOOLEAN_TYPE)))
 	maybe_warn_bool_compare (loc, code, arg1, arg2);
       /* Fall through.  */
     case PLUS_EXPR:
diff --git a/gcc/testsuite/g++.dg/diagnostic/inhibit-warn.C b/gcc/testsuite/g++.dg/diagnostic/inhibit-warn.C
new file mode 100644
index 0000000..5655eb4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/inhibit-warn.C
@@ -0,0 +1,32 @@
+// PR c++/65882
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wbool-compare" }
+
+// Check that we don't ICE because of reentering error reporting routines while
+// evaluating template parameters
+
+template<typename>
+struct type_function {
+  static constexpr bool value = false;
+};
+
+template<bool>
+struct dependent_type {
+  typedef int type;
+};
+
+template<typename T>
+typename dependent_type<(5 > type_function<T>::value)>::type
+bar();
+
+template<typename T>
+typename dependent_type<(5 > type_function<T>::value)>::type
+foo()
+{
+  return bar<int>();
+}
+
+int main()
+{
+  foo<int>();
+}

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-06-26 21:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-26 11:11 [Patch, C++, PR65882] Check tf_warning flag in build_new_op_1 Mikhail Maltsev
2015-06-09  7:53 ` Marek Polacek
2015-06-19 16:43 ` Jason Merrill
2015-06-20  0:36   ` Mikhail Maltsev
2015-06-22 17:00     ` Jason Merrill
2015-06-24 16:05       ` Christophe Lyon
2015-06-24 20:39         ` Mikhail Maltsev
2015-06-26 10:02           ` James Greenhalgh
2015-06-26 21:59           ` Jason Merrill

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).