[clang] [C23][Clang] Claim conformance to WG14 Issue 1016 (PR #246117)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 25 10:50:23 PST 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Aaron Ballman (AaronBallman)
<details>
<summary>Changes</summary>
The crux of the issue is ensuring that `__LINE__` cannot expand to include digit separators. Verifying this with a regression test is challenging, but this uses a large line number as a proxy on the assumption that if we were to accidentally introduce digit separators, they would most likely appear on a huge value if anywhere.
---
Full diff: https://github.com/llvm/llvm-project/pull/246117.diff
2 Files Affected:
- (added) clang/test/C/drs/dr1016.c (+25)
- (modified) clang/www/c_dr_status.html (+1-1)
``````````diff
diff --git a/clang/test/C/drs/dr1016.c b/clang/test/C/drs/dr1016.c
new file mode 100644
index 00000000000000..763b2dd89dd81f
--- /dev/null
+++ b/clang/test/C/drs/dr1016.c
@@ -0,0 +1,25 @@
+/* RUN: %clang_cc1 -std=c89 -fsyntax-only -verify=c89only -pedantic %s
+ RUN: %clang_cc1 -std=c99 -fsyntax-only -verify -pedantic %s
+ RUN: %clang_cc1 -std=c11 -fsyntax-only -verify -pedantic %s
+ RUN: %clang_cc1 -std=c17 -fsyntax-only -verify -pedantic %s
+ RUN: %clang_cc1 -std=c23 -fsyntax-only -verify -pedantic %s
+ RUN: %clang_cc1 -std=c2y -fsyntax-only -verify -pedantic %s
+ */
+
+/* expected-no-diagnostics */
+
+/* WG14 DR1016: yes
+ * Are digit separators allowed in __LINE__?
+ *
+ * We cannot exhaustively test that digit separators do not appear in __LINE__,
+ * but if any line number were to have digit separators, it would be one of the
+ * largest line numbers we support. So we'll test that it does not produce any
+ * digit separators and call it good. If a digit separator is produced by the
+ * expansion, then the variable declaration would be invalid because it would
+ * contain single-quote characters.
+ */
+#define UNIQ_(X, Y) X ## Y
+#define UNIQ(X) UNIQ_(X, __LINE__)
+#line 2147483646 /* c89only-warning {{C requires #line number to be less than 32768, allowed as extension}} */
+int UNIQ(special) = 0; /* okay */
+
diff --git a/clang/www/c_dr_status.html b/clang/www/c_dr_status.html
index e1a3874f8463b7..288da280ea7917 100644
--- a/clang/www/c_dr_status.html
+++ b/clang/www/c_dr_status.html
@@ -3193,7 +3193,7 @@ <h2 id="cdr">C defect report implementation status</h2>
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/issues/c23/issue1016.html">1016</a></td>
<td>C2y</td>
<td>Are digit separators allowed in __LINE__?</td>
- <td class="unknown" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="1017" class="open">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/issues/c23/issue1017.html">1017</a></td>
``````````
</details>
https://github.com/llvm/llvm-project/pull/246117
More information about the cfe-commits
mailing list