From patchwork Sat Jun 20 00:23:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Maltsev X-Patchwork-Id: 486943 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F23814030F for ; Sat, 20 Jun 2015 10:23:39 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=EUg/bqGS; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=WHZoIjn5byhoJsc22 4ZJ9VWRZ15E7/cnDaLwwR3w9VrowMW8hv9PXDv90f4/uKCZmGSa8AasWwzedszSl eRlwNnDmhq++AGjk+42Uy/tzCCtEP+3qfL0EwVltF+Dx9QbdIlcTEvraycXD4TXh s6W/MRkkQNJ5kAwiGvflwtGB84= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=wAmdyFiPkPKEbSA9wOvYD3G b2dY=; b=EUg/bqGSSj5PDO1oKWXP11GZI1H/3BefvI0IXWcB9yJVBDdWuuS/P6Q UK6A1Yp2Z87BJ2aT5br1I1e/5P1EssaokAyJiaxkr8SO8vS93t3hUv6hjWxpt7FB thcC69viykt6AvAwRr+YlNLzhMOWkRN/rLw6mNswZJYa2ERCbj/4= Received: (qmail 113183 invoked by alias); 20 Jun 2015 00:23:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 113171 invoked by uid 89); 20 Jun 2015 00:23:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 20 Jun 2015 00:23:29 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43173) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1Z66ZD-0002m7-76 for gcc-patches@gnu.org; Fri, 19 Jun 2015 20:23:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z66Z8-00088w-Rf for gcc-patches@gnu.org; Fri, 19 Jun 2015 20:23:26 -0400 Received: from mail-la0-x236.google.com ([2a00:1450:4010:c03::236]:33942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z66Z8-00088p-FZ for gcc-patches@gnu.org; Fri, 19 Jun 2015 20:23:22 -0400 Received: by labbc20 with SMTP id bc20so82873288lab.1 for ; Fri, 19 Jun 2015 17:23:21 -0700 (PDT) X-Received: by 10.152.6.196 with SMTP id d4mr20236854laa.40.1434759801534; Fri, 19 Jun 2015 17:23:21 -0700 (PDT) Received: from [192.168.123.200] ([77.41.78.126]) by mx.google.com with ESMTPSA id 4sm2837331lai.36.2015.06.19.17.23.20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Jun 2015 17:23:20 -0700 (PDT) Message-ID: <5584B276.1090901@gmail.com> Date: Sat, 20 Jun 2015 03:23:18 +0300 From: Mikhail Maltsev User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Jason Merrill , gcc-patches , Marek Polacek Subject: Re: [Patch, C++, PR65882] Check tf_warning flag in build_new_op_1 References: <553CC7D2.5050708@gmail.com> <558444DE.3070204@redhat.com> In-Reply-To: <558444DE.3070204@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::236 X-IsSubscribed: yes On 19.06.2015 19:35, Jason Merrill wrote: > OK, thanks. > > Sorry this took so long to review; please feel free to ping me every week. > > Jason I added the testcase from PR66467, bootstrapped and regtested on x86_64-linux. The final variant is attached. I applied it to trunk. I see that version 5.2 is set as target milestone for this bug. Should I backport the patch? diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index eb5e4c5..6656441 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-06-20 Mikhail Maltsev + + PR c++/65882 + * call.c (build_new_op_1): Check tf_warning flag in all cases. + 2015-06-19 Jason Merrill PR c++/66585 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 5d1891d..ba5da4c 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5640,8 +5640,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: @@ -5649,8 +5650,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/ChangeLog b/gcc/testsuite/ChangeLog index 42a0ee9d..89b859f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-06-20 Mikhail Maltsev + + PR c++/65882 + * g++.dg/diagnostic/inhibit-warn-1.C: New test. + * g++.dg/diagnostic/inhibit-warn-2.C: New test. + 2015-06-19 Eric Botcazou * gnat.dg/specs/debug1.ads: Adjust. diff --git a/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-1.C b/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-1.C new file mode 100644 index 0000000..5655eb4 --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-1.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 +struct type_function { + static constexpr bool value = false; +}; + +template +struct dependent_type { + typedef int type; +}; + +template +typename dependent_type<(5 > type_function::value)>::type +bar(); + +template +typename dependent_type<(5 > type_function::value)>::type +foo() +{ + return bar(); +} + +int main() +{ + foo(); +} diff --git a/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-2.C b/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-2.C new file mode 100644 index 0000000..cb16b4c --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/inhibit-warn-2.C @@ -0,0 +1,36 @@ +// PR c++/65882 +// PR c++/66467 +// { dg-do compile } + +template +struct A +{ + typedef int type; +}; + +struct B +{ + static const int value = 0; +}; + +template +struct C +{ + typedef int type; +}; + +template +struct F : B {}; + +class D +{ + template + typename A::type>::value || B::value>::type + operator=(Expr); // { dg-message "declared" } +}; + +void fn1() +{ + D opt; + opt = 0; // { dg-error "private" } +}