aboutsummaryrefslogtreecommitdiff
path: root/libcpp/traditional.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-01-28 07:58:29 -0800
committerNathan Sidwell <nathan@acm.org>2020-01-28 08:02:17 -0800
commit3d056cbfb3484f4037b34c908b26e1c6776c86b5 (patch)
tree591410d4cd98b8777276072cc5af998a3f97d97c /libcpp/traditional.c
parenta5d81aaab6d54379cd3835b33d84d9be5c5be099 (diff)
downloadgcc-3d056cbfb3484f4037b34c908b26e1c6776c86b5.zip
gcc-3d056cbfb3484f4037b34c908b26e1c6776c86b5.tar.gz
gcc-3d056cbfb3484f4037b34c908b26e1c6776c86b5.tar.bz2
preprocessor: Make __has_include a builtin macro [PR93452]
The clever hack of '#define __has_include __has_include' breaks -dD and -fdirectives-only, because that emits definitions. This turns __has_include into a proper builtin macro. Thus it's never emitted via -dD, and because use outside of directive processing is undefined, we can just expand it anywhere. PR preprocessor/93452 * internal.h (struct spec_nodes): Drop n__has_include{,_next}. * directives.c (lex_macro_node): Don't check __has_include redef. * expr.c (eval_token): Drop __has_include eval. (parse_has_include): Move to ... * macro.c (builtin_has_include): ... here. (_cpp_builtin_macro_text): Eval __has_include{,_next}. * include/cpplib.h (enum cpp_builtin_type): Add BT_HAS_INCLUDE{,_NEXT}. * init.c (builtin_array): Add them. (cpp_init_builtins): Drop __has_include{,_next} init here ... * pch.c (cpp_read_state): ... and here. * traditional.c (enum ls): Drop has_include states ... (_cpp_scan_out_logical_line): ... and here.
Diffstat (limited to 'libcpp/traditional.c')
-rw-r--r--libcpp/traditional.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/libcpp/traditional.c b/libcpp/traditional.c
index ff06d31..039fcfe 100644
--- a/libcpp/traditional.c
+++ b/libcpp/traditional.c
@@ -77,9 +77,8 @@ enum ls {ls_none = 0, /* Normal state. */
ls_defined_close, /* Looking for ')' of defined(). */
ls_hash, /* After # in preprocessor conditional. */
ls_predicate, /* After the predicate, maybe paren? */
- ls_answer, /* In answer to predicate. */
- ls_has_include, /* After __has_include. */
- ls_has_include_close}; /* Looking for ')' of __has_include. */
+ ls_answer /* In answer to predicate. */
+};
/* Lexing TODO: Maybe handle space in escaped newlines. Stop lex.c
from recognizing comments and directives during its lexing pass. */
@@ -564,13 +563,6 @@ _cpp_scan_out_logical_line (cpp_reader *pfile, cpp_macro *macro,
lex_state = ls_defined;
continue;
}
- else if (pfile->state.in_expression
- && (node == pfile->spec_nodes.n__has_include
- || node == pfile->spec_nodes.n__has_include_next))
- {
- lex_state = ls_has_include;
- continue;
- }
}
break;
@@ -594,8 +586,6 @@ _cpp_scan_out_logical_line (cpp_reader *pfile, cpp_macro *macro,
lex_state = ls_answer;
else if (lex_state == ls_defined)
lex_state = ls_defined_close;
- else if (lex_state == ls_has_include)
- lex_state = ls_has_include_close;
}
break;
@@ -729,8 +719,7 @@ _cpp_scan_out_logical_line (cpp_reader *pfile, cpp_macro *macro,
goto new_context;
}
}
- else if (lex_state == ls_answer || lex_state == ls_defined_close
- || lex_state == ls_has_include_close)
+ else if (lex_state == ls_answer || lex_state == ls_defined_close)
lex_state = ls_none;
}
break;
@@ -811,8 +800,7 @@ _cpp_scan_out_logical_line (cpp_reader *pfile, cpp_macro *macro,
lex_state = ls_none;
else if (lex_state == ls_hash
|| lex_state == ls_predicate
- || lex_state == ls_defined
- || lex_state == ls_has_include)
+ || lex_state == ls_defined)
lex_state = ls_none;
/* ls_answer and ls_defined_close keep going until ')'. */