From 1f69e63cfcc664fd7382dd877846007652a01dcf Mon Sep 17 00:00:00 2001 From: Ed Smith-Rowland <3dw4rd@verizon.net> Date: Tue, 2 Feb 2021 16:11:57 -0500 Subject: c++: Implement C++23 P0330 - Literal Suffixes for ptrdiff_t and size_t. Integer literal suffixes for signed size ('z') and unsigned size (some permutation od 'zu') are provided as a language addition. gcc/c-family/ChangeLog: * c-cppbuiltin.c (c_cpp_builtins): Define __cpp_size_t_suffix. * c-lex.c (interpret_integer): Set node type for size literal. libcpp/ChangeLog: * expr.c (interpret_int_suffix): Detect 'z' integer suffix. (cpp_classify_number): Compat warning for use of 'z' suffix. * include/cpplib.h (struct cpp_options): New flag. (enum cpp_warning_reason): New flag. (CPP_N_USERDEF): Comment C++0x -> C++11. (CPP_N_SIZE_T): New flag for cpp_classify_number. * init.c (cpp_set_lang): Initialize new flag. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/udlit-shadow-neg.C: Test for 'z' and 'zu' shadowing. * g++.dg/cpp23/feat-cxx2b.C: New test. * g++.dg/cpp23/size_t-literals.C: New test. * g++.dg/warn/Wsize_t-literals.C: New test. --- libcpp/include/cpplib.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libcpp/include') diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index 4467c73..17feb64 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -500,6 +500,9 @@ struct cpp_options /* Nonzero means tokenize C++20 module directives. */ unsigned char module_directives; + /* Nonzero for C++23 size_t literals. */ + unsigned char size_t_literals; + /* Holds the name of the target (execution) character set. */ const char *narrow_charset; @@ -626,6 +629,7 @@ enum cpp_warning_reason { CPP_W_INVALID_PCH, CPP_W_WARNING_DIRECTIVE, CPP_W_LITERAL_SUFFIX, + CPP_W_SIZE_T_LITERALS, CPP_W_DATE_TIME, CPP_W_PEDANTIC, CPP_W_C90_C99_COMPAT, @@ -1211,7 +1215,9 @@ struct cpp_num #define CPP_N_FLOATN 0x400000 /* _FloatN types. */ #define CPP_N_FLOATNX 0x800000 /* _FloatNx types. */ -#define CPP_N_USERDEF 0x1000000 /* C++0x user-defined literal. */ +#define CPP_N_USERDEF 0x1000000 /* C++11 user-defined literal. */ + +#define CPP_N_SIZE_T 0x2000000 /* C++23 size_t literal. */ #define CPP_N_WIDTH_FLOATN_NX 0xF0000000 /* _FloatN / _FloatNx value of N, divided by 16. */ -- cgit v1.1