diff options
author | aaw <aaw@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-07-30 18:29:20 +0000 |
---|---|---|
committer | aaw <aaw@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-07-30 18:29:20 +0000 |
commit | fcde64dc3abc672d1353e44993b839c4db1d5758 (patch) | |
tree | bb584ffda6bfb46d8b03b533da0e2f408e0bbd23 /libcpp/init.c | |
parent | 81a410b1e4f861bb1eb31c7fa7daedf6bf70abc4 (diff) | |
download | gcc-fcde64dc3abc672d1353e44993b839c4db1d5758.tar.gz |
libcpp/
* directives-only.c: New file.
* internal.h (struct _cpp_dir_only_callbacks): New.
(_cpp_preprocess_dir_only): New function.
* directives.c (_cpp_handle_directive): Check directives_only before
disabling execution of indented directives.
* files.c (_cpp_stack_file): Add directives_only check.
* include/cpplib.h (struct cpp_options): Add directives_only.
(cpp_init_special_builtins): New function.
* init.c (cpp_init_special_builtins): New function.
(cpp_init_builtins): Move builtin_array initialization to
cpp_init_special_builtins.
(post_options): Check directives_only before setting
pfile->state.prevent_expansion = 1.
* macro.c (_cpp_builtin_macro_text): Print an error if __COUNTER__
is expanded inside a directive while -fdirectives-only is enabled.
* Makefile.in (libcpp_a_OBJS): Add directives-only.o.
(libcpp_a_SOURCES): Add directives-only.c.
gcc/
* c-ppoutput.c (print_lines_directives_only): New function.
(scan_translation_unit_directives_only): New function.
(preprocess_file): Add call to scan_translation_unit_directives_only.
* c-opts.c (c_common_handle_option): Add OPT_fdirectives_only.
(sanitize_cpp_opts): Add default flag_dump_macros setting for
-fdirectives-only. Add errors for -fdirectives-only conflict with
-Wunused-macros and -traditional.
(finish_options): Add builtin macro initialization for
-fdirectives-only + -fpreprocessed.
* c.opt (fdirectives-only): New.
* doc/cppopts.texi (fdirectives-only): New.
gcc/testsuite/
* gcc.dg/cpp/counter-2.c: New test.
* gcc.dg/cpp/counter-3.c: New test.
* gcc.dg/cpp/dir-only-1.c: New test.
* gcc.dg/cpp/dir-only-1.h: New file.
* gcc.dg/cpp/dir-only-2.c: New test.
* gcc.dg/cpp/dir-only-3.c: New test.
* gcc.dg/cpp/dir-only-3a.h: New file.
* gcc.dg/cpp/dir-only-3b.h: New file.
* gcc.dg/cpp/dir-only-4.c: New test.
* gcc.dg/cpp/dir-only-5.c: New test.
* gcc.dg/cpp/dir-only-6.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127066 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/init.c')
-rw-r--r-- | libcpp/init.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/libcpp/init.c b/libcpp/init.c index 71583df94d6..62f4f95dcf4 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -350,11 +350,8 @@ mark_named_operators (cpp_reader *pfile) } } -/* Read the builtins table above and enter them, and language-specific - macros, into the hash table. HOSTED is true if this is a hosted - environment. */ void -cpp_init_builtins (cpp_reader *pfile, int hosted) +cpp_init_special_builtins (cpp_reader *pfile) { const struct builtin *b; size_t n = ARRAY_SIZE (builtin_array); @@ -363,10 +360,7 @@ cpp_init_builtins (cpp_reader *pfile, int hosted) n -= 2; else if (! CPP_OPTION (pfile, stdc_0_in_system_headers) || CPP_OPTION (pfile, std)) - { - n--; - _cpp_define_builtin (pfile, "__STDC__ 1"); - } + n--; for (b = builtin_array; b < builtin_array + n; b++) { @@ -375,6 +369,20 @@ cpp_init_builtins (cpp_reader *pfile, int hosted) hp->flags |= NODE_BUILTIN | NODE_WARN; hp->value.builtin = (enum builtin_type) b->value; } +} + +/* Read the builtins table above and enter them, and language-specific + macros, into the hash table. HOSTED is true if this is a hosted + environment. */ +void +cpp_init_builtins (cpp_reader *pfile, int hosted) +{ + cpp_init_special_builtins (pfile); + + if (!CPP_OPTION (pfile, traditional) + && (! CPP_OPTION (pfile, stdc_0_in_system_headers) + || CPP_OPTION (pfile, std))) + _cpp_define_builtin (pfile, "__STDC__ 1"); if (CPP_OPTION (pfile, cplusplus)) _cpp_define_builtin (pfile, "__cplusplus 1"); @@ -622,7 +630,8 @@ post_options (cpp_reader *pfile) preprocessed text. Read preprocesed source in ISO mode. */ if (CPP_OPTION (pfile, preprocessed)) { - pfile->state.prevent_expansion = 1; + if (!CPP_OPTION (pfile, directives_only)) + pfile->state.prevent_expansion = 1; CPP_OPTION (pfile, traditional) = 0; } |