https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103355

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-11-22
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #0)
> [[likely]] and [[unlikely]] come from C++20, or?

Yes. It should really be guarded by #if __has_cpp_attribute(likely)

Or use [[__likely__]] which recent versions of GCC will accept in C++11 mode,
but non-GCC compilers will warn about.


Or both:

--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -1286,7 +1286,14 @@ namespace bidi {
       case kind::RTL:
        /* These aren't popped by a PDF/PDI.  */
        break;
-      [[likely]] case kind::NONE:
+#ifdef __has_cpp_attribute
+# if __has_cpp_attribute(likely)
+      [[likely]]
+# elif __has_cpp_attribute(__likely__)
+      [[__likely__]]
+# endif
+#endif
+      case kind::NONE:
        break;
       default:
        abort ();

Reply via email to