[clang] 7d0656d - [C2y] Add test coverage for WG14 N3192
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 2 04:26:22 PDT 2024
Author: Aaron Ballman
Date: 2024-07-02T07:26:02-04:00
New Revision: 7d0656d734bdc19f2478b394b15378a637cc43ee
URL: https://github.com/llvm/llvm-project/commit/7d0656d734bdc19f2478b394b15378a637cc43ee
DIFF: https://github.com/llvm/llvm-project/commit/7d0656d734bdc19f2478b394b15378a637cc43ee.diff
LOG: [C2y] Add test coverage for WG14 N3192
Clang has always supported sequential hexdigits.
Added:
clang/test/C/C2y/n3192.c
Modified:
Removed:
################################################################################
diff --git a/clang/test/C/C2y/n3192.c b/clang/test/C/C2y/n3192.c
new file mode 100644
index 0000000000000..b6f61d5a883dd
--- /dev/null
+++ b/clang/test/C/C2y/n3192.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -verify -Wno-c23-extensions %s
+
+/* WG14 N3192: Yes
+ * Sequential hexdigits
+ */
+
+// expected-no-diagnostics
+
+// Demonstrate that hex digits are already sequential in all targets Clang
+// supports.
+
+#define TEST_VAL(ch) ((ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f'))
+#define GET_VAL(ch) (((ch >= 'A' && ch <= 'F') ? (ch - 'A') : (ch - 'a')) + 10)
+
+_Static_assert(TEST_VAL('A'));
+_Static_assert(TEST_VAL('B'));
+_Static_assert(TEST_VAL('C'));
+_Static_assert(TEST_VAL('D'));
+_Static_assert(TEST_VAL('E'));
+_Static_assert(TEST_VAL('F'));
+_Static_assert(TEST_VAL('a'));
+_Static_assert(TEST_VAL('b'));
+_Static_assert(TEST_VAL('c'));
+_Static_assert(TEST_VAL('d'));
+_Static_assert(TEST_VAL('e'));
+_Static_assert(TEST_VAL('f'));
+
+_Static_assert(!TEST_VAL('G'));
+_Static_assert(!TEST_VAL('h'));
+
+_Static_assert(GET_VAL('A') == 0xA);
+_Static_assert(GET_VAL('B') == 0xB);
+_Static_assert(GET_VAL('C') == 0xC);
+_Static_assert(GET_VAL('D') == 0xD);
+_Static_assert(GET_VAL('E') == 0xE);
+_Static_assert(GET_VAL('F') == 0xF);
+_Static_assert(GET_VAL('a') == 0xA);
+_Static_assert(GET_VAL('b') == 0xB);
+_Static_assert(GET_VAL('c') == 0xC);
+_Static_assert(GET_VAL('d') == 0xD);
+_Static_assert(GET_VAL('e') == 0xE);
+_Static_assert(GET_VAL('f') == 0xF);
+
More information about the cfe-commits
mailing list