diff options
author | Zack Weinberg <zack@gcc.gnu.org> | 2001-05-10 00:07:23 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2001-05-10 00:07:23 +0000 |
commit | 6d4587f7359a633dc610f5d0ad95c023f672c5d9 (patch) | |
tree | dbbe9eb784b1862db1081f71d85145cf0a696198 /gcc/cpplib.c | |
parent | 6ebe3121aa8e693a53f4964bd9b058bf73cb54bf (diff) | |
download | gcc-6d4587f7359a633dc610f5d0ad95c023f672c5d9.zip gcc-6d4587f7359a633dc610f5d0ad95c023f672c5d9.tar.gz gcc-6d4587f7359a633dc610f5d0ad95c023f672c5d9.tar.bz2 |
cppinit.c (cpp_post_options): Shut off macro expansion if -fpreprocessed.
* cppinit.c (cpp_post_options): Shut off macro expansion if
-fpreprocessed.
* cpplib.c (_cpp_handle_directive): If -fpreprocessed, accept
IN_I directives only if the # is in column 1 and the directive
name begins in column 2.
* cppmain.c (scan_buffer): Insert a space between # and an
identifier, when that identifier is a directive name.
* tradcpp.c (struct file_buf): Add a pointer to the next entry
in the header search path.
(enum node_type): Add T_INCLUDE_NEXT.
(directive_table): Add entry for include_next.
(do_include_next): New function.
(process_include): New routine, broken out of do_include.
(finclude): Insert 'nhd' argument, to be copied into
next_header_dir of the new buffer.
(main): Adjust to match.
* gsyslimits.h, limity.h: Un-indent #include_next.
testsuite:
* gcc.dg/cpp/direct2.c: New test.
* gcc.dg/cpp/direct2s.c: New test.
* gcc.c-torture/execute/920730-1t.c: #undef __GNUC__ at head.
From-SVN: r41932
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r-- | gcc/cpplib.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c index 057bdf4c..97e0cf2 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -311,7 +311,32 @@ _cpp_handle_directive (pfile, indented) /* If we are rescanning preprocessed input, only directives tagged with IN_I are honored, and the warnings below are suppressed. */ - if (! CPP_OPTION (pfile, preprocessed) || dir->flags & IN_I) + if (CPP_OPTION (pfile, preprocessed)) + { + /* Kluge alert. In order to be sure that code like this + #define HASH # + HASH define foo bar + does not cause '#define foo bar' to get executed when + compiled with -save-temps, we recognize directives in + -fpreprocessed mode only if the # is in column 1 and the + directive name starts in column 2. This output can only + be generated by the directive callbacks in cppmain.c (see + also the special case in scan_buffer). */ + if (dir->flags & IN_I && !indented && !(dname.flags & PREV_WHITE)) + (*dir->handler) (pfile); + /* That check misses '# 123' linemarkers. Let them through too. */ + else if (dname.type == CPP_NUMBER) + (*dir->handler) (pfile); + else + { + /* We don't want to process this directive. Put back the + tokens so caller will see them (and issue an error, + probably). */ + _cpp_push_token (pfile, &dname, &pfile->directive_pos); + skip = 0; + } + } + else { /* Traditionally, a directive is ignored unless its # is in column 1. Therefore in code intended to work with K+R |