From patchwork Thu Jan 23 18:11:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1228398 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-518157-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=Gvn5eTZO; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZiVqzSB6; 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 483VhW1Bjlz9s1x for ; Fri, 24 Jan 2020 05:11:22 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type :content-transfer-encoding; q=dns; s=default; b=MS5m5OsvHhwhnun2 bUeWE02XdCKnCtfsTdwC/ppHeSBm7gpaez/nHE3vLgFj+5TMCvMtUshxPql5w+aL AqDy9pfvOb8VKq1REBg04ThX64J22UgCVQbOMToya+j4zr7nRoJoXRMwsWNbkUmm z0Cp1DxF4XcvGTTZorPakERjfjc= 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:from :to:subject:date:message-id:content-type :content-transfer-encoding; s=default; bh=WyvDn0c9sLWZKXb3BHjh4f p+j7k=; b=Gvn5eTZOc62AEe38UhCD24eMw5HHjjAtybOEu1D8VBGNfIax04G+yg lKd1oRelJ60YhKrGcdfTuYJ0T8++6raKbJeP+o7kPIi/kxGS/iSzgIhWaRLK7FeM HMGkpFOJLKgTN+fN19ChiMWO738l3Lew5p5fcGic7zVqFWWVIJ4/Q= Received: (qmail 44876 invoked by alias); 23 Jan 2020 18:11:13 -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 44867 invoked by uid 89); 23 Jan 2020 18:11:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Jan 2020 18:11:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579803068; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OYrh+vV5yU/eF92KGBCe4LFm9sdlM+mCsH9kXRKFZyU=; b=ZiVqzSB6ocULkaUw4fYcOr7dX0Zhl0I4ikz9+0K2ZorC/UT39YeTgrh1aKjLQ30QVygpc3 bVi90ewUev3CWyzgxL6OV3KMA5az/J7/AgdLGExKJzVJLKtH6/7jgVRV2b8PU750wVVwAR nT7LLkaaAV0OElZTlcKtgZQIdFwzKtk= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-23-sfxUorW9MByPF7ghGsWNqA-1; Thu, 23 Jan 2020 13:11:06 -0500 Received: by mail-qt1-f198.google.com with SMTP id l25so2628731qtu.0 for ; Thu, 23 Jan 2020 10:11:06 -0800 (PST) Received: from barrymore.redhat.com (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id r185sm1320585qke.102.2020.01.23.10.11.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 10:11:04 -0800 (PST) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [COMMITTED] c++: Avoid ICE when constexpr __builtin_strchr fails. Date: Thu, 23 Jan 2020 13:11:03 -0500 Message-Id: <20200123181103.9384-1-jason@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes If we can't change the argument to &"...", use the original arg instead of the partially munged one. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/93331 - ICE with __builtin_strchr. * constexpr.c (cxx_eval_builtin_function_call): Use the original argument if we didn't manage to extract a STRING_CST. --- gcc/cp/constexpr.c | 3 +++ .../{gcc.c-torture/compile => c-c++-common}/pr34029-1.c | 0 2 files changed, 3 insertions(+) rename gcc/testsuite/{gcc.c-torture/compile => c-c++-common}/pr34029-1.c (100%) base-commit: 6d00f052ef209bacdd93f503b0c5fb428cc6c434 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 5864b67d4de..f6b8f331bc9 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -1293,6 +1293,7 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun, for (i = 0; i < nargs; ++i) { tree arg = CALL_EXPR_ARG (t, i); + tree oarg = arg; /* To handle string built-ins we need to pass ADDR_EXPR since expand_builtin doesn't know how to look in the values table. */ @@ -1327,6 +1328,8 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun, arg = braced_lists_to_strings (TREE_TYPE (arg), arg); if (TREE_CODE (arg) == STRING_CST) arg = build_address (arg); + else + arg = oarg; } args[i] = arg; diff --git a/gcc/testsuite/gcc.c-torture/compile/pr34029-1.c b/gcc/testsuite/c-c++-common/pr34029-1.c similarity index 100% rename from gcc/testsuite/gcc.c-torture/compile/pr34029-1.c rename to gcc/testsuite/c-c++-common/pr34029-1.c