From patchwork Thu Aug 31 12:17:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 808226 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-461205-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ZVXxeEAE"; dkim-atps=neutral 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 3xjhHB5j3Fz9sMN for ; Thu, 31 Aug 2017 22:18:29 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=ZW19FOujfH8eprxByJHX9yrCSS2NCbuJHgQoCH3L6/cA7gjX6cy3C h6d0yoevBTzszDYA72DUczAMk5IV5tb5NuLFUtmxyz3lj9LI/hPhYSJEQ30+ueSG FWzSCTPDEEOrQp+49iU3OQVkNTcrm/octvSYYgltHDEvTcemcystMQ= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=EJfNOHEAbs7PedBqEiuQ41J9jJo=; b=ZVXxeEAEDLC+cO3bLMm/ AhjfwwD/heSAETGcmzYt8demySjM3nriUNDhME1K8vG+/kBWnvdBY4JA+zx23wUK ynZ9LoCxo7OJdHAux4hli3d315TibeCgz1rPuDhBjRhTSO+L88i0Jcaf4G2xAApG D3n6/6hNyfuAyYSi/pqAcw8= Received: (qmail 78269 invoked by alias); 31 Aug 2017 12:18:20 -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 78260 invoked by uid 89); 31 Aug 2017 12:18:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=ensued X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 31 Aug 2017 12:18:09 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 09233C047B8D for ; Thu, 31 Aug 2017 12:18:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 09233C047B8D Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=polacek@redhat.com Received: from redhat.com (ovpn-204-79.brq.redhat.com [10.40.204.79]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 68099B32C7; Thu, 31 Aug 2017 12:18:06 +0000 (UTC) Date: Thu, 31 Aug 2017 14:17:54 +0200 From: Marek Polacek To: GCC Patches , Jason Merrill Subject: C++ PATCH to fix ICE with -Wbool-operation (PR c++/82040) Message-ID: <20170831121754.GH17069@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.8.3 (2017-05-23) Here we got into re-entering the error reporting routines because the warning_at call wasn't guarded with "complain", and crash ensued. Bootstrapped/regtested on x86_64-linux, ok for trunk/7? 2017-08-31 Marek Polacek PR c++/82040 * typeck.c (cp_build_unary_op): Avoid re-entering reporting routines. * g++.dg/warn/Wbool-operation-1.C: New test. Marek diff --git gcc/cp/typeck.c gcc/cp/typeck.c index 171c2dfb57c..b303ceaede1 100644 --- gcc/cp/typeck.c +++ gcc/cp/typeck.c @@ -5982,6 +5982,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert, { /* Warn if the expression has boolean value. */ if (TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE + && (complain & tf_error) && warning_at (location, OPT_Wbool_operation, "%<~%> on an expression of type bool")) inform (location, "did you mean to use logical not (%)?"); diff --git gcc/testsuite/g++.dg/warn/Wbool-operation-1.C gcc/testsuite/g++.dg/warn/Wbool-operation-1.C index e69de29bb2d..4512b858287 100644 --- gcc/testsuite/g++.dg/warn/Wbool-operation-1.C +++ gcc/testsuite/g++.dg/warn/Wbool-operation-1.C @@ -0,0 +1,11 @@ +// PR c++/82040 +// { dg-do compile { target c++11 } } +// { dg-options "-Wbool-operation" } + +template +decltype (~c{}) +call () +{ + return ~false; // { dg-warning "on an expression of type bool" } +} +template int call();