Mercurial > hg > CbC > CbC_gcc
diff libcpp/expr.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
line wrap: on
line diff
--- a/libcpp/expr.c Thu Oct 25 07:37:49 2018 +0900 +++ b/libcpp/expr.c Thu Feb 13 11:34:05 2020 +0900 @@ -1,5 +1,5 @@ /* Parse C expressions for cpplib. - Copyright (C) 1987-2018 Free Software Foundation, Inc. + Copyright (C) 1987-2020 Free Software Foundation, Inc. Contributed by Per Bothner, 1994. This program is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ { const cpp_token *token; /* The token forming op (for diagnostics). */ cpp_num value; /* The value logically "right" of op. */ - source_location loc; /* The location of this value. */ + location_t loc; /* The location of this value. */ enum cpp_ttype op; }; @@ -52,20 +52,18 @@ enum cpp_ttype); static cpp_num num_mul (cpp_reader *, cpp_num, cpp_num); static cpp_num num_div_op (cpp_reader *, cpp_num, cpp_num, enum cpp_ttype, - source_location); + location_t); static cpp_num num_lshift (cpp_num, size_t, size_t); static cpp_num num_rshift (cpp_num, size_t, size_t); static cpp_num append_digit (cpp_num, int, int, size_t); static cpp_num parse_defined (cpp_reader *); -static cpp_num eval_token (cpp_reader *, const cpp_token *, source_location); +static cpp_num eval_token (cpp_reader *, const cpp_token *, location_t); static struct op *reduce (cpp_reader *, struct op *, enum cpp_ttype); 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); - /* Token type abuse to create unary plus and minus operators. */ #define CPP_UPLUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 1)) #define CPP_UMINUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 2)) @@ -98,8 +96,8 @@ flags = 0; f = d = l = w = q = i = fn = fnx = fn_bits = 0; - /* The following decimal float suffixes, from TR 24732:2009 and TS - 18661-2:2015, are supported: + /* The following decimal float suffixes, from TR 24732:2009, TS + 18661-2:2015 and C2X, are supported: df, DF - _Decimal32. dd, DD - _Decimal64. @@ -505,7 +503,7 @@ VIRTUAL_LOCATION is the virtual location for TOKEN. */ unsigned int cpp_classify_number (cpp_reader *pfile, const cpp_token *token, - const char **ud_suffix, source_location virtual_location) + const char **ud_suffix, location_t virtual_location) { const uchar *str = token->val.str.text; const uchar *limit; @@ -744,9 +742,16 @@ cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0, "fixed-point constants are a GCC extension"); - if ((result & CPP_N_DFLOAT) && CPP_PEDANTIC (pfile)) - cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0, - "decimal float constants are a GCC extension"); + if (result & CPP_N_DFLOAT) + { + if (CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, dfp_constants)) + cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0, + "decimal float constants are a C2X feature"); + else if (CPP_OPTION (pfile, cpp_warn_c11_c2x_compat) > 0) + cpp_warning_with_line (pfile, CPP_W_C11_C2X_COMPAT, + virtual_location, 0, + "decimal float constants are a C2X feature"); + } result |= CPP_N_FLOATING; } @@ -1075,14 +1080,13 @@ pfile->state.prevent_expansion--; /* Do not treat conditional macros as being defined. This is due to the - powerpc and spu ports using conditional macros for 'vector', 'bool', and - 'pixel' to act as conditional keywords. This messes up tests like #ifndef + powerpc port using conditional macros for 'vector', 'bool', and 'pixel' + to act as conditional keywords. This messes up tests like #ifndef bool. */ 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; } @@ -1091,7 +1095,7 @@ operators). */ static cpp_num eval_token (cpp_reader *pfile, const cpp_token *token, - source_location virtual_location) + location_t virtual_location) { cpp_num result; unsigned int temp; @@ -1153,10 +1157,6 @@ 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 (CPP_OPTION (pfile, cplusplus) && (token->val.node.node == pfile->spec_nodes.n_true || token->val.node.node == pfile->spec_nodes.n_false)) @@ -1288,7 +1288,7 @@ struct op *top = pfile->op_stack; unsigned int lex_count; bool saw_leading_not, want_value = true; - source_location virtual_location = 0; + location_t virtual_location = 0; pfile->state.skip_eval = 0; @@ -2086,7 +2086,7 @@ static cpp_num num_div_op (cpp_reader *pfile, cpp_num lhs, cpp_num rhs, enum cpp_ttype op, - source_location location) + location_t location) { cpp_num result, sub; cpp_num_part mask; @@ -2183,71 +2183,3 @@ return lhs; } -/* Handle meeting "__has_include__" in a preprocessor expression. */ -static cpp_num -parse_has_include (cpp_reader *pfile, enum include_type type) -{ - cpp_num result; - bool paren = false; - cpp_hashnode *node = 0; - const cpp_token *token; - bool bracket = false; - char *fname = 0; - - result.unsignedp = false; - result.high = 0; - result.overflow = false; - result.low = 0; - - pfile->state.in__has_include__++; - - token = cpp_get_token (pfile); - if (token->type == CPP_OPEN_PAREN) - { - paren = true; - token = cpp_get_token (pfile); - } - - if (token->type == CPP_STRING || token->type == CPP_HEADER_NAME) - { - if (token->type == CPP_HEADER_NAME) - bracket = true; - fname = XNEWVEC (char, token->val.str.len - 1); - memcpy (fname, token->val.str.text + 1, token->val.str.len - 2); - fname[token->val.str.len - 2] = '\0'; - node = token->val.node.node; - } - else if (token->type == CPP_LESS) - { - bracket = true; - fname = _cpp_bracket_include (pfile); - } - else - cpp_error (pfile, CPP_DL_ERROR, - "operator \"__has_include__\" requires a header string"); - - if (fname) - { - int angle_brackets = (bracket ? 1 : 0); - - if (_cpp_has_header (pfile, fname, angle_brackets, type)) - result.low = 1; - else - result.low = 0; - - XDELETEVEC (fname); - } - - if (paren && cpp_get_token (pfile)->type != CPP_CLOSE_PAREN) - cpp_error (pfile, CPP_DL_ERROR, - "missing ')' after \"__has_include__\""); - - /* 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; -}