1 | /* Language-specific hook definitions for C front end. |
2 | Copyright (C) 1991-2024 Free Software Foundation, Inc. |
3 | |
4 | This file is part of GCC. |
5 | |
6 | GCC is free software; you can redistribute it and/or modify it under |
7 | the terms of the GNU General Public License as published by the Free |
8 | Software Foundation; either version 3, or (at your option) any later |
9 | version. |
10 | |
11 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or |
13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
14 | for more details. |
15 | |
16 | You should have received a copy of the GNU General Public License |
17 | along with GCC; see the file COPYING3. If not see |
18 | <http://www.gnu.org/licenses/>. */ |
19 | |
20 | |
21 | #include "config.h" |
22 | #include "system.h" |
23 | #include "coretypes.h" |
24 | #include "c-tree.h" |
25 | #include "langhooks.h" |
26 | #include "langhooks-def.h" |
27 | #include "c-objc-common.h" |
28 | #include "c-family/c-pragma.h" |
29 | #include "c-parser.h" |
30 | |
31 | enum c_language_kind c_language = clk_c; |
32 | |
33 | /* Lang hooks common to C and ObjC are declared in c-objc-common.h; |
34 | consequently, there should be very few hooks below. */ |
35 | |
36 | #undef LANG_HOOKS_NAME |
37 | #define LANG_HOOKS_NAME "GNU C" |
38 | #undef LANG_HOOKS_INIT |
39 | #define LANG_HOOKS_INIT c_objc_common_init |
40 | #undef LANG_HOOKS_INIT_TS |
41 | #define LANG_HOOKS_INIT_TS c_common_init_ts |
42 | |
43 | #if CHECKING_P |
44 | #undef LANG_HOOKS_RUN_LANG_SELFTESTS |
45 | #define LANG_HOOKS_RUN_LANG_SELFTESTS selftest::run_c_tests |
46 | #endif /* #if CHECKING_P */ |
47 | |
48 | #undef LANG_HOOKS_GET_SUBSTRING_LOCATION |
49 | #define LANG_HOOKS_GET_SUBSTRING_LOCATION c_get_substring_location |
50 | |
51 | #undef LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE |
52 | #define LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE c_get_sarif_source_language |
53 | |
54 | /* Each front end provides its own lang hook initializer. */ |
55 | struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; |
56 | |
57 | /* Get a value for the SARIF v2.1.0 "artifact.sourceLanguage" property, |
58 | based on the list in SARIF v2.1.0 Appendix J. */ |
59 | |
60 | const char * |
61 | c_get_sarif_source_language (const char *) |
62 | { |
63 | return "c" ; |
64 | } |
65 | |
66 | /* Implement c-family hook to register language-specific features for |
67 | __has_{feature,extension}. */ |
68 | |
69 | void |
70 | c_family_register_lang_features () |
71 | { |
72 | c_register_features (); |
73 | } |
74 | |
75 | #if CHECKING_P |
76 | |
77 | namespace selftest { |
78 | |
79 | /* Implementation of LANG_HOOKS_RUN_LANG_SELFTESTS for the C frontend. */ |
80 | |
81 | void |
82 | run_c_tests (void) |
83 | { |
84 | /* Run selftests shared within the C family. */ |
85 | c_family_tests (); |
86 | |
87 | /* Additional C-specific tests. */ |
88 | } |
89 | |
90 | } // namespace selftest |
91 | |
92 | #endif /* #if CHECKING_P */ |
93 | |
94 | |
95 | #include "gtype-c.h" |
96 | |