diff options
Diffstat (limited to 'contrib/gcc/cppinit.c')
-rw-r--r-- | contrib/gcc/cppinit.c | 115 |
1 files changed, 64 insertions, 51 deletions
diff --git a/contrib/gcc/cppinit.c b/contrib/gcc/cppinit.c index d15a884..477c85d 100644 --- a/contrib/gcc/cppinit.c +++ b/contrib/gcc/cppinit.c @@ -101,6 +101,7 @@ static void path_include PARAMS ((cpp_reader *, char *, int)); static void init_library PARAMS ((void)); static void init_builtins PARAMS ((cpp_reader *)); +static void mark_named_operators PARAMS ((cpp_reader *)); static void append_include_chain PARAMS ((cpp_reader *, char *, int, int)); static struct search_path * remove_dup_dir PARAMS ((cpp_reader *, @@ -190,7 +191,7 @@ path_include (pfile, list, path) name[q - p] = 0; } - append_include_chain (pfile, name, path, 0); + append_include_chain (pfile, name, path, path == SYSTEM); /* Advance past this name. */ if (*q == 0) @@ -397,7 +398,7 @@ struct lang_flags char objc; char cplusplus; char extended_numbers; - char trigraphs; + char std; char dollars_in_ident; char cplusplus_comments; char digraphs; @@ -405,7 +406,7 @@ struct lang_flags /* ??? Enable $ in identifiers in assembly? */ static const struct lang_flags lang_defaults[] = -{ /* c99 objc c++ xnum trig dollar c++comm digr */ +{ /* c99 objc c++ xnum std dollar c++comm digr */ /* GNUC89 */ { 0, 0, 0, 1, 0, 1, 1, 1 }, /* GNUC99 */ { 1, 0, 0, 1, 0, 1, 1, 1 }, /* STDC89 */ { 0, 0, 0, 0, 1, 0, 0, 0 }, @@ -432,7 +433,8 @@ set_lang (pfile, lang) CPP_OPTION (pfile, objc) = l->objc; CPP_OPTION (pfile, cplusplus) = l->cplusplus; CPP_OPTION (pfile, extended_numbers) = l->extended_numbers; - CPP_OPTION (pfile, trigraphs) = l->trigraphs; + CPP_OPTION (pfile, std) = l->std; + CPP_OPTION (pfile, trigraphs) = l->std; CPP_OPTION (pfile, dollars_in_ident) = l->dollars_in_ident; CPP_OPTION (pfile, cplusplus_comments) = l->cplusplus_comments; CPP_OPTION (pfile, digraphs) = l->digraphs; @@ -614,28 +616,22 @@ cpp_destroy (pfile) Two values are not compile time constants, so we tag them in the FLAGS field instead: VERS value is the global version_string, quoted - ULP value is the global user_label_prefix - - Also, macros with CPLUS set in the flags field are entered only for C++. */ + ULP value is the global user_label_prefix */ struct builtin { const U_CHAR *name; const char *value; unsigned char builtin; - unsigned char operator; unsigned short flags; unsigned short len; }; #define VERS 0x01 #define ULP 0x02 -#define CPLUS 0x04 #define BUILTIN 0x08 -#define OPERATOR 0x10 -#define B(n, t) { U n, 0, t, 0, BUILTIN, sizeof n - 1 } -#define C(n, v) { U n, v, 0, 0, 0, sizeof n - 1 } -#define X(n, f) { U n, 0, 0, 0, f, sizeof n - 1 } -#define O(n, c, f) { U n, 0, 0, c, OPERATOR | f, sizeof n - 1 } +#define B(n, t) { U n, 0, t, BUILTIN, sizeof n - 1 } +#define C(n, v) { U n, v, 0, 0, sizeof n - 1 } +#define X(n, f) { U n, 0, 0, f, sizeof n - 1 } static const struct builtin builtin_array[] = { B("__TIME__", BT_TIME), @@ -671,30 +667,55 @@ static const struct builtin builtin_array[] = #else C("__STDC__", "1"), #endif - - /* Named operators known to the preprocessor. These cannot be #defined - and always have their stated meaning. They are treated like normal - identifiers except for the type code and the meaning. Most of them - are only for C++ (but see iso646.h). */ - O("and", CPP_AND_AND, CPLUS), - O("and_eq", CPP_AND_EQ, CPLUS), - O("bitand", CPP_AND, CPLUS), - O("bitor", CPP_OR, CPLUS), - O("compl", CPP_COMPL, CPLUS), - O("not", CPP_NOT, CPLUS), - O("not_eq", CPP_NOT_EQ, CPLUS), - O("or", CPP_OR_OR, CPLUS), - O("or_eq", CPP_OR_EQ, CPLUS), - O("xor", CPP_XOR, CPLUS), - O("xor_eq", CPP_XOR_EQ, CPLUS) }; #undef B #undef C #undef X -#undef O #define builtin_array_end \ builtin_array + sizeof(builtin_array)/sizeof(struct builtin) +/* Named operators known to the preprocessor. These cannot be + #defined and always have their stated meaning. They are treated + like normal identifiers except for the type code and the meaning. + Most of them are only for C++ (but see iso646.h). */ +#define B(n, t) { DSC(n), t } +static const struct named_op +{ + const U_CHAR *name; + unsigned int len; + enum cpp_ttype value; +} operator_array[] = { + B("and", CPP_AND_AND), + B("and_eq", CPP_AND_EQ), + B("bitand", CPP_AND), + B("bitor", CPP_OR), + B("compl", CPP_COMPL), + B("not", CPP_NOT), + B("not_eq", CPP_NOT_EQ), + B("or", CPP_OR_OR), + B("or_eq", CPP_OR_EQ), + B("xor", CPP_XOR), + B("xor_eq", CPP_XOR_EQ) +}; +#undef B + +/* Mark the C++ named operators in the hash table. */ +static void +mark_named_operators (pfile) + cpp_reader *pfile; +{ + const struct named_op *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 |= NODE_OPERATOR; + hp->value.operator = b->value; + } +} + /* Subroutine of cpp_read_main_file; reads the builtins table above and enters them, and language-specific macros, into the hash table. */ static void @@ -705,26 +726,12 @@ init_builtins (pfile) for(b = builtin_array; b < builtin_array_end; b++) { - if ((b->flags & CPLUS) && ! CPP_OPTION (pfile, cplusplus)) - continue; - - if ((b->flags & OPERATOR) && ! CPP_OPTION (pfile, operator_names)) - continue; - - if (b->flags & (OPERATOR | BUILTIN)) + if (b->flags & BUILTIN) { cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len); - if (b->flags & OPERATOR) - { - hp->flags |= NODE_OPERATOR; - hp->value.operator = b->operator; - } - else - { - hp->type = NT_MACRO; - hp->flags |= NODE_BUILTIN | NODE_WARN; - hp->value.builtin = b->builtin; - } + hp->type = NT_MACRO; + hp->flags |= NODE_BUILTIN | NODE_WARN; + hp->value.builtin = b->builtin; } else /* A standard macro of some kind. */ { @@ -783,7 +790,6 @@ init_builtins (pfile) #undef OPERATOR #undef VERS #undef ULP -#undef CPLUS #undef builtin_array_end /* And another subroutine. This one sets up the standard include path. */ @@ -1003,6 +1009,10 @@ void cpp_finish_options (pfile) cpp_reader *pfile; { + /* Mark named operators before handling command line macros. */ + if (CPP_OPTION (pfile, cplusplus) && CPP_OPTION (pfile, operator_names)) + mark_named_operators (pfile); + /* Install builtins and process command line macros etc. in the order they appeared, but only if not already preprocessed. */ if (! CPP_OPTION (pfile, preprocessed)) @@ -1877,7 +1887,10 @@ init_dependency_output (pfile) { spec = getenv ("SUNPRO_DEPENDENCIES"); if (spec) - CPP_OPTION (pfile, print_deps) = 2; + { + CPP_OPTION (pfile, print_deps) = 2; + CPP_OPTION (pfile, deps_ignore_main_file) = 1; + } else return; } |