[clang] 637ce0f - [C2x] Claim support for WG14 N2838

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 3 08:57:30 PST 2023


Author: Aaron Ballman
Date: 2023-03-03T11:57:21-05:00
New Revision: 637ce0f7139015735d7e50cf12ad312a382f6283

URL: https://github.com/llvm/llvm-project/commit/637ce0f7139015735d7e50cf12ad312a382f6283
DIFF: https://github.com/llvm/llvm-project/commit/637ce0f7139015735d7e50cf12ad312a382f6283.diff

LOG: [C2x] Claim support for WG14 N2838

This paper clarifies that complete object types need to be smaller than
SIZE_MAX. We already conformed to that requirement, so this adds some
test coverage to prove it.

Added: 
    clang/test/C/C2x/n2838.c

Modified: 
    clang/www/c_status.html

Removed: 
    


################################################################################
diff  --git a/clang/test/C/C2x/n2838.c b/clang/test/C/C2x/n2838.c
new file mode 100644
index 0000000000000..f110fef9d0f41
--- /dev/null
+++ b/clang/test/C/C2x/n2838.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -verify -std=c2x %s
+
+/* WG14 N2838: yes
+ * Types and sizes
+ */
+
+char buffer4[0xFFFF'FFFF'FFFF'FFFF'1wb]; /* expected-error {{array is too large (295147905179352825841 elements)}} */
+char buffer3[0xFFFF'FFFF'FFFF'FFFFwb];   /* expected-error {{array is too large (18446744073709551615 elements)}} */
+char buffer2[0x7FFF'FFFF'FFFF'FFFFwb];   /* expected-error {{array is too large (9223372036854775807 elements)}} */
+char buffer1[0x1FFF'FFFF'FFFF'FFFFwb];   /* array is juuuuuust right */
+
+/* The largest object we can create is still smaller than SIZE_MAX. */
+static_assert(0x1FFF'FFFF'FFFF'FFFFwb <= __SIZE_MAX__);

diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
index dcc02e8b05145..20eec37fce3de 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -972,7 +972,7 @@ <h2 id="c2x">C2x implementation status</h2>
     <tr>
       <td>Types and sizes</td>
       <td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2838.htm">N2838</a></td>
-      <td class="unknown" align="center">Unknown</td>
+      <td class="full" align="center">Yes</td>
     </tr>
     <tr>
       <td>Clarifying integer terms</td>


        


More information about the cfe-commits mailing list