aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c153
1 files changed, 82 insertions, 71 deletions
diff --git a/parse.c b/parse.c
index b3bf15d..34fa562 100644
--- a/parse.c
+++ b/parse.c
@@ -470,83 +470,85 @@ static struct init_keyword {
{ "__TI__", NS_KEYWORD, MOD_LONGLONGLONG, .op = &mode_TI_op },
{ "word", NS_KEYWORD, MOD_LONG, .op = &mode_word_op },
{ "__word__", NS_KEYWORD, MOD_LONG, .op = &mode_word_op },
+};
- /* Ignored attributes */
- { "nothrow", NS_KEYWORD, .op = &ignore_attr_op },
- { "__nothrow", NS_KEYWORD, .op = &ignore_attr_op },
- { "__nothrow__", NS_KEYWORD, .op = &ignore_attr_op },
- { "malloc", NS_KEYWORD, .op = &ignore_attr_op },
- { "__malloc__", NS_KEYWORD, .op = &ignore_attr_op },
- { "nonnull", NS_KEYWORD, .op = &ignore_attr_op },
- { "__nonnull", NS_KEYWORD, .op = &ignore_attr_op },
- { "__nonnull__", NS_KEYWORD, .op = &ignore_attr_op },
- { "format", NS_KEYWORD, .op = &ignore_attr_op },
- { "__format__", NS_KEYWORD, .op = &ignore_attr_op },
- { "format_arg", NS_KEYWORD, .op = &ignore_attr_op },
- { "__format_arg__", NS_KEYWORD, .op = &ignore_attr_op },
- { "section", NS_KEYWORD, .op = &ignore_attr_op },
- { "__section__",NS_KEYWORD, .op = &ignore_attr_op },
- { "unused", NS_KEYWORD, .op = &ignore_attr_op },
- { "__unused__", NS_KEYWORD, .op = &ignore_attr_op },
- { "const", NS_KEYWORD, .op = &ignore_attr_op },
- { "__const", NS_KEYWORD, .op = &ignore_attr_op },
- { "__const__", NS_KEYWORD, .op = &ignore_attr_op },
- { "no_instrument_function", NS_KEYWORD, .op = &ignore_attr_op },
- { "__no_instrument_function__", NS_KEYWORD, .op = &ignore_attr_op },
- { "sentinel", NS_KEYWORD, .op = &ignore_attr_op },
- { "__sentinel__", NS_KEYWORD, .op = &ignore_attr_op },
- { "regparm", NS_KEYWORD, .op = &ignore_attr_op },
- { "__regparm__", NS_KEYWORD, .op = &ignore_attr_op },
- { "weak", NS_KEYWORD, .op = &ignore_attr_op },
- { "__weak__", NS_KEYWORD, .op = &ignore_attr_op },
- { "alias", NS_KEYWORD, .op = &ignore_attr_op },
- { "__alias__", NS_KEYWORD, .op = &ignore_attr_op },
- { "pure", NS_KEYWORD, .op = &ignore_attr_op },
- { "__pure__", NS_KEYWORD, .op = &ignore_attr_op },
- { "always_inline", NS_KEYWORD, .op = &ignore_attr_op },
- { "__always_inline__", NS_KEYWORD, .op = &ignore_attr_op },
- { "syscall_linkage", NS_KEYWORD, .op = &ignore_attr_op },
- { "__syscall_linkage__", NS_KEYWORD, .op = &ignore_attr_op },
- { "visibility", NS_KEYWORD, .op = &ignore_attr_op },
- { "__visibility__", NS_KEYWORD, .op = &ignore_attr_op },
- { "deprecated", NS_KEYWORD, .op = &ignore_attr_op },
- { "__deprecated__", NS_KEYWORD, .op = &ignore_attr_op },
- { "noinline", NS_KEYWORD, .op = &ignore_attr_op },
- { "__noinline__", NS_KEYWORD, .op = &ignore_attr_op },
- { "used", NS_KEYWORD, .op = &ignore_attr_op },
- { "__used__", NS_KEYWORD, .op = &ignore_attr_op },
- { "warn_unused_result", NS_KEYWORD, .op = &ignore_attr_op },
- { "__warn_unused_result__", NS_KEYWORD, .op = &ignore_attr_op },
- { "model", NS_KEYWORD, .op = &ignore_attr_op },
- { "__model__", NS_KEYWORD, .op = &ignore_attr_op },
- { "cdecl", NS_KEYWORD, .op = &ignore_attr_op },
- { "__cdecl__", NS_KEYWORD, .op = &ignore_attr_op },
- { "stdcall", NS_KEYWORD, .op = &ignore_attr_op },
- { "__stdcall__", NS_KEYWORD, .op = &ignore_attr_op },
- { "fastcall", NS_KEYWORD, .op = &ignore_attr_op },
- { "__fastcall__", NS_KEYWORD, .op = &ignore_attr_op },
- { "dllimport", NS_KEYWORD, .op = &ignore_attr_op },
- { "__dllimport__", NS_KEYWORD, .op = &ignore_attr_op },
- { "dllexport", NS_KEYWORD, .op = &ignore_attr_op },
- { "__dllexport__", NS_KEYWORD, .op = &ignore_attr_op },
- { "constructor", NS_KEYWORD, .op = &ignore_attr_op },
- { "__constructor__", NS_KEYWORD, .op = &ignore_attr_op },
- { "destructor", NS_KEYWORD, .op = &ignore_attr_op },
- { "__destructor__", NS_KEYWORD, .op = &ignore_attr_op },
- { "cold", NS_KEYWORD, .op = &ignore_attr_op },
- { "__cold__", NS_KEYWORD, .op = &ignore_attr_op },
- { "hot", NS_KEYWORD, .op = &ignore_attr_op },
- { "__hot__", NS_KEYWORD, .op = &ignore_attr_op },
- { "warning", NS_KEYWORD, .op = &ignore_attr_op },
- { "__warning__", NS_KEYWORD, .op = &ignore_attr_op },
- { "bounded", NS_KEYWORD, .op = &ignore_attr_op },
- { "__bounded__", NS_KEYWORD, .op = &ignore_attr_op },
+const char *ignored_attributes[] = {
+ "alias",
+ "__alias__",
+ "always_inline",
+ "__always_inline__",
+ "bounded",
+ "__bounded__",
+ "cdecl",
+ "__cdecl__",
+ "cold",
+ "__cold__",
+ "const",
+ "__const",
+ "__const__",
+ "constructor",
+ "__constructor__",
+ "deprecated",
+ "__deprecated__",
+ "destructor",
+ "__destructor__",
+ "dllexport",
+ "__dllexport__",
+ "dllimport",
+ "__dllimport__",
+ "fastcall",
+ "__fastcall__",
+ "format",
+ "__format__",
+ "format_arg",
+ "__format_arg__",
+ "hot",
+ "__hot__",
+ "malloc",
+ "__malloc__",
+ "model",
+ "__model__",
+ "no_instrument_function",
+ "__no_instrument_function__",
+ "noinline",
+ "__noinline__",
+ "nonnull",
+ "__nonnull",
+ "__nonnull__",
+ "nothrow",
+ "__nothrow",
+ "__nothrow__",
+ "pure",
+ "__pure__",
+ "regparm",
+ "__regparm__",
+ "section",
+ "__section__",
+ "sentinel",
+ "__sentinel__",
+ "stdcall",
+ "__stdcall__",
+ "syscall_linkage",
+ "__syscall_linkage__",
+ "unused",
+ "__unused__",
+ "used",
+ "__used__",
+ "visibility",
+ "__visibility__",
+ "warn_unused_result",
+ "__warn_unused_result__",
+ "warning",
+ "__warning__",
+ "weak",
+ "__weak__",
};
+
void init_parser(int stream)
{
int i;
- for (i = 0; i < sizeof keyword_table/sizeof keyword_table[0]; i++) {
+ for (i = 0; i < ARRAY_SIZE(keyword_table); i++) {
struct init_keyword *ptr = keyword_table + i;
struct symbol *sym = create_symbol(stream, ptr->name, SYM_KEYWORD, ptr->ns);
sym->ident->keyword = 1;
@@ -556,8 +558,17 @@ void init_parser(int stream)
sym->ctype.base_type = ptr->type;
sym->op = ptr->op;
}
+
+ for (i = 0; i < ARRAY_SIZE(ignored_attributes); i++) {
+ const char * name = ignored_attributes[i];
+ struct symbol *sym = create_symbol(stream, name, SYM_KEYWORD,
+ NS_KEYWORD);
+ sym->ident->keyword = 1;
+ sym->op = &ignore_attr_op;
+ }
}
+
// Add a symbol to the list of function-local symbols
static void fn_local_symbol(struct symbol *sym)
{