aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.demon.co.uk>2001-02-20 22:52:11 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-02-20 22:52:11 +0000
commitc740cee29d8abc1b547e23cdb6992c70b44f6864 (patch)
treeda85e6f46726842d6187a452b89d7a507bc2f85c /gcc
parent064a552c29257fc313b13ebe1e9bd18047b8d2c4 (diff)
downloadgcc-c740cee29d8abc1b547e23cdb6992c70b44f6864.zip
gcc-c740cee29d8abc1b547e23cdb6992c70b44f6864.tar.gz
gcc-c740cee29d8abc1b547e23cdb6992c70b44f6864.tar.bz2
cppinit.c (set_lang): Move builtin handling to...
* cppinit.c (set_lang): Move builtin handling to... (init_builtins): ...here. (_cpp_create_reader): Move call to set_lang. From-SVN: r39934
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/cppinit.c32
2 files changed, 24 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 70b8d26..c801bed 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2001-02-20 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * cppinit.c (set_lang): Move builtin handling to...
+ (init_builtins): ...here.
+ (_cpp_create_reader): Move call to set_lang.
+
2001-02-20 Mark Mitchell <mark@codesourcery.com>
* stmt.c (expand_return): If an attempt is made to return the
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index 5393666..d885a76 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -371,8 +371,6 @@ set_lang (pfile, lang)
cpp_reader *pfile;
enum c_lang lang;
{
- struct cpp_pending *pend = CPP_OPTION (pfile, pending);
-
/* Defaults. */
CPP_OPTION (pfile, lang) = lang;
CPP_OPTION (pfile, objc) = 0;
@@ -388,7 +386,6 @@ set_lang (pfile, lang)
CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, c99) = 1;
- new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define);
break;
case CLK_GNUC89:
CPP_OPTION (pfile, trigraphs) = 0;
@@ -400,7 +397,6 @@ set_lang (pfile, lang)
/* ISO C. */
case CLK_STDC94:
- new_pending_directive (pend, "__STDC_VERSION__=199409L", cpp_define);
case CLK_STDC89:
CPP_OPTION (pfile, trigraphs) = 1;
CPP_OPTION (pfile, dollars_in_ident) = 0;
@@ -408,7 +404,6 @@ set_lang (pfile, lang)
CPP_OPTION (pfile, digraphs) = lang == CLK_STDC94;
CPP_OPTION (pfile, c99) = 0;
CPP_OPTION (pfile, extended_numbers) = 0;
- new_pending_directive (pend, "__STRICT_ANSI__", cpp_define);
break;
case CLK_STDC99:
CPP_OPTION (pfile, trigraphs) = 1;
@@ -416,13 +411,10 @@ set_lang (pfile, lang)
CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, c99) = 1;
- new_pending_directive (pend, "__STRICT_ANSI__", cpp_define);
- new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define);
break;
/* Objective C. */
case CLK_OBJCXX:
- new_pending_directive (pend, "__cplusplus", cpp_define);
CPP_OPTION (pfile, cplusplus) = 1;
case CLK_OBJC:
CPP_OPTION (pfile, trigraphs) = 0;
@@ -431,7 +423,6 @@ set_lang (pfile, lang)
CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, c99) = 0;
CPP_OPTION (pfile, objc) = 1;
- new_pending_directive (pend, "__OBJC__", cpp_define);
break;
/* C++. */
@@ -443,7 +434,6 @@ set_lang (pfile, lang)
CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, c99) = 0;
- new_pending_directive (pend, "__cplusplus", cpp_define);
break;
/* Assembler. */
@@ -453,7 +443,6 @@ set_lang (pfile, lang)
CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, digraphs) = 0;
CPP_OPTION (pfile, c99) = 0;
- new_pending_directive (pend, "__ASSEMBLER__", cpp_define);
break;
}
}
@@ -509,6 +498,7 @@ cpp_create_reader (lang)
pfile = (cpp_reader *) xcalloc (1, sizeof (cpp_reader));
+ set_lang (pfile, lang);
CPP_OPTION (pfile, warn_import) = 1;
CPP_OPTION (pfile, discard_comments) = 1;
CPP_OPTION (pfile, show_column) = 1;
@@ -518,9 +508,6 @@ cpp_create_reader (lang)
CPP_OPTION (pfile, pending) =
(struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
- /* After creating pfile->pending. */
- set_lang (pfile, lang);
-
/* It's simplest to just create this struct whether or not it will
be needed. */
pfile->deps = deps_init ();
@@ -757,6 +744,23 @@ init_builtins (pfile)
_cpp_define_builtin (pfile, str);
}
}
+
+ if (CPP_OPTION (pfile, cplusplus))
+ _cpp_define_builtin (pfile, "__cplusplus 1");
+ if (CPP_OPTION (pfile, objc))
+ _cpp_define_builtin (pfile, "__OBJC__ 1");
+
+ 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 (CPP_OPTION (pfile, lang) == CLK_STDC89
+ || CPP_OPTION (pfile, lang) == CLK_STDC94
+ || CPP_OPTION (pfile, lang) == CLK_STDC99)
+ _cpp_define_builtin (pfile, "__STRICT_ANSI__ 1");
+ else if (CPP_OPTION (pfile, lang) == CLK_ASM)
+ _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
}
#undef BUILTIN
#undef OPERATOR