From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 04628385771B for ; Mon, 15 May 2023 21:28:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 04628385771B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.99,277,1677571200"; d="scan'208";a="5436312" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 15 May 2023 13:28:49 -0800 IronPort-SDR: 0TwXJDTAVcwbqgd+n/Pe3oPhqWxISc6R5+PEyZ4PoJyxVoubsGVFrw6JDvJfIwfTF+R0HiViaW vpTrkyoSNyxj+rLbp198bwEdnzqnCZuIGpMmrIwT5zzRnxq65AOlRB0B5szfFxl04+SXx8+UHM C03soeQX2Q7f08krOlL557G/Zaku4s4mAOWiF2dltcMIO4Po6AdqFZnm3mdROADY2dbLMQ9oFf hVyemueLv0VLVeKsmrE0a61xEKgI8HpoWIEMDpXJRLOhohwSUmdEZJ4FU+dHqV4rYuk38zpGKK KXE= Date: Mon, 15 May 2023 21:28:45 +0000 From: Joseph Myers To: Subject: [committed] c: Update __has_c_attribute values for C2x Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-3112.8 required=5.0 tests=BAYES_00,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,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 List-Id: WG14 decided that __has_c_attribute should return the same value (equal to the intended __STDC_VERSION__ value) for all standard attributes in C2x, with values associated with when an attribute was added to the working draft (or had semantics added or changed in the working draft) only being used in earlier stages of development of that draft. The intent is that the values for existing attributes increase in future standard versions only if there are new features / semantic changes for those attributes. Implement this change for GCC. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c-family/ * c-lex.cc (c_common_has_attribute): Use 202311 as __has_c_attribute return for all C2x attributes. gcc/testsuite/ * gcc.dg/c2x-has-c-attribute-2.c: Expect 202311L return value from __has_c_attribute for all C2x attributes. diff --git a/gcc/c-family/c-lex.cc b/gcc/c-family/c-lex.cc index 6eb0fae2f53..dcd061c7cb1 100644 --- a/gcc/c-family/c-lex.cc +++ b/gcc/c-family/c-lex.cc @@ -392,17 +392,13 @@ c_common_has_attribute (cpp_reader *pfile, bool std_syntax) } else { - if (is_attribute_p ("deprecated", attr_name)) - result = 201904; - else if (is_attribute_p ("fallthrough", attr_name)) - result = 201910; - else if (is_attribute_p ("nodiscard", attr_name)) - result = 202003; - else if (is_attribute_p ("maybe_unused", attr_name)) - result = 202106; - else if (is_attribute_p ("noreturn", attr_name) - || is_attribute_p ("_Noreturn", attr_name)) - result = 202202; + if (is_attribute_p ("deprecated", attr_name) + || is_attribute_p ("fallthrough", attr_name) + || is_attribute_p ("maybe_unused", attr_name) + || is_attribute_p ("nodiscard", attr_name) + || is_attribute_p ("noreturn", attr_name) + || is_attribute_p ("_Noreturn", attr_name)) + result = 202311; } if (result) attr_name = NULL_TREE; diff --git a/gcc/testsuite/gcc.dg/c2x-has-c-attribute-2.c b/gcc/testsuite/gcc.dg/c2x-has-c-attribute-2.c index 3c34ab6cbd9..dc92b95e907 100644 --- a/gcc/testsuite/gcc.dg/c2x-has-c-attribute-2.c +++ b/gcc/testsuite/gcc.dg/c2x-has-c-attribute-2.c @@ -2,56 +2,56 @@ /* { dg-do preprocess } */ /* { dg-options "-std=c2x -pedantic-errors" } */ -#if __has_c_attribute ( nodiscard ) != 202003L +#if __has_c_attribute ( nodiscard ) != 202311L #error "bad result for nodiscard" #endif -#if __has_c_attribute ( __nodiscard__ ) != 202003L +#if __has_c_attribute ( __nodiscard__ ) != 202311L #error "bad result for __nodiscard__" #endif -#if __has_c_attribute(maybe_unused) != 202106L +#if __has_c_attribute(maybe_unused) != 202311L #error "bad result for maybe_unused" #endif -#if __has_c_attribute(__maybe_unused__) != 202106L +#if __has_c_attribute(__maybe_unused__) != 202311L #error "bad result for __maybe_unused__" #endif -#if __has_c_attribute (deprecated) != 201904L +#if __has_c_attribute (deprecated) != 202311L #error "bad result for deprecated" #endif -#if __has_c_attribute (__deprecated__) != 201904L +#if __has_c_attribute (__deprecated__) != 202311L #error "bad result for __deprecated__" #endif -#if __has_c_attribute (fallthrough) != 201910L +#if __has_c_attribute (fallthrough) != 202311L #error "bad result for fallthrough" #endif -#if __has_c_attribute (__fallthrough__) != 201910L +#if __has_c_attribute (__fallthrough__) != 202311L #error "bad result for __fallthrough__" #endif -#if __has_c_attribute (noreturn) != 202202L +#if __has_c_attribute (noreturn) != 202311L #error "bad result for noreturn" #endif -#if __has_c_attribute (__noreturn__) != 202202L +#if __has_c_attribute (__noreturn__) != 202311L #error "bad result for __noreturn__" #endif -#if __has_c_attribute (_Noreturn) != 202202L +#if __has_c_attribute (_Noreturn) != 202311L #error "bad result for _Noreturn" #endif -#if __has_c_attribute (___Noreturn__) != 202202L +#if __has_c_attribute (___Noreturn__) != 202311L #error "bad result for ___Noreturn__" #endif /* Macros in the attribute name are expanded. */ #define foo deprecated -#if __has_c_attribute (foo) != 201904L +#if __has_c_attribute (foo) != 202311L #error "bad result for foo" #endif -- Joseph S. Myers joseph@codesourcery.com