From: Zack Weinberg Date: Mon, 2 Jul 2001 18:55:35 +0000 (+0000) Subject: cppinit.c (lang_defaults): New table. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a01eb545c4ec23419355bc3cc4d231d5043d02a8;p=gcc.git cppinit.c (lang_defaults): New table. * cppinit.c (lang_defaults): New table. (set_lang): Just read from lang_defaults into the live options structure. From-SVN: r43699 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ebaf3f544d0..ec3252cfbb3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2001-07-02 Zack Weinberg + + * cppinit.c (lang_defaults): New table. + (set_lang): Just read from lang_defaults into the live options + structure. + 2001-07-02 Zack Weinberg * Makefile.in (doc): Depend on $(GENERATED_MANPAGES). diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 0d3d3a0d634..3c446b27989 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -370,85 +370,51 @@ merge_include_chains (pfile) /* Sets internal flags correctly for a given language, and defines macros if necessary. */ + +struct lang_flags +{ + char c99; + char objc; + char cplusplus; + char extended_numbers; + char trigraphs; + char dollars_in_ident; + char cplusplus_comments; + char digraphs; +}; + +/* ??? Enable $ in identifiers in assembly? */ +static const struct lang_flags lang_defaults[] = +{ /* c99 objc c++ xnum trig 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 }, + /* STDC94 */ { 0, 0, 0, 0, 1, 0, 0, 1 }, + /* STDC99 */ { 1, 0, 0, 1, 1, 0, 1, 1 }, + /* GNUCXX */ { 0, 0, 1, 1, 0, 1, 1, 1 }, + /* CXX98 */ { 0, 0, 1, 1, 1, 0, 1, 1 }, + /* OBJC */ { 0, 1, 0, 1, 0, 1, 1, 1 }, + /* OBJCXX */ { 0, 1, 1, 1, 0, 1, 1, 1 }, + /* ASM */ { 0, 0, 0, 1, 0, 0, 1, 0 } +}; + static void set_lang (pfile, lang) cpp_reader *pfile; enum c_lang lang; { - /* Defaults. */ + const struct lang_flags *l = &lang_defaults[(int) lang]; + CPP_OPTION (pfile, lang) = lang; - CPP_OPTION (pfile, objc) = 0; - CPP_OPTION (pfile, cplusplus) = 0; - CPP_OPTION (pfile, extended_numbers) = 1; /* Allowed in GNU C and C99. */ - - switch (lang) - { - /* GNU C. */ - case CLK_GNUC99: - CPP_OPTION (pfile, trigraphs) = 0; - CPP_OPTION (pfile, dollars_in_ident) = 1; - CPP_OPTION (pfile, cplusplus_comments) = 1; - CPP_OPTION (pfile, digraphs) = 1; - CPP_OPTION (pfile, c99) = 1; - break; - case CLK_GNUC89: - CPP_OPTION (pfile, trigraphs) = 0; - CPP_OPTION (pfile, dollars_in_ident) = 1; - CPP_OPTION (pfile, cplusplus_comments) = 1; - CPP_OPTION (pfile, digraphs) = 1; - CPP_OPTION (pfile, c99) = 0; - break; - /* ISO C. */ - case CLK_STDC94: - case CLK_STDC89: - CPP_OPTION (pfile, trigraphs) = 1; - CPP_OPTION (pfile, dollars_in_ident) = 0; - CPP_OPTION (pfile, cplusplus_comments) = 0; - CPP_OPTION (pfile, digraphs) = lang == CLK_STDC94; - CPP_OPTION (pfile, c99) = 0; - CPP_OPTION (pfile, extended_numbers) = 0; - break; - case CLK_STDC99: - CPP_OPTION (pfile, trigraphs) = 1; - CPP_OPTION (pfile, dollars_in_ident) = 0; - CPP_OPTION (pfile, cplusplus_comments) = 1; - CPP_OPTION (pfile, digraphs) = 1; - CPP_OPTION (pfile, c99) = 1; - break; - - /* Objective C. */ - case CLK_OBJCXX: - CPP_OPTION (pfile, cplusplus) = 1; - case CLK_OBJC: - CPP_OPTION (pfile, trigraphs) = 0; - CPP_OPTION (pfile, dollars_in_ident) = 1; - CPP_OPTION (pfile, cplusplus_comments) = 1; - CPP_OPTION (pfile, digraphs) = 1; - CPP_OPTION (pfile, c99) = 0; - CPP_OPTION (pfile, objc) = 1; - break; - - /* C++. */ - case CLK_GNUCXX: - case CLK_CXX98: - CPP_OPTION (pfile, cplusplus) = 1; - CPP_OPTION (pfile, trigraphs) = lang == CLK_CXX98; - CPP_OPTION (pfile, dollars_in_ident) = lang == CLK_GNUCXX; - CPP_OPTION (pfile, cplusplus_comments) = 1; - CPP_OPTION (pfile, digraphs) = 1; - CPP_OPTION (pfile, c99) = 0; - break; - - /* Assembler. */ - case CLK_ASM: - CPP_OPTION (pfile, trigraphs) = 0; - CPP_OPTION (pfile, dollars_in_ident) = 0; /* Maybe not? */ - CPP_OPTION (pfile, cplusplus_comments) = 1; - CPP_OPTION (pfile, digraphs) = 0; - CPP_OPTION (pfile, c99) = 0; - break; - } + CPP_OPTION (pfile, c99) = l->c99; + 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, dollars_in_ident) = l->dollars_in_ident; + CPP_OPTION (pfile, cplusplus_comments) = l->cplusplus_comments; + CPP_OPTION (pfile, digraphs) = l->digraphs; } #ifdef HOST_EBCDIC