Mercurial > hg > CbC > CbC_gcc
comparison libcpp/expr.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* Parse C expressions for cpplib. | 1 /* Parse C expressions for cpplib. |
2 Copyright (C) 1987-2017 Free Software Foundation, Inc. | 2 Copyright (C) 1987-2018 Free Software Foundation, Inc. |
3 Contributed by Per Bothner, 1994. | 3 Contributed by Per Bothner, 1994. |
4 | 4 |
5 This program is free software; you can redistribute it and/or modify it | 5 This program is free software; you can redistribute it and/or modify it |
6 under the terms of the GNU General Public License as published by the | 6 under the terms of the GNU General Public License as published by the |
7 Free Software Foundation; either version 3, or (at your option) any | 7 Free Software Foundation; either version 3, or (at your option) any |
88 length LEN, possibly zero. Returns 0 for an invalid suffix, or a | 88 length LEN, possibly zero. Returns 0 for an invalid suffix, or a |
89 flag vector (of CPP_N_* bits) describing the suffix. */ | 89 flag vector (of CPP_N_* bits) describing the suffix. */ |
90 static unsigned int | 90 static unsigned int |
91 interpret_float_suffix (cpp_reader *pfile, const uchar *s, size_t len) | 91 interpret_float_suffix (cpp_reader *pfile, const uchar *s, size_t len) |
92 { | 92 { |
93 size_t orig_len = len; | |
94 const uchar *orig_s = s; | |
93 size_t flags; | 95 size_t flags; |
94 size_t f, d, l, w, q, i, fn, fnx, fn_bits; | 96 size_t f, d, l, w, q, i, fn, fnx, fn_bits; |
95 | 97 |
96 flags = 0; | 98 flags = 0; |
97 f = d = l = w = q = i = fn = fnx = fn_bits = 0; | 99 f = d = l = w = q = i = fn = fnx = fn_bits = 0; |
267 if (fn && fn_bits != 16 && fn_bits % 32 != 0) | 269 if (fn && fn_bits != 16 && fn_bits % 32 != 0) |
268 return 0; | 270 return 0; |
269 if (fn && fn_bits == 96) | 271 if (fn && fn_bits == 96) |
270 return 0; | 272 return 0; |
271 | 273 |
272 if (i && !CPP_OPTION (pfile, ext_numeric_literals)) | 274 if (i) |
273 return 0; | 275 { |
276 if (!CPP_OPTION (pfile, ext_numeric_literals)) | |
277 return 0; | |
278 | |
279 /* In C++14 and up these suffixes are in the standard library, so treat | |
280 them as user-defined literals. */ | |
281 if (CPP_OPTION (pfile, cplusplus) | |
282 && CPP_OPTION (pfile, lang) > CLK_CXX11 | |
283 && orig_s[0] == 'i' | |
284 && (orig_len == 1 | |
285 || (orig_len == 2 | |
286 && (orig_s[1] == 'f' || orig_s[1] == 'l')))) | |
287 return 0; | |
288 } | |
274 | 289 |
275 if ((w || q) && !CPP_OPTION (pfile, ext_numeric_literals)) | 290 if ((w || q) && !CPP_OPTION (pfile, ext_numeric_literals)) |
276 return 0; | 291 return 0; |
277 | 292 |
278 return ((i ? CPP_N_IMAGINARY : 0) | 293 return ((i ? CPP_N_IMAGINARY : 0) |
297 of length LEN, possibly zero. Returns 0 for an invalid suffix, or a | 312 of length LEN, possibly zero. Returns 0 for an invalid suffix, or a |
298 flag vector describing the suffix. */ | 313 flag vector describing the suffix. */ |
299 static unsigned int | 314 static unsigned int |
300 interpret_int_suffix (cpp_reader *pfile, const uchar *s, size_t len) | 315 interpret_int_suffix (cpp_reader *pfile, const uchar *s, size_t len) |
301 { | 316 { |
317 size_t orig_len = len; | |
302 size_t u, l, i; | 318 size_t u, l, i; |
303 | 319 |
304 u = l = i = 0; | 320 u = l = i = 0; |
305 | 321 |
306 while (len--) | 322 while (len--) |
319 } | 335 } |
320 | 336 |
321 if (l > 2 || u > 1 || i > 1) | 337 if (l > 2 || u > 1 || i > 1) |
322 return 0; | 338 return 0; |
323 | 339 |
324 if (i && !CPP_OPTION (pfile, ext_numeric_literals)) | 340 if (i) |
325 return 0; | 341 { |
342 if (!CPP_OPTION (pfile, ext_numeric_literals)) | |
343 return 0; | |
344 | |
345 /* In C++14 and up these suffixes are in the standard library, so treat | |
346 them as user-defined literals. */ | |
347 if (CPP_OPTION (pfile, cplusplus) | |
348 && CPP_OPTION (pfile, lang) > CLK_CXX11 | |
349 && s[0] == 'i' | |
350 && (orig_len == 1 || (orig_len == 2 && s[1] == 'l'))) | |
351 return 0; | |
352 } | |
326 | 353 |
327 return ((i ? CPP_N_IMAGINARY : 0) | 354 return ((i ? CPP_N_IMAGINARY : 0) |
328 | (u ? CPP_N_UNSIGNED : 0) | 355 | (u ? CPP_N_UNSIGNED : 0) |
329 | ((l == 0) ? CPP_N_SMALL | 356 | ((l == 0) ? CPP_N_SMALL |
330 : (l == 1) ? CPP_N_MEDIUM : CPP_N_LARGE)); | 357 : (l == 1) ? CPP_N_MEDIUM : CPP_N_LARGE)); |
1036 && CPP_OPTION (pfile, warn_expansion_to_defined)) | 1063 && CPP_OPTION (pfile, warn_expansion_to_defined)) |
1037 cpp_pedwarning (pfile, CPP_W_EXPANSION_TO_DEFINED, | 1064 cpp_pedwarning (pfile, CPP_W_EXPANSION_TO_DEFINED, |
1038 "this use of \"defined\" may not be portable"); | 1065 "this use of \"defined\" may not be portable"); |
1039 | 1066 |
1040 _cpp_mark_macro_used (node); | 1067 _cpp_mark_macro_used (node); |
1041 if (!(node->flags & NODE_USED)) | 1068 _cpp_maybe_notify_macro_use (pfile, node); |
1042 { | |
1043 node->flags |= NODE_USED; | |
1044 if (node->type == NT_MACRO) | |
1045 { | |
1046 if ((node->flags & NODE_BUILTIN) | |
1047 && pfile->cb.user_builtin_macro) | |
1048 pfile->cb.user_builtin_macro (pfile, node); | |
1049 if (pfile->cb.used_define) | |
1050 pfile->cb.used_define (pfile, pfile->directive_line, node); | |
1051 } | |
1052 else | |
1053 { | |
1054 if (pfile->cb.used_undef) | |
1055 pfile->cb.used_undef (pfile, pfile->directive_line, node); | |
1056 } | |
1057 } | |
1058 | 1069 |
1059 /* A possible controlling macro of the form #if !defined (). | 1070 /* A possible controlling macro of the form #if !defined (). |
1060 _cpp_parse_expr checks there was no other junk on the line. */ | 1071 _cpp_parse_expr checks there was no other junk on the line. */ |
1061 pfile->mi_ind_cmacro = node; | 1072 pfile->mi_ind_cmacro = node; |
1062 } | 1073 } |
1068 'pixel' to act as conditional keywords. This messes up tests like #ifndef | 1079 'pixel' to act as conditional keywords. This messes up tests like #ifndef |
1069 bool. */ | 1080 bool. */ |
1070 result.unsignedp = false; | 1081 result.unsignedp = false; |
1071 result.high = 0; | 1082 result.high = 0; |
1072 result.overflow = false; | 1083 result.overflow = false; |
1073 result.low = (node && node->type == NT_MACRO | 1084 result.low = (node && cpp_macro_p (node) |
1074 && (node->flags & NODE_CONDITIONAL) == 0); | 1085 && !(node->flags & NODE_CONDITIONAL)); |
1075 return result; | 1086 return result; |
1076 } | 1087 } |
1077 | 1088 |
1078 /* Convert a token into a CPP_NUMBER (an interpreted preprocessing | 1089 /* Convert a token into a CPP_NUMBER (an interpreted preprocessing |
1079 number or character constant, or the result of the "defined" or "#" | 1090 number or character constant, or the result of the "defined" or "#" |