diff options
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/c-lang.cc | 9 | ||||
-rw-r--r-- | gcc/c/c-objc-common.cc | 33 | ||||
-rw-r--r-- | gcc/c/c-objc-common.h | 3 |
3 files changed, 45 insertions, 0 deletions
diff --git a/gcc/c/c-lang.cc b/gcc/c/c-lang.cc index ddfd3e8..ff6633e 100644 --- a/gcc/c/c-lang.cc +++ b/gcc/c/c-lang.cc @@ -63,6 +63,15 @@ c_get_sarif_source_language (const char *) return "c"; } +/* Implement c-family hook to register language-specific features for + __has_{feature,extension}. */ + +void +c_family_register_lang_features () +{ + c_register_features (); +} + #if CHECKING_P namespace selftest { diff --git a/gcc/c/c-objc-common.cc b/gcc/c/c-objc-common.cc index c8f49aa..53eda7f 100644 --- a/gcc/c/c-objc-common.cc +++ b/gcc/c/c-objc-common.cc @@ -34,6 +34,39 @@ along with GCC; see the file COPYING3. If not see static bool c_tree_printer (pretty_printer *, text_info *, const char *, int, bool, bool, bool, bool *, const char **); +/* Info for C language features which can be queried through + __has_{feature,extension}. */ + +struct c_feature_info +{ + const char *ident; + const int *enable_flag; +}; + +static const c_feature_info c_feature_table[] = +{ + { "c_alignas", &flag_isoc11 }, + { "c_alignof", &flag_isoc11 }, + { "c_atomic", &flag_isoc11 }, + { "c_generic_selections", &flag_isoc11 }, + { "c_static_assert", &flag_isoc11 }, + { "c_thread_local", &flag_isoc11 }, + { "cxx_binary_literals", &flag_isoc23 } +}; + +/* Register features specific to the C language. */ + +void +c_register_features () +{ + for (unsigned i = 0; i < ARRAY_SIZE (c_feature_table); i++) + { + const c_feature_info *info = c_feature_table + i; + const bool feat_p = !info->enable_flag || *info->enable_flag; + c_common_register_feature (info->ident, feat_p); + } +} + bool c_missing_noreturn_ok_p (tree decl) { diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h index ede451c..63aff70 100644 --- a/gcc/c/c-objc-common.h +++ b/gcc/c/c-objc-common.h @@ -21,6 +21,9 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_C_OBJC_COMMON #define GCC_C_OBJC_COMMON +/* Implemented in c-objc-common.cc. */ +extern void c_register_features (); + /* Lang hooks that are shared between C and ObjC are defined here. Hooks specific to C or ObjC go in c-lang.cc and objc/objc-lang.cc, respectively. */ |