[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Support FALLTHROUGH macro better in glibc+clang
From: |
Bruno Haible |
Subject: |
Re: Support FALLTHROUGH macro better in glibc+clang |
Date: |
Mon, 27 Mar 2023 19:24:23 +0200 |
Paul Eggert wrote:
> On 2023-03-25 14:24, Paul Eggert wrote:
> > # if __GNUC_PREREQ (7,0) || __glibc_has_attribute (__fallthrough__)
>
> Come to think of it this could be simplified further, to just:
>
> # if __glibc_has_attribute (__fallthrough__)
>
> since GCC started supporting __has_attribute in GCC 5.
Good point. I'm thus committing this in your name:
2023-03-27 Paul Eggert <eggert@cs.ucla.edu>
Support FALLTHROUGH macro better in glibc+clang.
* lib/fnmatch.c (FALLTHROUGH): Use __attribute__ ((__fallthrough__))
also in clang >= 10.
* lib/fts.c (FALLTHROUGH): Likewise.
* lib/regex_internal.h (FALLTHROUGH): Likewise.
diff --git a/lib/fnmatch.c b/lib/fnmatch.c
index 7c9c4e0f24..32cfb48d0f 100644
--- a/lib/fnmatch.c
+++ b/lib/fnmatch.c
@@ -64,7 +64,7 @@ extern int fnmatch (const char *pattern, const char *string,
int flags);
#endif
#ifdef _LIBC
-# if __GNUC__ >= 7
+# if __glibc_has_attribute (__fallthrough__)
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# else
# define FALLTHROUGH ((void) 0)
diff --git a/lib/fts.c b/lib/fts.c
index 794a4f75d7..3fffb45d70 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -203,7 +203,7 @@ enum Fts_stat
#endif
#ifdef _LIBC
-# if __GNUC__ >= 7
+# if __glibc_has_attribute (__fallthrough__)
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# else
# define FALLTHROUGH ((void) 0)
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index 149ec2e868..ae9257eac0 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -822,7 +822,7 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
}
#ifdef _LIBC
-# if __GNUC__ >= 7
+# if __glibc_has_attribute (__fallthrough__)
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# else
# define FALLTHROUGH ((void) 0)