From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2078.outbound.protection.outlook.com [40.107.7.78]) by sourceware.org (Postfix) with ESMTPS id D1C33385697D for ; Thu, 6 Jul 2023 13:58:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D1C33385697D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WcUD7cvCYDQHZ03HTccqHC7Lyr6Ss3N8k7hBDjqO5B0=; b=J3+qwA6FP7tgYR0ZylXvyzLbmzluy8S4xiae71wTFdF8zHiAqAcsa4eAZwLlfHm8DiS3HtyVqX+MLLEI4qAOwojcrykyM8nwIDGdoWnvEQ5qG358TXh8ABBPhqwVfxebJm/M/nU14PpcoqdPxePLvQ0yud1ZPZe5yAJzzLuIsmg= Received: from DU2PR04CA0047.eurprd04.prod.outlook.com (2603:10a6:10:234::22) by GV1PR08MB8404.eurprd08.prod.outlook.com (2603:10a6:150:80::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Thu, 6 Jul 2023 13:58:22 +0000 Received: from DBAEUR03FT044.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:234:cafe::4e) by DU2PR04CA0047.outlook.office365.com (2603:10a6:10:234::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.18 via Frontend Transport; Thu, 6 Jul 2023 13:58:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT044.mail.protection.outlook.com (100.127.142.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.24 via Frontend Transport; Thu, 6 Jul 2023 13:58:22 +0000 Received: ("Tessian outbound d6c4ee3ba1eb:v142"); Thu, 06 Jul 2023 13:58:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f41c1034add602ed X-CR-MTA-TID: 64aa7808 Received: from f120b2464f24.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C0783130-F476-44F6-A37A-12E3473851A2.1; Thu, 06 Jul 2023 13:58:15 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f120b2464f24.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 06 Jul 2023 13:58:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OP0H3Ls1v5c5XVwuHhgOe8Ts1ycXXP76QVtb+ZRd5ciDwy4T3kpFwXezwWo76CjBHXf4Q+a6bmGt32sxLpik2hhF55l69eCHt1ljKCuF4BgvShklahaICVWFmJ1glRaDzoQ9E5yzZJ838NxRHBroQ/bqDaAnx9GsBqXbwsJ7yqYZu3oBqwO6czL7Kd6ZmVtaTeHERur5tfw4207j1cARSqpGFtMiPp9AWMZYLNGkr4YOCw96i9Vgerakfd39Xx/+CtteXY3zXI6wPdtL6L1Lg1THRE5mRxfxebyDn2B6R3OQ9bvtuxwklI5pfkkAuvZWh0fGNqcO5xrowNltPaROUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WcUD7cvCYDQHZ03HTccqHC7Lyr6Ss3N8k7hBDjqO5B0=; b=Okl4zpwJ6eB+IxMa9IZ7hfhiM0awOEWS4+RiUxWaFnxMQrrgWdVbBb9Bu65AG9LcIGUjvBBQG7OqFy36QuIDkMwQPXxgSp964n54NlaO+d6tuJJY4OwIcM0qgst1rA9q1YDqX++fCJA1DTyFqqfHEwvS3Zkd1pR5Of1hBgE2DpCAwWVMHYtIPf/M93HWk+feI+w/2C0kuosIHQSzaGsaMwaChNOBzS8KJsRSPUerAhP+5fTg8FkEmP0o6DOWzwEOfREAAXcX7fqOtYopLJX0R+XxxOH84v4ZJgS6x6VgC+j0P04ENTmaSFx+ZheTMesyYTIJrsePS9GtjUpf53UO7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WcUD7cvCYDQHZ03HTccqHC7Lyr6Ss3N8k7hBDjqO5B0=; b=J3+qwA6FP7tgYR0ZylXvyzLbmzluy8S4xiae71wTFdF8zHiAqAcsa4eAZwLlfHm8DiS3HtyVqX+MLLEI4qAOwojcrykyM8nwIDGdoWnvEQ5qG358TXh8ABBPhqwVfxebJm/M/nU14PpcoqdPxePLvQ0yud1ZPZe5yAJzzLuIsmg= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) by AM9PR08MB5908.eurprd08.prod.outlook.com (2603:10a6:20b:283::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Thu, 6 Jul 2023 13:58:13 +0000 Received: from PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::202a:45b7:3be8:47d5]) by PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::202a:45b7:3be8:47d5%7]) with mapi id 15.20.6565.016; Thu, 6 Jul 2023 13:58:12 +0000 Date: Thu, 6 Jul 2023 14:58:05 +0100 From: Alex Coplan To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, Iain Sandoe , Joseph Myers , Nathan Sidwell , Jonathan Wakely Subject: Re: [PATCH][RFC] c-family: Implement __has_feature and __has_extension [PR60512] Message-ID: References: <4d1f72c2-be3c-c548-00b8-d80216898c8a@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <4d1f72c2-be3c-c548-00b8-d80216898c8a@redhat.com> X-ClientProxiedBy: DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) To PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAWPR08MB8958:EE_|AM9PR08MB5908:EE_|DBAEUR03FT044:EE_|GV1PR08MB8404:EE_ X-MS-Office365-Filtering-Correlation-Id: 710812b9-32c2-4693-f929-08db7e290f79 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: nVuOFO2MhajUVLYRXoC0GWIhlFqxhIyMb6EA0ESxG/L0po+a9P1pUHm/jm1oaUJl47rzM0MStc/3pwIxAa32TWRnHa514RCsEXvSFAwPTr/eI1ybW+GxKLAsNQxZSi2BXF+MuVlp2tGRhULF/8WJql21Ur+L+bjzY70XJN55rV97DTpG8GpjP8WjC+Dgc26saH+zXzqsa7o9Hq9TmcG3v8toDz7wAQWPGLB+JfkZ6veF0x/XlqMTh1X61jg3kPL5xzYk6S0jMbn2/dtQRQHLHNbQGobaC8ce+x5biU1K/syvB6ckFxl9ogRXCSjVcw5k/NfxYkR4L8ZE3gxsu1z8sZNO5Tr4GJjLkwM9/2lTHUtQYWWZS150cC5WcMT5RwckGxODAhGrpq57w078cC9YWEj1+YKq2T8FGauIY63rp63Rpc4Y4QRXSuw9f1e8hKfFb+mQgmrohtc404TMo2B7FuD6DxUWyImirpn91a12VERpFApwzx64DoiXe7nOg0fESy0/ldfFd4r1UlW/8h93nZgI7LM7WfBR+ihoviuSLvMJZC9aygGZ3AQiAXGRm01wi8q8P8hFSAo06TLJmDriDjU9bBjkBcRLHQzavdY0FALyT+8czssyggrp101GKOBpVM0dfb1zlhO0XMsWU0Piig== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAWPR08MB8958.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(366004)(396003)(136003)(39860400002)(451199021)(44832011)(5660300002)(41300700001)(8936002)(8676002)(2906002)(316002)(83380400001)(4326008)(54906003)(2616005)(6916009)(38100700002)(66946007)(66476007)(66556008)(86362001)(6506007)(26005)(53546011)(478600001)(186003)(6486002)(36756003)(6512007)(966005)(6666004)(21314003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB5908 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: beef9ec3-89fd-43f2-dad3-08db7e2909c8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uHY4RvKIYOM3vbJJ2t7CX9WyZT+rkvGLKsuIUudFJYxp7hIEIiZqEht+HiuQZfobZvW09inaBa65ucKugqKrz/tPNhBAY8qSNnaMzkIpudSqSKdrg9XdJxedqxo479MKI05hS5t6+CB3yJWEzh/S+qknd5iDU3i99A86TMoaCTtqgqvlI8vFRkkn+e6Xm6EQZuQND9r/zB8JT4JfQd7ty/kIYay+cj4dN6bCK5WRvvoQDOxw5SOXFmtYrlmLX7M5j0EfyWSiYHwOSDcp44IijPVP3ejx8lLPKcARUJVP5EX6lApBWYsKujPb8Gk8kD6uDoF8A0LhkmPH0KQskzek6H3+LuVMhNmvRF7ZU9q+R3XpG6i4s6++B6WrA82dFDeuM4WLpW/fJhscEjPHEk6KWpHEoL7jRnh5SY3tj1aGfo17c/apxrV8cK04SQHLTrPt5NKgSidBa7c/bmgjb2NPVT3qfrQDGWhE2kDZFHcUxgM1NgJ0DBpHc71K4ZusHe9+9c2zqMZhKoMXxoVUGe+t/4QZHEcCaBkxJAxsLLO0rBaZ27DrCzWsHT/I5forN1tvfRFkci+eGqmaViV/n6GytJq9+qCTQnPTlHHlXOoSWEzP7Y1TF+PnEXKgZQZpG9gxcEyCCL4+3p3+Kjhynvyu6rKHzs8x3p7+CDPVvjghSOBUSYHtb74/Hn4yAMeYmWrlv3VEhWKVsPaR30VMQPGwPIuabCyATGUqhIUx16GEqS5wH5kWy55tgjp0ojSsDe3ImhQCcIpbZlS5RpoDOsl/3XAmHAh6pFrVqZYUvOcbqVM= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(376002)(346002)(396003)(136003)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(478600001)(6666004)(6486002)(54906003)(6506007)(26005)(53546011)(966005)(70586007)(6512007)(186003)(107886003)(70206006)(2906002)(82310400005)(41300700001)(4326008)(316002)(44832011)(5660300002)(6862004)(8936002)(8676002)(356005)(81166007)(82740400003)(36756003)(86362001)(47076005)(40460700003)(36860700001)(83380400001)(2616005)(336012)(40480700001)(21314003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2023 13:58:22.1467 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 710812b9-32c2-4693-f929-08db7e290f79 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8404 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_NONE,KAM_SHORT,LIKELY_SPAM_BODY,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Jason, On 11/05/2023 16:25, Jason Merrill wrote: > On 5/9/23 08:07, Alex Coplan wrote: > > This patch implements clang's __has_feature and __has_extension in GCC. > > Thanks! Thanks a lot for the review, I posted a v2 patch incorporating your feedback here: https://gcc.gnu.org/pipermail/gcc-patches/2023-June/623057.html do the C++ parts of the patch look OK? Thanks, Alex > > > Currently the patch aims to implement all documented features (and some > > undocumented ones) following the documentation at > > https://clang.llvm.org/docs/LanguageExtensions.html with the following > > omissions: > > - C++ type traits. > > - Objective-C-specific features. > > > > C++ type traits aren't currently implemented since, as the clang > > documentation notes, __has_builtin is the correct "modern" way to query > > for these (which GCC already implements). Of course there's an argument > > that we should recognize the legacy set of C++ type traits that can be > > queried through __has_feature for backwards compatibility with older > > code. I'm happy to do this if reviewers think that's a good idea. > > That seems unnecessary unless there's a specific motivation. > > > There are some comments in the patch marked with XXX, I'm looking for > > review comments from C/C++ maintainers on those areas in particular. > > > > Bootstrapped/regtested on aarch64-linux-gnu. Any comments? > > All the has_*_feature_p functions need to check flag_pedantic_errors, for > compatibility with the Clang documented behavior "If the -pedantic-errors > option is given, __has_extension is equivalent to __has_feature." > > > +static const cp_feature_info cp_feature_table[] = > > +{ > > + { "cxx_exceptions", &flag_exceptions }, > > + { "cxx_rtti", &flag_rtti }, > > + { "cxx_access_control_sfinae", { cxx11, cxx98 } }, > > + { "cxx_alias_templates", cxx11 }, > > + { "cxx_alignas", cxx11 }, > > + { "cxx_alignof", cxx11 }, > > + { "cxx_attributes", cxx11 }, > > + { "cxx_constexpr", cxx11 }, > > + { "cxx_constexpr_string_builtins", cxx11 }, > > + { "cxx_decltype", cxx11 }, > > + { "cxx_decltype_incomplete_return_types", cxx11 }, > > + { "cxx_default_function_template_args", cxx11 }, > > + { "cxx_defaulted_functions", cxx11 }, /* XXX: extension in c++98? */ > > I'm not sure I see the benefit of advertising a lot of these as C++98 > extensions, even if we do accept them with a pedwarn by default. The ones > that indicate DRs like cxx_access_control_sfinae, yes, but I'm inclined to > be conservative if it isn't an extension that libstdc++ relies on, like > variadic templates or inline namespaces. My concern is that important > implementation is limited to C++11 mode even if we don't immediately give an > error. For instance, > > struct A > { > int i = 42; > A() = default; > }; > > breaks in C++98 mode; even though we only warn for the two C++11 features, > trying to actually combine them fails. > > So if there's a question, let's say no. > > > + { "cxx_delegating_constructors", { cxx11, cxx98 } }, > > + { "cxx_deleted_functions", cxx11 }, > > + { "cxx_explicit_conversions", { cxx11, cxx98 } }, > > + { "cxx_generalized_initializers", cxx11 }, > > + { "cxx_implicit_moves", cxx11 }, > > + { "cxx_inheriting_constructors", cxx11 }, /* XXX: extension in c++98? */ > > + { "cxx_inline_namespaces", { cxx11, cxx98 } }, > > + { "cxx_lambdas", cxx11 }, /* XXX: extension in c++98? */ > > + { "cxx_local_type_template_args", cxx11 }, > > + { "cxx_noexcept", cxx11 }, > > + { "cxx_nonstatic_member_init", { cxx11, cxx98 } }, > > + { "cxx_nullptr", cxx11 }, > > + { "cxx_override_control", { cxx11, cxx98 } }, > > + { "cxx_reference_qualified_functions", cxx11 }, > > + { "cxx_range_for", cxx11 }, > > + { "cxx_raw_string_literals", cxx11 }, > > + { "cxx_rvalue_references", cxx11 }, > > + { "cxx_static_assert", cxx11 }, > > + { "cxx_thread_local", cxx11 }, > > + { "cxx_auto_type", cxx11 }, > > + { "cxx_strong_enums", cxx11 }, > > + { "cxx_trailing_return", cxx11 }, > > + { "cxx_unicode_literals", cxx11 }, > > + { "cxx_unrestricted_unions", cxx11 }, > > + { "cxx_user_literals", cxx11 }, > > + { "cxx_variadic_templates", { cxx11, cxx98 } }, > > + { "cxx_binary_literals", { cxx14, cxx98 } }, > > + { "cxx_contextual_conversions", { cxx14, cxx98 } }, > > + { "cxx_decltype_auto", cxx14 }, > > + { "cxx_aggregate_nsdmi", cxx14 }, > > + { "cxx_init_captures", { cxx14, cxx11 } }, > > + { "cxx_generic_lambdas", cxx14 }, > > + { "cxx_relaxed_constexpr", cxx14 }, > > + { "cxx_return_type_deduction", cxx14 }, > > + { "cxx_variable_templates", { cxx14, cxx98 } }, > > + { "modules", &flag_modules }, > > >