From 630686f93f0018fa1ef128aa673fddd302cc83e1 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Mon, 22 Nov 2021 11:29:40 -0500 Subject: libcpp: Use [[likely]] conditionally Let's hide [[likely]] behind a macro, to suppress warnings if the compiler doesn't support it. Co-authored-by: Jonathan Wakely PR preprocessor/103355 libcpp/ChangeLog: * lex.c: Use ATTR_LIKELY instead of [[likely]]. * system.h (ATTR_LIKELY): Define. --- libcpp/system.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libcpp/system.h') diff --git a/libcpp/system.h b/libcpp/system.h index ee5fbe2..f6fc583 100644 --- a/libcpp/system.h +++ b/libcpp/system.h @@ -422,6 +422,16 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; #define gcc_checking_assert(EXPR) ((void)(0 && (EXPR))) #endif +#ifdef __has_cpp_attribute +# if __has_cpp_attribute(likely) +# define ATTR_LIKELY [[likely]] +# elif __has_cpp_attribute(__likely__) +# define ATTR_LIKELY [[__likely__]] +# else +# define ATTR_LIKELY +# endif +#endif + /* Poison identifiers we do not want to use. */ #if (GCC_VERSION >= 3000) #undef calloc -- cgit v1.1 From 46d3cfd29dc701e1e0d18b0380d6299fce7944f2 Mon Sep 17 00:00:00 2001 From: Christophe Lyon Date: Tue, 23 Nov 2021 16:06:42 +0000 Subject: libcpp: Fix ATTR_LIKELY definition PR preprocessor/103355 Fix the definition of ATTR_LIKELY when __has_cpp_attribute is not defined, as it is the case with old compilers such as gcc-4.8.5. libcpp/: PR preprocessor/103355 * system.h (ATTR_LIKELY): Fix definition. --- libcpp/system.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libcpp/system.h') diff --git a/libcpp/system.h b/libcpp/system.h index f6fc583..b78ab81 100644 --- a/libcpp/system.h +++ b/libcpp/system.h @@ -430,6 +430,8 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; # else # define ATTR_LIKELY # endif +#else +# define ATTR_LIKELY #endif /* Poison identifiers we do not want to use. */ -- cgit v1.1 From 7adcbafe45f8001b698967defe682687b52c0007 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 3 Jan 2022 10:42:10 +0100 Subject: Update copyright years. --- libcpp/system.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libcpp/system.h') diff --git a/libcpp/system.h b/libcpp/system.h index b78ab81..e80cf02 100644 --- a/libcpp/system.h +++ b/libcpp/system.h @@ -1,6 +1,6 @@ /* Get common system includes and various definitions and declarations based on autoconf macros. - Copyright (C) 1998-2021 Free Software Foundation, Inc. + Copyright (C) 1998-2022 Free Software Foundation, Inc. This file is part of GCC. -- cgit v1.1