On 2/1/21 9:15 PM, Ed Smith-Rowland wrote:
On 2/1/21 2:23 PM, Jakub Jelinek wrote:
On Mon, Feb 01, 2021 at 01:46:13PM -0500, Ed Smith-Rowland wrote:
@@ -0,0 +1,8 @@
+// { dg-do compile { target c++23 } }
+
+#include <cstddef>
+#include <type_traits>
+
+static_assert(std::is_same_v<decltype(123zu), std::size_t>);
+static_assert(std::is_same_v<decltype(456z), std::ptrdiff_t>);
Shouldn't this be std::make_signed<std::size_t>::type instead of
std::ptrdiff_t
Yes it should. The paper goes on about ptrdiff_t but at the very end
they punt on that in favor of what you have.
+std::ptrdiff_t pd1 = 1234z; // { dg-warning "use of C\+\+23
ptrdiff_t integer constant" "" { target c++20_down } }
+std::ptrdiff_t PD1 = 5678Z; // { dg-warning "use of C\+\+23
ptrdiff_t integer constant" "" { target c++20_down } }
Ditto here.
Agree.
+ const char *message = (result & CPP_N_UNSIGNED) == CPP_N_UNSIGNED
+ ? N_("use of C++23 size_t integer constant")
+ : N_("use of C++23 ptrdiff_t integer constant");
And here too (perhaps %<make_signed<size_t>::type%> )?
And maybe %<size_t%> too.
Agree.
--- 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 ptrdiff_t and size_t literals. */
And drop "ptrdiff_t and " here?
+#define CPP_N_SIZE_T 0x2000000 /* C++23 size_t or ptrdiff_t
literal */
And " or ptrdiff_t" here?
While ptrdiff_t will usually be the same type, seems there is e.g.:
config/darwin.h:#define SIZE_TYPE "long unsigned int"
config/darwin.h:#define PTRDIFF_TYPE "int"
config/i386/djgpp.h:#define SIZE_TYPE "long unsigned int"
config/i386/djgpp.h:#define PTRDIFF_TYPE "int"
config/m32c/m32c.h:#define PTRDIFF_TYPE (TARGET_A16 ? "int" : "long int")
config/m32c/m32c.h:#define SIZE_TYPE "unsigned int"
config/rs6000/rs6000.h:#define PTRDIFF_TYPE "int"
config/rs6000/rs6000.h:#define SIZE_TYPE "long unsigned int"
config/s390/linux.h:#define SIZE_TYPE "long unsigned int"
config/s390/linux.h:#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" :
"int")
config/visium/visium.h:#define SIZE_TYPE "unsigned int"
config/visium/visium.h:#define PTRDIFF_TYPE "long int"
config/vms/vms.h:#define SIZE_TYPE "unsigned int"
config/vms/vms.h:#define PTRDIFF_TYPE (flag_vms_pointer_size ==
VMS_POINTER_SIZE_NONE ? \
config/vms/vms.h- "int" : "long long int")
so quite a few differences.
Jakub
Here is my last patch with all the concerns addressed.
I am not smart enough to get the dg-warning regex in Wsize_t-literals.C
to work. If someone could carry this over the finish line that would be
great. Or give me pointers. I can't any more.
Your regex will work fine if you wrap it in {} instead of "", e.g.
{ dg-warning {use of C\+\+23 .size_t. integer constant} }
Jason