/* Set up the identifier hash table. Use TABLE if non-null, otherwise create our own. */ void _cpp_init_hashtable (cpp_reader *pfile, hash_table *table) { struct spec_nodes *s; if (table == NULL) { pfile->our_hashtable = 1; table = ht_create (13); /* 8K (=2^13) entries. */ table->alloc_node = (hashnode (*) (hash_table *)) alloc_node; _obstack_begin (&pfile->hash_ob, 0, 0, (void *(*) (long)) xmalloc, (void (*) (void *)) free); } table->pfile = pfile; pfile->hash_table = table; /* Now we can initialize things that use the hash table. */ _cpp_init_directives (pfile); _cpp_init_internal_pragmas (pfile); s = &pfile->spec_nodes; s->n_defined = cpp_lookup (pfile, DSC("defined")); s->n_true = cpp_lookup (pfile, DSC("true")); s->n_false = cpp_lookup (pfile, DSC("false")); s->n__VA_ARGS__ = cpp_lookup (pfile, DSC("__VA_ARGS__")); s->n__VA_ARGS__->flags |= NODE_DIAGNOSTIC; }
void cpp_init_special_builtins (cpp_reader *pfile) { const struct builtin_macro *b; size_t n = ARRAY_SIZE (builtin_array); if (CPP_OPTION (pfile, traditional)) n -= 2; else if (! CPP_OPTION (pfile, stdc_0_in_system_headers) || CPP_OPTION (pfile, std)) n--; for (b = builtin_array; b < builtin_array + n; b++) { if (b->value == BT_HAS_ATTRIBUTE && (CPP_OPTION (pfile, lang) == CLK_ASM || pfile->cb.has_attribute == NULL)) continue; cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len); hp->type = NT_MACRO; hp->flags |= NODE_BUILTIN; if (b->always_warn_if_redefined) hp->flags |= NODE_WARN; hp->value.builtin = (enum cpp_builtin_type) b->value; } }
/* Read the builtins table above and enter them, and language-specific macros, into the hash table. HOSTED is true if this is a hosted environment. */ void cpp_init_builtins (cpp_reader *pfile, int hosted) { const struct builtin *b; size_t n = ARRAY_SIZE (builtin_array); if (CPP_OPTION (pfile, traditional)) n -= 2; for(b = builtin_array; b < builtin_array + n; b++) { cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len); hp->type = NT_MACRO; hp->flags |= NODE_BUILTIN | NODE_WARN; hp->value.builtin = b->value; } if (CPP_OPTION (pfile, cplusplus)) _cpp_define_builtin (pfile, "__cplusplus 1"); else if (CPP_OPTION (pfile, lang) == CLK_ASM) _cpp_define_builtin (pfile, "__ASSEMBLER__ 1"); else if (CPP_OPTION (pfile, lang) == CLK_STDC94) _cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L"); else if (CPP_OPTION (pfile, c99)) _cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L"); if (hosted) _cpp_define_builtin (pfile, "__STDC_HOSTED__ 1"); else _cpp_define_builtin (pfile, "__STDC_HOSTED__ 0"); if (CPP_OPTION (pfile, objc)) _cpp_define_builtin (pfile, "__OBJC__ 1"); }
/* Set up the identifier hash table. Use TABLE if non-null, otherwise create our own. */ void _cpp_init_hashtable (cpp_reader *pfile, cpp_hash_table *table) { struct spec_nodes *s; if (table == NULL) { pfile->our_hashtable = 1; table = ht_create (13); /* 8K (=2^13) entries. */ table->alloc_node = alloc_node; obstack_specify_allocation (&pfile->hash_ob, 0, 0, xmalloc, free); } table->pfile = pfile; pfile->hash_table = table; /* Now we can initialize things that use the hash table. */ _cpp_init_directives (pfile); _cpp_init_internal_pragmas (pfile); s = &pfile->spec_nodes; s->n_defined = cpp_lookup (pfile, DSC("defined")); s->n_true = cpp_lookup (pfile, DSC("true")); s->n_false = cpp_lookup (pfile, DSC("false")); s->n__VA_ARGS__ = cpp_lookup (pfile, DSC("__VA_ARGS__")); s->n__VA_ARGS__->flags |= NODE_DIAGNOSTIC; s->n__has_include__ = cpp_lookup (pfile, DSC("__has_include__")); s->n__has_include_next__ = cpp_lookup (pfile, DSC("__has_include_next__")); s->n__has_attribute__ = cpp_lookup (pfile, DSC("__has_attribute__")); }
/* SDCPP specific option initialization */ static unsigned int sdcpp_init_options (unsigned int argc, const char **argv) { unsigned int ret = sdcpp_common_init_options(argc, argv); CPP_OPTION (parse_in, allow_naked_hash) = 0; CPP_OPTION (parse_in, preproc_asm) = 1; CPP_OPTION (parse_in, pedantic_parse_number) = 0; CPP_OPTION (parse_in, obj_ext) = NULL; /* Kevin abuse for SDCC. */ cpp_register_pragma(parse_in, 0, "sdcc_hash", do_pragma_sdcc_hash, false); /* SDCC _asm specific */ cpp_register_pragma(parse_in, 0, "preproc_asm", do_pragma_preproc_asm, false); /* SDCC specific */ cpp_register_pragma(parse_in, 0, "pedantic_parse_number", do_pragma_pedantic_parse_number, false); /* SDCC _asm specific */ parse_in->spec_nodes.n__asm = cpp_lookup (parse_in, DSC("__asm")); parse_in->spec_nodes.n__endasm = cpp_lookup (parse_in, DSC("__endasm")); return ret; }
/* Mark the C++ named operators in the hash table. */ static void mark_named_operators (cpp_reader *pfile, int flags) { const struct builtin_operator *b; for (b = operator_array; b < (operator_array + ARRAY_SIZE (operator_array)); b++) { cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len); hp->flags |= flags; hp->is_directive = 0; hp->directive_index = b->value; } }
void cpp_init_special_builtins (cpp_reader *pfile) { const struct builtin *b; size_t n = ARRAY_SIZE (builtin_array); if (CPP_OPTION (pfile, traditional)) n -= 2; else if (! CPP_OPTION (pfile, stdc_0_in_system_headers) || CPP_OPTION (pfile, std)) n--; for (b = builtin_array; b < builtin_array + n; b++) { cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len); hp->type = NT_MACRO; hp->flags |= NODE_BUILTIN | NODE_WARN; hp->value.builtin = (enum builtin_type) b->value; } }