diff options
Diffstat (limited to 'libcpp/expr.c')
-rw-r--r-- | libcpp/expr.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libcpp/expr.c b/libcpp/expr.c index c24b640ba16..529709c8560 100644 --- a/libcpp/expr.c +++ b/libcpp/expr.c @@ -65,6 +65,7 @@ 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_attribute (cpp_reader *); /* Token type abuse to create unary plus and minus operators. */ #define CPP_UPLUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 1)) @@ -1054,6 +1055,8 @@ eval_token (cpp_reader *pfile, const cpp_token *token, 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_attribute__) + return parse_has_attribute (pfile); else if (CPP_OPTION (pfile, cplusplus) && (token->val.node.node == pfile->spec_nodes.n_true || token->val.node.node == pfile->spec_nodes.n_false)) @@ -2147,3 +2150,21 @@ parse_has_include (cpp_reader *pfile, enum include_type type) return result; } + +/* Handle meeting "__has_attribute__" in a preprocessor expression. */ +static cpp_num +parse_has_attribute (cpp_reader *pfile) +{ + pfile->state.in__has_attribute__++; + + cpp_num result; + result.unsignedp = false; + result.high = 0; + result.overflow = false; + + result.low = pfile->cb.has_attribute (pfile); + + pfile->state.in__has_attribute__--; + + return result; +} |