From patchwork Tue Jun 30 08:43:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1319619 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=aMEq6OH4; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49wyZW3gHPz9sQx for ; Tue, 30 Jun 2020 18:44:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7C1763851C04; Tue, 30 Jun 2020 08:43:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C1763851C04 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1593506635; bh=+3aybhUkjGqvot+jA6FJ5dkuBNvMSJhifq7F6zbEEqg=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=aMEq6OH4TxxhDxI4BjYpjUljjED9poAmgWMru5l8Sc2ic5c7P532J7JkKvI0SrpLs C6HR7gL5Zt1eypv4iDyirvhQsAOBX+1kWpYLQyVnzZVSA/zgtb5M0qQAjhUdw9fvyW rQ+R0lTOMngXBln+gkbOToZpu1RNBqoRo7lpKEcI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id 97B143858D37 for ; Tue, 30 Jun 2020 08:43:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 97B143858D37 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-219-PlkneRk8NVWQyUGJUjbMxQ-1; Tue, 30 Jun 2020 04:43:48 -0400 X-MC-Unique: PlkneRk8NVWQyUGJUjbMxQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 37EE2100AA23; Tue, 30 Jun 2020 08:43:47 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-94.ams2.redhat.com [10.36.112.94]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C518B10013C0; Tue, 30 Jun 2020 08:43:46 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 05U8hhrq020944; Tue, 30 Jun 2020 10:43:43 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 05U8hg5P020943; Tue, 30 Jun 2020 10:43:42 +0200 Date: Tue, 30 Jun 2020 10:43:41 +0200 To: Richard Biener , Jason Merrill , Nathan Sidwell Subject: [PATCH] c-family: Avoid ICEs on calls to internal functions [PR95963] Message-ID: <20200630084341.GC8462@tucnak> MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! The following testcase ICEs since recent Martin's -Wnonnull changes, we see a CALL_EXPR and ICE because CALL_EXPR_FN is NULL, which is valid for internal function calls. Internal function calls don't have a function type, and will never have format_arg attribute on them nor will serve as the i18n routines -Wformat cares about. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2020-06-30 Jakub Jelinek PR c++/95963 * c-common.c (check_function_arguments_recurse): Don't crash on calls to internal functions. * g++.dg/cpp1z/launder9.C: New test. Jakub --- gcc/c-family/c-common.c.jj 2020-06-29 14:51:54.821086398 +0200 +++ gcc/c-family/c-common.c 2020-06-29 21:06:02.624773345 +0200 @@ -5815,7 +5815,7 @@ check_function_arguments_recurse (void ( return; } - if (TREE_CODE (param) == CALL_EXPR) + if (TREE_CODE (param) == CALL_EXPR && CALL_EXPR_FN (param)) { tree type = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (param))); tree attrs; --- gcc/testsuite/g++.dg/cpp1z/launder9.C.jj 2020-06-29 21:07:02.191932465 +0200 +++ gcc/testsuite/g++.dg/cpp1z/launder9.C 2020-06-29 21:08:19.137846260 +0200 @@ -0,0 +1,11 @@ +// PR c++/95963 +// { dg-do compile } +// { dg-options "-Wnonnull" } + +struct A { virtual void foo (); }; + +void +bar (A *p) +{ + __builtin_launder (p)->foo (); +}