aboutsummaryrefslogtreecommitdiff
path: root/libcpp/expr.c
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2021-09-13 19:49:49 +0200
committerThomas Koenig <tkoenig@gcc.gnu.org>2021-09-13 19:49:49 +0200
commitb18a97e5dd0935e1c4a626c230f21457d0aad3d5 (patch)
treec1818f41af6fe780deafb6cd6a183f32085fe654 /libcpp/expr.c
parente76a53644c9d70e998c0d050e9a456af388c6b61 (diff)
downloadgcc-b18a97e5dd0935e1c4a626c230f21457d0aad3d5.zip
gcc-b18a97e5dd0935e1c4a626c230f21457d0aad3d5.tar.gz
gcc-b18a97e5dd0935e1c4a626c230f21457d0aad3d5.tar.bz2
Merged current trunk to branch.
Diffstat (limited to 'libcpp/expr.c')
-rw-r--r--libcpp/expr.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/libcpp/expr.c b/libcpp/expr.c
index 2ba7726..ab4a260 100644
--- a/libcpp/expr.c
+++ b/libcpp/expr.c
@@ -1,5 +1,5 @@
/* Parse C expressions for cpplib.
- Copyright (C) 1987-2020 Free Software Foundation, Inc.
+ Copyright (C) 1987-2021 Free Software Foundation, Inc.
Contributed by Per Bothner, 1994.
This program is free software; you can redistribute it and/or modify it
@@ -313,13 +313,14 @@ static unsigned int
interpret_int_suffix (cpp_reader *pfile, const uchar *s, size_t len)
{
size_t orig_len = len;
- size_t u, l, i;
+ size_t u, l, i, z;
- u = l = i = 0;
+ u = l = i = z = 0;
while (len--)
switch (s[len])
{
+ case 'z': case 'Z': z++; break;
case 'u': case 'U': u++; break;
case 'i': case 'I':
case 'j': case 'J': i++; break;
@@ -332,9 +333,17 @@ interpret_int_suffix (cpp_reader *pfile, const uchar *s, size_t len)
return 0;
}
- if (l > 2 || u > 1 || i > 1)
+ if (l > 2 || u > 1 || i > 1 || z > 1)
return 0;
+ if (z)
+ {
+ if (l > 0 || i > 0)
+ return 0;
+ if (!CPP_OPTION (pfile, cplusplus))
+ return 0;
+ }
+
if (i)
{
if (!CPP_OPTION (pfile, ext_numeric_literals))
@@ -352,7 +361,8 @@ interpret_int_suffix (cpp_reader *pfile, const uchar *s, size_t len)
return ((i ? CPP_N_IMAGINARY : 0)
| (u ? CPP_N_UNSIGNED : 0)
| ((l == 0) ? CPP_N_SMALL
- : (l == 1) ? CPP_N_MEDIUM : CPP_N_LARGE));
+ : (l == 1) ? CPP_N_MEDIUM : CPP_N_LARGE)
+ | (z ? CPP_N_SIZE_T : 0));
}
/* Return the classification flags for an int suffix. */
@@ -572,11 +582,7 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
max_digit = c;
}
else if (DIGIT_SEP (c))
- {
- if (seen_digit_sep)
- SYNTAX_ERROR_AT (virtual_location, "adjacent digit separators");
- seen_digit_sep = true;
- }
+ seen_digit_sep = true;
else if (c == '.')
{
if (seen_digit_sep || DIGIT_SEP (*str))
@@ -805,6 +811,16 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
virtual_location, 0, message);
}
+ if ((result & CPP_N_SIZE_T) == CPP_N_SIZE_T
+ && !CPP_OPTION (pfile, size_t_literals))
+ {
+ const char *message = (result & CPP_N_UNSIGNED) == CPP_N_UNSIGNED
+ ? N_("use of C++23 %<size_t%> integer constant")
+ : N_("use of C++23 %<make_signed_t<size_t>%> integer constant");
+ cpp_warning_with_line (pfile, CPP_W_SIZE_T_LITERALS,
+ virtual_location, 0, message);
+ }
+
result |= CPP_N_INTEGER;
}