From patchwork Wed Jun 12 17:20:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 1947046 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=k0IKRHdD; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Vzsl84GsTz20Pb for ; Thu, 13 Jun 2024 03:21:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 098353882178 for ; Wed, 12 Jun 2024 17:21:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by sourceware.org (Postfix) with ESMTPS id 0E5B93870899 for ; Wed, 12 Jun 2024 17:20:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E5B93870899 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=linux.intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0E5B93870899 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718212842; cv=none; b=LIvnBG280Dj1lc3ynT//EHfnkH+rHEv8luBCdElZnXsO2A283bISvL4mGJQuzkNcPY2sULO3sp4MjT3knTIAz48w3bXXzGIkVE309fmMdjxEqpUOUFgJ8E54eU8wACrHprByQfuGQck6yfpcHaL2Rf8ZWCIPA8EhRTjuJhzY+RY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718212842; c=relaxed/simple; bh=pn92SRGdMBLpg13MxZKlecMeQ5Nl+HDGoSoK2bJj4HI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=x/5Qqjd0KLO3ADHjauW/CH5cWNfmUl8YPex0/fPInsBdJtYjGyKAuOu2JtytuTOc9IQLno3PiHSuv1Aq2gaQB7Fu3EI2hdC23GtfekkFLcPbXsgcBwbSoeVd8EhVKCPWyHx1bh9Li90Nq8efK9+gJYJHp0y15FhJd2pBFXcVQhk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718212840; x=1749748840; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=pn92SRGdMBLpg13MxZKlecMeQ5Nl+HDGoSoK2bJj4HI=; b=k0IKRHdDlVqIAcKZRMWplvu1Pd4LOITbT2USr+1uEUTUcOoWRhyPIwoO +OTjkK4scZIDYzmbIMgUYSyjoKR1UDtwOTXHjtORLJe8M0DkdWu7kdo0P e48Robkj7tvJbzlosvv1JXP8/eCNQMCVGmJYmd/9RZLqhwV6xVl/w+7fA RaA3LP7yuH5ZIFwyUS6OX5rBgRCIp0ZEpRmsIk0bZngKd/YmlWjMYeRtj 5wwZH8vHTJtRBbQxrNTH6pdkrPTloAcw9CSkkgYq9xNXwpYdLJaFdAJTH P6mETma6a3w7+36TEVRZv7UBbyTg6P+30/X7ZVCtlXA6kWJTBTEwSIVgC A==; X-CSE-ConnectionGUID: nQw/XXdXTTm1300LH1L5vQ== X-CSE-MsgGUID: ZYypXtRVSY6o+EHsR2cOVg== X-IronPort-AV: E=McAfee;i="6700,10204,11101"; a="12039719" X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="12039719" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 10:20:39 -0700 X-CSE-ConnectionGUID: WY0Ex780QJaxIqe6E1O6QQ== X-CSE-MsgGUID: Ok11v//hRxao5EWGdhk8Vw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="44796874" Received: from tassilo.jf.intel.com ([10.54.38.190]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 10:20:39 -0700 From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Andi Kleen Subject: [PATCH 1/3] Remove const char * support for asm constexpr Date: Wed, 12 Jun 2024 10:20:29 -0700 Message-ID: <20240612172031.3827584-1-ak@linux.intel.com> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org asm constexpr now only accepts the same string types as C++26 assert, e.g. string_view and string. Adjust test suite and documentation. gcc/cp/ChangeLog: * parser.cc (cp_parser_asm_string_expression): Remove support for const char * for asm constexpr. gcc/ChangeLog: * doc/extend.texi: Use std::string_view in asm constexpr example. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/constexpr-asm-1.C: Use std::std_string_view. * g++.dg/cpp1z/constexpr-asm-3.C: Dito. --- gcc/cp/parser.cc | 7 ------- gcc/doc/extend.texi | 3 ++- gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C | 12 +++++++----- gcc/testsuite/g++.dg/cpp1z/constexpr-asm-3.C | 12 +++++++----- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index de5f0483c120..98e8ca10ac40 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -22852,13 +22852,6 @@ cp_parser_asm_string_expression (cp_parser *parser) tree string = cp_parser_constant_expression (parser); if (string != error_mark_node) string = cxx_constant_value (string, tf_error); - if (TREE_CODE (string) == NOP_EXPR) - string = TREE_OPERAND (string, 0); - if (TREE_CODE (string) == ADDR_EXPR - && TREE_CODE (TREE_OPERAND (string, 0)) == STRING_CST) - string = TREE_OPERAND (string, 0); - if (TREE_CODE (string) == VIEW_CONVERT_EXPR) - string = TREE_OPERAND (string, 0); cexpr_str cstr (string); if (!cstr.type_check (tok->location)) return error_mark_node; diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 17e26c5004c1..ee3644a52645 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -10716,7 +10716,8 @@ message. Any string is converted to the character set of the source code. When this feature is available the @code{__GXX_CONSTEXPR_ASM__} cpp symbol is defined. @example -constexpr const char *genfoo() @{ return "foo"; @} +#include +constexpr std::string_view genfoo() @{ return "foo"; @} void function() @{ diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C index 7cc6b37d6208..311209acb43b 100644 --- a/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C @@ -1,22 +1,24 @@ /* { dg-do compile } */ -/* { dg-options "-std=gnu++11" } */ +/* { dg-options "-std=gnu++17" } */ -constexpr const char *genfoo () +#include + +constexpr std::string_view genfoo () { return "foo %1,%0"; } -constexpr const char *genoutput () +constexpr std::string_view genoutput () { return "=r"; } -constexpr const char *geninput () +constexpr std::string_view geninput () { return "r"; } -constexpr const char *genclobber () +constexpr std::string_view genclobber () { return "memory"; } diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-3.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-3.C index d33631876bdc..ef8a35a0b3ba 100644 --- a/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-3.C +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-3.C @@ -1,22 +1,24 @@ /* { dg-do compile } */ -/* { dg-options "-std=gnu++11" } */ +/* { dg-options "-std=gnu++17" } */ -constexpr const char *genfoo () +#include + +constexpr std::string_view genfoo () { return "foo %1,%0"; } -constexpr const char *genoutput () +constexpr std::string_view genoutput () { return "=r"; } -constexpr const char *geninput () +constexpr std::string_view geninput () { return "r"; } -constexpr const char *genclobber () +constexpr std::string_view genclobber () { return "memory"; }