summaryrefslogtreecommitdiff
path: root/gcc/cppinit.c
diff options
context:
space:
mode:
authorneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-20 22:52:11 +0000
committerneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-20 22:52:11 +0000
commiteef6c20f1e0ede5a3a5bfc031d370316f4934000 (patch)
treeda85e6f46726842d6187a452b89d7a507bc2f85c /gcc/cppinit.c
parent5ec3ff43c8262371e4d9da027e1752594abfaf18 (diff)
downloadgcc-eef6c20f1e0ede5a3a5bfc031d370316f4934000.tar.gz
* cppinit.c (set_lang): Move builtin handling to...
(init_builtins): ...here. (_cpp_create_reader): Move call to set_lang. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39934 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r--gcc/cppinit.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index 539366660b1..d885a764615 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