From patchwork Thu Sep 5 07:20:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1981111 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=d4fcrL0Z; 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 4WzrP74SyVz1yfv for ; Thu, 5 Sep 2024 17:20:43 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 64B4C386482B for ; Thu, 5 Sep 2024 07:20:41 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 7DC74386182F for ; Thu, 5 Sep 2024 07:20:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7DC74386182F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7DC74386182F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725520820; cv=none; b=GN9grHNBmi5u5lEvZSrJXqW3KSZDXEbSZ2zZoNqAlpPdlcmHa9TXsJR+bUFX07/PXpcluohX5LcnGh9Qo2daOivtYKNFyMXHQ5Px/7PDtbEjPT5b5xNSg5V/C88W9e2R95ohW5MdHAn4N9Qo8cx/3hNQWxR4DpMkrqvq0sCCyEM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725520820; c=relaxed/simple; bh=cub9AGljDdzjnKACnbvCl81UbhQ52ec04nqZVb9kO10=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Q6TrMZ/Jqz9sszymeUUO3a6VGa1yrK4RBc+HXLImE0cq+ookI0Ce257l7uS3/BRN/KO2zYXeiUoCzlUAwGre8tlmAtkTrFhq9YhASUZxDHUcdlHqEzLHi4cCfx6UO96xcLazjGtIchD9i2hpmpKv+FGd/8DuedJzx3yTV1UKJZg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725520815; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=NT0Xc4+4IwNAo2HCjjP01MevBmRUcfBM5PhDmyh84KM=; b=d4fcrL0ZM1gT62YvM76Mp8kTSE7ch9hAU90vNiLGh6cPmN8TdBDahjBbNyU0nxMxKZt46O dTmOQxHLSqKwTFfvLlcPqrkcYlFRoPZvV7xac5ZKHVIlI22GlnuiiIH2MfOeWR6XYBJiaX z+4wlgIpmH7loGfMP5lbyZS4PQi6bhE= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-62-StXeA6TVM5WYzS4dA8hf2A-1; Thu, 05 Sep 2024 03:20:13 -0400 X-MC-Unique: StXeA6TVM5WYzS4dA8hf2A-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 15BB119560BF for ; Thu, 5 Sep 2024 07:20:13 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.29]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 883CE1955F44; Thu, 5 Sep 2024 07:20:12 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 4857KAFZ1837197 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 5 Sep 2024 09:20:10 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 4857K9pv1837196; Thu, 5 Sep 2024 09:20:09 +0200 Date: Thu, 5 Sep 2024 09:20:09 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Add {,un}likely attribute further test coverage [PR110345] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-0.9 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_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! Similarly for likely/unlikely attributes. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-09-05 Jakub Jelinek PR c++/110345 * g++.dg/cpp0x/attr-likely1.C: New test. * g++.dg/cpp0x/attr-unlikely1.C: New test. Jakub --- gcc/testsuite/g++.dg/cpp0x/attr-likely1.C.jj 2024-09-04 16:53:59.829472783 +0200 +++ gcc/testsuite/g++.dg/cpp0x/attr-likely1.C 2024-09-04 17:04:52.566048248 +0200 @@ -0,0 +1,149 @@ +// C++ 26 P2552R3 - On the ignorability of standard attributes +// { dg-do compile { target c++11 } } + +int arr[2]; +struct S { int a, b; }; +S arr2[2]; + +void +foo (int n) +{ + [[likely]]; + [[likely (1)]]; // { dg-error "'likely' attribute does not take any arguments" } + [[likely]] ++n; + [[likely]] int x1; // { dg-warning "'likely' attribute ignored" } + + auto a = [] [[likely]] () {}; // { dg-warning "ISO C\\\+\\\+ 'likely' attribute does not apply to functions; treating as '\\\[\\\[gnu::hot\\\]\\\]'" } + auto b = [] constexpr [[likely]] {}; // { dg-warning "'likely' attribute ignored" } + // { dg-error "parameter declaration before lambda declaration specifiers only optional with" "" { target c++20_down } .-1 } + // { dg-error "'constexpr' lambda only available with" "" { target c++14_down } .-2 } + auto c = [] noexcept [[likely]] {}; // { dg-warning "'likely' attribute ignored" } + // { dg-error "parameter declaration before lambda exception specification only optional with" "" { target c++20_down } .-1 } + auto d = [] () [[likely]] {}; // { dg-warning "'likely' attribute ignored" } + auto e = new int [n] [[likely]]; // { dg-warning "attributes ignored on outermost array type in new expression" } + auto e2 = new int [n] [[likely]] [42];// { dg-warning "attributes ignored on outermost array type in new expression" } + auto f = new int [n][42] [[likely]]; // { dg-warning "'likely' attribute ignored" } + [[likely]]; + [[likely]] {} + [[likely]] if (true) {} + [[likely]] while (false) {} + [[likely]] goto lab; + [[likely]] lab:; + [[likely]] try {} catch (int) {} + if ([[likely]] int x = 0) {} // { dg-warning "'likely' attribute ignored" } + switch (n) + { + [[likely]] case 1: + [[likely]] break; + [[likely]] default: + break; + } + for ([[likely]] auto a : arr) {} // { dg-warning "'likely' attribute ignored" } + for ([[likely]] auto [a, b] : arr2) {}// { dg-warning "'likely' attribute ignored" } + // { dg-error "structured bindings only available with" "" { target c++14_down } .-1 } + [[likely]] asm (""); // { dg-warning "attributes ignored on 'asm' declaration" } + try {} catch ([[likely]] int x) {} // { dg-warning "'likely' attribute ignored" } + try {} catch ([[likely]] int) {} // { dg-warning "'likely' attribute ignored" } + try {} catch (int [[likely]] x) {} // { dg-warning "attribute ignored" } + try {} catch (int [[likely]]) {} // { dg-warning "attribute ignored" } + try {} catch (int x [[likely]]) {} // { dg-warning "'likely' attribute ignored" } +} + +[[likely]] int bar (); // { dg-warning "ISO C\\\+\\\+ 'likely' attribute does not apply to functions; treating as '\\\[\\\[gnu::hot\\\]\\\]'" } +using foobar [[likely]] = int; // { dg-warning "'likely' attribute ignored" } +[[likely]] int a; // { dg-warning "'likely' attribute ignored" } +[[likely]] auto [b, c] = arr; // { dg-warning "'likely' attribute ignored" } + // { dg-error "structured bindings only available with" "" { target c++14_down } .-1 } +[[likely]]; // { dg-warning "attribute ignored" } +inline [[likely]] void baz () {} // { dg-warning "attribute ignored" } + // { dg-error "standard attributes in middle of decl-specifiers" "" { target *-*-* } .-1 } +constexpr [[likely]] int qux () { return 0; } // { dg-warning "attribute ignored" } + // { dg-error "standard attributes in middle of decl-specifiers" "" { target *-*-* } .-1 } +int [[likely]] d; // { dg-warning "attribute ignored" } +int const [[likely]] e = 1; // { dg-warning "attribute ignored" } +struct A {} [[likely]]; // { dg-warning "attribute ignored in declaration of 'struct A'" } +struct A [[likely]]; // { dg-warning "attribute ignored" } +struct A [[likely]] a1; // { dg-warning "attribute ignored" } +A [[likely]] a2; // { dg-warning "attribute ignored" } +enum B { B0 } [[likely]]; // { dg-warning "attribute ignored in declaration of 'enum B'" } +enum B [[likely]]; // { dg-warning "attribute ignored" } +enum B [[likely]] b1; // { dg-warning "attribute ignored" } +B [[likely]] b2; // { dg-warning "attribute ignored" } +struct [[likely]] C {}; // { dg-warning "'likely' attribute ignored" } +int f [[likely]]; // { dg-warning "'likely' attribute ignored" } +int g[2] [[likely]]; // { dg-warning "'likely' attribute ignored" } +int g2 [[likely]] [2]; // { dg-warning "'likely' attribute ignored" } +int corge () [[likely]]; // { dg-warning "'likely' attribute ignored" } +int *[[likely]] h; // { dg-warning "'likely' attribute ignored" } +int & [[likely]] i = f; // { dg-warning "'likely' attribute ignored" } +int && [[likely]] j = 0; // { dg-warning "'likely' attribute ignored" } +int S::* [[likely]] k; // { dg-warning "'likely' attribute ignored" } +auto l = sizeof (int [2] [[likely]]); // { dg-warning "'likely' attribute ignored" } +int freddy ([[likely]] int a, // { dg-warning "'likely' attribute ignored" } + [[likely]] int, // { dg-warning "'likely' attribute ignored" } + [[likely]] int c = 0, // { dg-warning "'likely' attribute ignored" } + [[likely]] int = 0); // { dg-warning "'likely' attribute ignored" } +void +corge ([[likely]] int a, // { dg-warning "'likely' attribute ignored" } + [[likely]] int, // { dg-warning "'likely' attribute ignored" } + [[likely]] int c = 0, // { dg-warning "'likely' attribute ignored" } + [[likely]] int = 0) // { dg-warning "'likely' attribute ignored" } +{ +} +[[likely]] void +garply () // { dg-warning "ISO C\\\+\\\+ 'likely' attribute does not apply to functions; treating as '\\\[\\\[gnu::hot\\\]\\\]'" } +{ +} +int grault (int [[likely]] a, // { dg-warning "attribute ignored" } + int [[likely]], // { dg-warning "attribute ignored" } + int [[likely]] c = 0, // { dg-warning "attribute ignored" } + int [[likely]] = 0); // { dg-warning "attribute ignored" } +void +waldo (int [[likely]] a, // { dg-warning "attribute ignored" } + int [[likely]], // { dg-warning "attribute ignored" } + int [[likely]] c = 0, // { dg-warning "attribute ignored" } + int [[likely]] = 0) // { dg-warning "attribute ignored" } +{ +} +int plugh (int a [[likely]], // { dg-warning "'likely' attribute ignored" } + int b [[likely]] = 0); // { dg-warning "'likely' attribute ignored" } +void +thud (int a [[likely]], // { dg-warning "'likely' attribute ignored" } + int b [[likely]] = 0) // { dg-warning "'likely' attribute ignored" } +{ +} +enum [[likely]] D { D0 }; // { dg-warning "'likely' attribute ignored" } +enum class [[likely]] E { E0 }; // { dg-warning "'likely' attribute ignored" } +enum F {}; +enum [[likely]] F; // { dg-warning "type attributes ignored after type is already defined" } +enum G { + G0 [[likely]], // { dg-warning "'likely' attribute ignored" } + G1 [[likely]] = 2 // { dg-warning "'likely' attribute ignored" } +}; +namespace [[likely]] H { using H0 = int; } // { dg-warning "'likely' attribute directive ignored" } */ +namespace [[likely]] {} // { dg-warning "'likely' attribute directive ignored" } +[[likely]] using namespace H; // { dg-warning "'likely' attribute directive ignored" } +struct [[likely]] I // { dg-warning "'likely' attribute ignored" } +{ + [[likely]]; // { dg-error "declaration does not declare anything" } + [[likely]] int i; // { dg-warning "'likely' attribute ignored" } + [[likely]] int foo (); // { dg-warning "ISO C\\\+\\\+ 'likely' attribute does not apply to functions; treating as '\\\[\\\[gnu::hot\\\]\\\]'" } + [[likely]] int bar () { return 1; } // { dg-warning "ISO C\\\+\\\+ 'likely' attribute does not apply to functions; treating as '\\\[\\\[gnu::hot\\\]\\\]'" } + [[likely]] int : 0; // { dg-warning "'likely' attribute ignored" } + [[likely]] int i2 : 5; // { dg-warning "'likely' attribute ignored" } + [[likely]] static int i3; // { dg-warning "'likely' attribute ignored" } + static int i4; +}; +[[likely]] int I::i4 = 0; // { dg-warning "'likely' attribute ignored" } +struct J : [[likely]] C {}; // { dg-warning "attributes on base specifiers are ignored" } +#if __cpp_concepts >= 201907L +template +concept K [[likely]] = requires { true; }; // { dg-warning "'likely' attribute ignored" "" { target c++20 } } +#endif +typedef int L [[likely]]; // { dg-warning "'likely' attribute ignored" } +template +struct M {}; +template <> +struct [[likely]] M { int m; }; // { dg-warning "'likely' attribute ignored" } +typedef int N[2] [[likely]]; // { dg-warning "'likely' attribute ignored" } +typedef int O [[likely]] [2]; // { dg-warning "'likely' attribute ignored" } --- gcc/testsuite/g++.dg/cpp0x/attr-unlikely1.C.jj 2024-09-04 17:05:46.855347565 +0200 +++ gcc/testsuite/g++.dg/cpp0x/attr-unlikely1.C 2024-09-04 17:07:05.602331182 +0200 @@ -0,0 +1,149 @@ +// C++ 26 P2552R3 - On the ignorability of standard attributes +// { dg-do compile { target c++11 } } + +int arr[2]; +struct S { int a, b; }; +S arr2[2]; + +void +foo (int n) +{ + [[unlikely]]; + [[unlikely (1)]]; // { dg-error "'unlikely' attribute does not take any arguments" } + [[unlikely]] ++n; + [[unlikely]] int x1; // { dg-warning "'unlikely' attribute ignored" } + + auto a = [] [[unlikely]] () {}; // { dg-warning "ISO C\\\+\\\+ 'unlikely' attribute does not apply to functions; treating as '\\\[\\\[gnu::cold\\\]\\\]'" } + auto b = [] constexpr [[unlikely]] {}; // { dg-warning "'unlikely' attribute ignored" } + // { dg-error "parameter declaration before lambda declaration specifiers only optional with" "" { target c++20_down } .-1 } + // { dg-error "'constexpr' lambda only available with" "" { target c++14_down } .-2 } + auto c = [] noexcept [[unlikely]] {}; // { dg-warning "'unlikely' attribute ignored" } + // { dg-error "parameter declaration before lambda exception specification only optional with" "" { target c++20_down } .-1 } + auto d = [] () [[unlikely]] {}; // { dg-warning "'unlikely' attribute ignored" } + auto e = new int [n] [[unlikely]]; // { dg-warning "attributes ignored on outermost array type in new expression" } + auto e2 = new int [n] [[unlikely]] [42]; // { dg-warning "attributes ignored on outermost array type in new expression" } + auto f = new int [n][42] [[unlikely]]; // { dg-warning "'unlikely' attribute ignored" } + [[unlikely]]; + [[unlikely]] {} + [[unlikely]] if (true) {} + [[unlikely]] while (false) {} + [[unlikely]] goto lab; + [[unlikely]] lab:; + [[unlikely]] try {} catch (int) {} + if ([[unlikely]] int x = 0) {} // { dg-warning "'unlikely' attribute ignored" } + switch (n) + { + [[unlikely]] case 1: + [[unlikely]] break; + [[unlikely]] default: + break; + } + for ([[unlikely]] auto a : arr) {} // { dg-warning "'unlikely' attribute ignored" } + for ([[unlikely]] auto [a, b] : arr2) {} // { dg-warning "'unlikely' attribute ignored" } + // { dg-error "structured bindings only available with" "" { target c++14_down } .-1 } + [[unlikely]] asm (""); // { dg-warning "attributes ignored on 'asm' declaration" } + try {} catch ([[unlikely]] int x) {} // { dg-warning "'unlikely' attribute ignored" } + try {} catch ([[unlikely]] int) {} // { dg-warning "'unlikely' attribute ignored" } + try {} catch (int [[unlikely]] x) {} // { dg-warning "attribute ignored" } + try {} catch (int [[unlikely]]) {} // { dg-warning "attribute ignored" } + try {} catch (int x [[unlikely]]) {} // { dg-warning "'unlikely' attribute ignored" } +} + +[[unlikely]] int bar (); // { dg-warning "ISO C\\\+\\\+ 'unlikely' attribute does not apply to functions; treating as '\\\[\\\[gnu::cold\\\]\\\]'" } +using foobar [[unlikely]] = int; // { dg-warning "'unlikely' attribute ignored" } +[[unlikely]] int a; // { dg-warning "'unlikely' attribute ignored" } +[[unlikely]] auto [b, c] = arr; // { dg-warning "'unlikely' attribute ignored" } + // { dg-error "structured bindings only available with" "" { target c++14_down } .-1 } +[[unlikely]]; // { dg-warning "attribute ignored" } +inline [[unlikely]] void baz () {} // { dg-warning "attribute ignored" } + // { dg-error "standard attributes in middle of decl-specifiers" "" { target *-*-* } .-1 } +constexpr [[unlikely]] int qux () { return 0; } // { dg-warning "attribute ignored" } + // { dg-error "standard attributes in middle of decl-specifiers" "" { target *-*-* } .-1 } +int [[unlikely]] d; // { dg-warning "attribute ignored" } +int const [[unlikely]] e = 1; // { dg-warning "attribute ignored" } +struct A {} [[unlikely]]; // { dg-warning "attribute ignored in declaration of 'struct A'" } +struct A [[unlikely]]; // { dg-warning "attribute ignored" } +struct A [[unlikely]] a1; // { dg-warning "attribute ignored" } +A [[unlikely]] a2; // { dg-warning "attribute ignored" } +enum B { B0 } [[unlikely]]; // { dg-warning "attribute ignored in declaration of 'enum B'" } +enum B [[unlikely]]; // { dg-warning "attribute ignored" } +enum B [[unlikely]] b1; // { dg-warning "attribute ignored" } +B [[unlikely]] b2; // { dg-warning "attribute ignored" } +struct [[unlikely]] C {}; // { dg-warning "'unlikely' attribute ignored" } +int f [[unlikely]]; // { dg-warning "'unlikely' attribute ignored" } +int g[2] [[unlikely]]; // { dg-warning "'unlikely' attribute ignored" } +int g2 [[unlikely]] [2]; // { dg-warning "'unlikely' attribute ignored" } +int corge () [[unlikely]]; // { dg-warning "'unlikely' attribute ignored" } +int *[[unlikely]] h; // { dg-warning "'unlikely' attribute ignored" } +int & [[unlikely]] i = f; // { dg-warning "'unlikely' attribute ignored" } +int && [[unlikely]] j = 0; // { dg-warning "'unlikely' attribute ignored" } +int S::* [[unlikely]] k; // { dg-warning "'unlikely' attribute ignored" } +auto l = sizeof (int [2] [[unlikely]]); // { dg-warning "'unlikely' attribute ignored" } +int freddy ([[unlikely]] int a, // { dg-warning "'unlikely' attribute ignored" } + [[unlikely]] int, // { dg-warning "'unlikely' attribute ignored" } + [[unlikely]] int c = 0, // { dg-warning "'unlikely' attribute ignored" } + [[unlikely]] int = 0); // { dg-warning "'unlikely' attribute ignored" } +void +corge ([[unlikely]] int a, // { dg-warning "'unlikely' attribute ignored" } + [[unlikely]] int, // { dg-warning "'unlikely' attribute ignored" } + [[unlikely]] int c = 0, // { dg-warning "'unlikely' attribute ignored" } + [[unlikely]] int = 0) // { dg-warning "'unlikely' attribute ignored" } +{ +} +[[unlikely]] void +garply () // { dg-warning "ISO C\\\+\\\+ 'unlikely' attribute does not apply to functions; treating as '\\\[\\\[gnu::cold\\\]\\\]'" } +{ +} +int grault (int [[unlikely]] a, // { dg-warning "attribute ignored" } + int [[unlikely]], // { dg-warning "attribute ignored" } + int [[unlikely]] c = 0, // { dg-warning "attribute ignored" } + int [[unlikely]] = 0); // { dg-warning "attribute ignored" } +void +waldo (int [[unlikely]] a, // { dg-warning "attribute ignored" } + int [[unlikely]], // { dg-warning "attribute ignored" } + int [[unlikely]] c = 0, // { dg-warning "attribute ignored" } + int [[unlikely]] = 0) // { dg-warning "attribute ignored" } +{ +} +int plugh (int a [[unlikely]], // { dg-warning "'unlikely' attribute ignored" } + int b [[unlikely]] = 0); // { dg-warning "'unlikely' attribute ignored" } +void +thud (int a [[unlikely]], // { dg-warning "'unlikely' attribute ignored" } + int b [[unlikely]] = 0) // { dg-warning "'unlikely' attribute ignored" } +{ +} +enum [[unlikely]] D { D0 }; // { dg-warning "'unlikely' attribute ignored" } +enum class [[unlikely]] E { E0 }; // { dg-warning "'unlikely' attribute ignored" } +enum F {}; +enum [[unlikely]] F; // { dg-warning "type attributes ignored after type is already defined" } +enum G { + G0 [[unlikely]], // { dg-warning "'unlikely' attribute ignored" } + G1 [[unlikely]] = 2 // { dg-warning "'unlikely' attribute ignored" } +}; +namespace [[unlikely]] H { using H0 = int; } // { dg-warning "'unlikely' attribute directive ignored" } */ +namespace [[unlikely]] {} // { dg-warning "'unlikely' attribute directive ignored" } +[[unlikely]] using namespace H; // { dg-warning "'unlikely' attribute directive ignored" } +struct [[unlikely]] I // { dg-warning "'unlikely' attribute ignored" } +{ + [[unlikely]]; // { dg-error "declaration does not declare anything" } + [[unlikely]] int i; // { dg-warning "'unlikely' attribute ignored" } + [[unlikely]] int foo (); // { dg-warning "ISO C\\\+\\\+ 'unlikely' attribute does not apply to functions; treating as '\\\[\\\[gnu::cold\\\]\\\]'" } + [[unlikely]] int bar () { return 1; } // { dg-warning "ISO C\\\+\\\+ 'unlikely' attribute does not apply to functions; treating as '\\\[\\\[gnu::cold\\\]\\\]'" } + [[unlikely]] int : 0; // { dg-warning "'unlikely' attribute ignored" } + [[unlikely]] int i2 : 5; // { dg-warning "'unlikely' attribute ignored" } + [[unlikely]] static int i3; // { dg-warning "'unlikely' attribute ignored" } + static int i4; +}; +[[unlikely]] int I::i4 = 0; // { dg-warning "'unlikely' attribute ignored" } +struct J : [[unlikely]] C {}; // { dg-warning "attributes on base specifiers are ignored" } +#if __cpp_concepts >= 201907L +template +concept K [[unlikely]] = requires { true; }; // { dg-warning "'unlikely' attribute ignored" "" { target c++20 } } +#endif +typedef int L [[unlikely]]; // { dg-warning "'unlikely' attribute ignored" } +template +struct M {}; +template <> +struct [[unlikely]] M { int m; }; // { dg-warning "'unlikely' attribute ignored" } +typedef int N[2] [[unlikely]]; // { dg-warning "'unlikely' attribute ignored" } +typedef int O [[unlikely]] [2]; // { dg-warning "'unlikely' attribute ignored" }