aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/cpphash.h5
-rw-r--r--gcc/cpplex.c5
-rw-r--r--gcc/cpplib.c23
4 files changed, 32 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8601f33..bdcc798 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2000-08-23 Zack Weinberg <zack@wolery.cumb.org>
+
+ * cpphash.h (IN_I): New flag for directive table.
+ * cpplib.c (DIRECTIVE_TABLE): Mark #define, #undef, #ident, and
+ #pragma with IN_I.
+ (_cpp_check_directive): If -fpreprocessed, execute directives
+ marked with IN_I. Issue no warnings in this case.
+ * cpplex.c (_cpp_get_token): Expand no macros if -fpreprocessed.
+
2000-08-23 Joseph S. Myers <jsm28@cam.ac.uk>
* c-common.c (print_char_table): Allow 'I' flag with %d, %i and
diff --git a/gcc/cpphash.h b/gcc/cpphash.h
index b2f5c1d..23e1d81 100644
--- a/gcc/cpphash.h
+++ b/gcc/cpphash.h
@@ -66,11 +66,14 @@ struct answer
conditional. EXPAND means that macros are to be expanded on the
directive line. INCL means to treat "..." and <...> as
q-char-sequence and h-char-sequence respectively. COMMENTS means
- preserve comments in the directive if -C. */
+ preserve comments in the directive if -C. IN_I means this directive
+ should be handled even if -fpreprocessed is in effect (these are the
+ directives with callback hooks). */
#define COND (1 << 0)
#define EXPAND (1 << 1)
#define INCL (1 << 2)
#define COMMENTS (1 << 3)
+#define IN_I (1 << 4)
/* Defines one #-directive, including how to handle it. */
typedef void (*directive_handler) PARAMS ((cpp_reader *));
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index 7b07944..779bcf0 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -3157,6 +3157,11 @@ _cpp_get_token (pfile)
be taken as a control macro. */
pfile->potential_control_macro = 0;
+ /* If we are rescanning preprocessed input, no macro expansion or
+ token pasting may occur. */
+ if (CPP_OPTION (pfile, preprocessed))
+ return token;
+
old_token = token;
/* See if there's a token to paste with this one. */
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index 274ca4a..2cc956d 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -79,21 +79,21 @@ static void unwind_if_stack PARAMS ((cpp_reader *, cpp_buffer *));
#endif
#define DIRECTIVE_TABLE \
-D(define, T_DEFINE = 0, KANDR, COMMENTS) /* 270554 */ \
+D(define, T_DEFINE = 0, KANDR, COMMENTS | IN_I)/* 270554 */ \
D(include, T_INCLUDE, KANDR, EXPAND | INCL) /* 52262 */ \
D(endif, T_ENDIF, KANDR, COND) /* 45855 */ \
D(ifdef, T_IFDEF, KANDR, COND) /* 22000 */ \
D(if, T_IF, KANDR, COND | EXPAND) /* 18162 */ \
D(else, T_ELSE, KANDR, COND) /* 9863 */ \
D(ifndef, T_IFNDEF, KANDR, COND) /* 9675 */ \
-D(undef, T_UNDEF, KANDR, 0) /* 4837 */ \
+D(undef, T_UNDEF, KANDR, IN_I) /* 4837 */ \
D(line, T_LINE, KANDR, EXPAND) /* 2465 */ \
D(elif, T_ELIF, KANDR, COND | EXPAND) /* 610 */ \
D(error, T_ERROR, STDC89, 0) /* 475 */ \
-D(pragma, T_PRAGMA, STDC89, 0) /* 195 */ \
+D(pragma, T_PRAGMA, STDC89, IN_I) /* 195 */ \
D(warning, T_WARNING, EXTENSION, 0) /* 22 GNU */ \
D(include_next, T_INCLUDE_NEXT, EXTENSION, EXPAND | INCL) /* 19 GNU */ \
-D(ident, T_IDENT, EXTENSION, 0) /* 11 SVR4 */ \
+D(ident, T_IDENT, EXTENSION, IN_I) /* 11 SVR4 */ \
D(import, T_IMPORT, EXTENSION, EXPAND | INCL) /* 0 ObjC */ \
D(assert, T_ASSERT, EXTENSION, 0) /* 0 SVR4 */ \
D(unassert, T_UNASSERT, EXTENSION, 0) /* 0 SVR4 */ \
@@ -140,14 +140,19 @@ _cpp_check_directive (pfile, token, bol)
{
unsigned int i;
- /* If we are rescanning preprocessed input, don't obey any directives
- other than # nnn. */
- if (CPP_OPTION (pfile, preprocessed))
- return 0;
-
for (i = 0; i < N_DIRECTIVES; i++)
if (pfile->spec_nodes->dirs[i] == token->val.node)
{
+ /* If we are rescanning preprocessed input, only directives
+ tagged with IN_I are to be honored, and the warnings below
+ are suppressed. */
+ if (CPP_OPTION (pfile, preprocessed))
+ {
+ if (dtable[i].flags & IN_I)
+ return &dtable[i];
+ return 0;
+ }
+
/* In -traditional mode, a directive is ignored unless its #
is in column 1. In code intended to work with K+R compilers,
therefore, directives added by C89 must have their # indented,