Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve check for fallthrough support #2482

Merged
merged 1 commit into from Oct 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/annotations.h
Expand Up @@ -6,18 +6,14 @@
#ifndef TIMESCALEDB_ANNOTATIONS_H
#define TIMESCALEDB_ANNOTATIONS_H

/* Fall-through annotation */
#if defined(__clang__)
#if (__clang_major__ >= 12) || (__clang_analyzer__)
/* Supported since clang 12 and GCC 7 */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are not supporting older compiler versions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are the fallthrough marking won't work on those but otherwise they are still supported

Copy link
Contributor

@pmwkaa pmwkaa Oct 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually have some defines about it in the cmake file. For eg CC_SUPPORTS_IMPLICIT_FALLTHROUGH, maybe rely on it if makes sense?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this tests whether the compiler supports -Wimplicit-fallthrough not necessarily whether it supports fallthrough attribute

#if defined __has_attribute
#if __has_attribute(fallthrough)
#define TS_FALLTHROUGH __attribute__((fallthrough))
#else
#define TS_FALLTHROUGH /* FALLTHROUGH */
#endif /* __clang__ */
#elif defined(__GNUC__)
/* Supported since GCC 7 */
#define TS_FALLTHROUGH __attribute__((fallthrough))
#endif
#else
/* MSVC and other compilers */
#define TS_FALLTHROUGH /* FALLTHROUGH */
#endif

Expand Down