summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/cppinit.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/gcc/cppinit.c')
-rw-r--r--contrib/gcc/cppinit.c121
1 files changed, 57 insertions, 64 deletions
diff --git a/contrib/gcc/cppinit.c b/contrib/gcc/cppinit.c
index adaa30f..d15a884 100644
--- a/contrib/gcc/cppinit.c
+++ b/contrib/gcc/cppinit.c
@@ -19,6 +19,8 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+/* $FreeBSD$ */
+
#include "config.h"
#include "system.h"
#include "cpplib.h"
@@ -99,7 +101,6 @@ 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 *,
@@ -189,7 +190,7 @@ path_include (pfile, list, path)
name[q - p] = 0;
}
- append_include_chain (pfile, name, path, path == SYSTEM);
+ append_include_chain (pfile, name, path, 0);
/* Advance past this name. */
if (*q == 0)
@@ -396,7 +397,7 @@ struct lang_flags
char objc;
char cplusplus;
char extended_numbers;
- char std;
+ char trigraphs;
char dollars_in_ident;
char cplusplus_comments;
char digraphs;
@@ -404,7 +405,7 @@ struct lang_flags
/* ??? Enable $ in identifiers in assembly? */
static const struct lang_flags lang_defaults[] =
-{ /* c99 objc c++ xnum std dollar c++comm digr */
+{ /* 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 },
@@ -431,8 +432,7 @@ 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, std) = l->std;
- CPP_OPTION (pfile, trigraphs) = l->std;
+ 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;
@@ -614,22 +614,28 @@ 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 */
+ ULP value is the global user_label_prefix
+
+ Also, macros with CPLUS set in the flags field are entered only for C++. */
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, 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 }
+#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 }
static const struct builtin builtin_array[] =
{
B("__TIME__", BT_TIME),
@@ -665,55 +671,30 @@ 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
@@ -724,12 +705,26 @@ init_builtins (pfile)
for(b = builtin_array; b < builtin_array_end; b++)
{
- if (b->flags & BUILTIN)
+ if ((b->flags & CPLUS) && ! CPP_OPTION (pfile, cplusplus))
+ continue;
+
+ if ((b->flags & OPERATOR) && ! CPP_OPTION (pfile, operator_names))
+ continue;
+
+ if (b->flags & (OPERATOR | BUILTIN))
{
cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
- hp->type = NT_MACRO;
- hp->flags |= NODE_BUILTIN | NODE_WARN;
- hp->value.builtin = b->builtin;
+ 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;
+ }
}
else /* A standard macro of some kind. */
{
@@ -788,6 +783,7 @@ 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. */
@@ -1007,10 +1003,6 @@ 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))
@@ -1235,6 +1227,7 @@ new_pending_directive (pend, text, handler)
DEF_OPT("std=gnu89", 0, OPT_std_gnu89) \
DEF_OPT("std=gnu99", 0, OPT_std_gnu99) \
DEF_OPT("std=gnu9x", 0, OPT_std_gnu9x) \
+ DEF_OPT("std=bsd", 0, OPT_std_bsd) \
DEF_OPT("std=iso9899:1990", 0, OPT_std_iso9899_1990) \
DEF_OPT("std=iso9899:199409", 0, OPT_std_iso9899_199409) \
DEF_OPT("std=iso9899:1999", 0, OPT_std_iso9899_1999) \
@@ -1520,6 +1513,9 @@ cpp_handle_option (pfile, argc, argv, ignore)
case OPT_std_gnu99:
set_lang (pfile, CLK_GNUC99);
break;
+ case OPT_std_bsd:
+ set_lang (pfile, CLK_GNUC89);
+ break;
case OPT_std_iso9899_199409:
set_lang (pfile, CLK_STDC94);
break;
@@ -1881,10 +1877,7 @@ init_dependency_output (pfile)
{
spec = getenv ("SUNPRO_DEPENDENCIES");
if (spec)
- {
- CPP_OPTION (pfile, print_deps) = 2;
- CPP_OPTION (pfile, deps_ignore_main_file) = 1;
- }
+ CPP_OPTION (pfile, print_deps) = 2;
else
return;
}
OpenPOWER on IntegriCloud