aboutsummaryrefslogtreecommitdiff
path: root/libcpp/expr.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp/expr.c')
-rw-r--r--libcpp/expr.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/libcpp/expr.c b/libcpp/expr.c
index 317faf5..df21a4b 100644
--- a/libcpp/expr.c
+++ b/libcpp/expr.c
@@ -64,7 +64,7 @@ static unsigned int interpret_float_suffix (cpp_reader *, const uchar *, size_t)
static unsigned int interpret_int_suffix (cpp_reader *, const uchar *, size_t);
static void check_promotion (cpp_reader *, const struct op *);
-static cpp_num parse_has_include (cpp_reader *, enum include_type);
+static cpp_num parse_has_include (cpp_reader *, cpp_hashnode *, include_type);
/* Token type abuse to create unary plus and minus operators. */
#define CPP_UPLUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 1))
@@ -1088,8 +1088,7 @@ parse_defined (cpp_reader *pfile)
result.unsignedp = false;
result.high = 0;
result.overflow = false;
- result.low = (node && cpp_macro_p (node)
- && !(node->flags & NODE_CONDITIONAL));
+ result.low = node && _cpp_defined_macro_p (node);
return result;
}
@@ -1160,10 +1159,10 @@ eval_token (cpp_reader *pfile, const cpp_token *token,
case CPP_NAME:
if (token->val.node.node == pfile->spec_nodes.n_defined)
return parse_defined (pfile);
- else if (token->val.node.node == pfile->spec_nodes.n__has_include__)
- return parse_has_include (pfile, IT_INCLUDE);
- else if (token->val.node.node == pfile->spec_nodes.n__has_include_next__)
- return parse_has_include (pfile, IT_INCLUDE_NEXT);
+ else if (token->val.node.node == pfile->spec_nodes.n__has_include)
+ return parse_has_include (pfile, token->val.node.node, IT_INCLUDE);
+ else if (token->val.node.node == pfile->spec_nodes.n__has_include_next)
+ return parse_has_include (pfile, token->val.node.node, IT_INCLUDE_NEXT);
else if (CPP_OPTION (pfile, cplusplus)
&& (token->val.node.node == pfile->spec_nodes.n_true
|| token->val.node.node == pfile->spec_nodes.n_false))
@@ -2190,9 +2189,9 @@ num_div_op (cpp_reader *pfile, cpp_num lhs, cpp_num rhs, enum cpp_ttype op,
return lhs;
}
-/* Handle meeting "__has_include__" in a preprocessor expression. */
+/* Handle meeting "__has_include" in a preprocessor expression. */
static cpp_num
-parse_has_include (cpp_reader *pfile, enum include_type type)
+parse_has_include (cpp_reader *pfile, cpp_hashnode *op, include_type type)
{
cpp_num result;
@@ -2201,12 +2200,15 @@ parse_has_include (cpp_reader *pfile, enum include_type type)
result.overflow = false;
result.low = 0;
- pfile->state.in__has_include__++;
-
+ pfile->state.angled_headers = true;
const cpp_token *token = cpp_get_token (pfile);
bool paren = token->type == CPP_OPEN_PAREN;
if (paren)
token = cpp_get_token (pfile);
+ else
+ cpp_error (pfile, CPP_DL_ERROR,
+ "missing '(' before \"%s\" operand", NODE_NAME (op));
+ pfile->state.angled_headers = false;
bool bracket = token->type != CPP_STRING;
cpp_hashnode *node = NULL;
@@ -2222,7 +2224,7 @@ parse_has_include (cpp_reader *pfile, enum include_type type)
fname = _cpp_bracket_include (pfile);
else
cpp_error (pfile, CPP_DL_ERROR,
- "operator \"__has_include__\" requires a header string");
+ "operator \"%s\" requires a header-name", NODE_NAME (op));
if (fname)
{
@@ -2237,14 +2239,10 @@ parse_has_include (cpp_reader *pfile, enum include_type type)
if (paren && !SEEN_EOL () && cpp_get_token (pfile)->type != CPP_CLOSE_PAREN)
cpp_error (pfile, CPP_DL_ERROR,
- "missing ')' after \"__has_include__\"");
+ "missing ')' after \"%s\" operand", NODE_NAME (op));
- /* A possible controlling macro of the form #if !__has_include__ ().
- _cpp_parse_expr checks there was no other junk on the line. */
if (node)
pfile->mi_ind_cmacro = node;
- pfile->state.in__has_include__--;
-
return result;
}