[C2y] Claim nonconformance to WG14 N3348#166966
Merged
AaronBallman merged 1 commit intollvm:mainfrom Nov 10, 2025
Merged
Conversation
This paper allows use of * in a multidimensional array extent within a _Generic selection association, as a wildcard for any array extent. Clang does not currently support this feature, so this is just some initial test coverage along with an update to the conformance site.
Member
|
@llvm/pr-subscribers-clang Author: Aaron Ballman (AaronBallman) ChangesThis paper allows use of * in a multidimensional array extent within a _Generic selection association, as a wildcard for any array extent. Clang does not currently support this feature, so this is just some initial test coverage along with an update to the conformance site. Full diff: https://github.com/llvm/llvm-project/pull/166966.diff 2 Files Affected:
diff --git a/clang/test/C/C2y/n3348.c b/clang/test/C/C2y/n3348.c
new file mode 100644
index 0000000000000..e20c9f74883f9
--- /dev/null
+++ b/clang/test/C/C2y/n3348.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -verify -std=c2y -Wall -pedantic %s
+
+/* WG14 N3348: No
+ * Matching of Multi-Dimensional Arrays in Generic Selection Expressions
+ *
+ * This allows use of * in a _Generic association as a placeholder for any size
+ * value.
+ *
+ * FIXME: Clang doesn't yet implement this paper. When we do implement it, we
+ * should expose the functionality in earlier language modes (C89) for
+ * compatibility with GCC.
+ */
+
+void test(int n, int m) {
+ static_assert(1 == _Generic(int[3][2], int[3][*]: 1, int[2][*]: 0)); /* expected-error {{star modifier used outside of function prototype}}
+ expected-error {{array has incomplete element type 'int[]'}}
+ */
+ static_assert(1 == _Generic(int[3][2], int[*][2]: 1, int[*][3]: 0)); // expected-error {{star modifier used outside of function prototype}}
+ static_assert(1 == _Generic(int[3][n], int[3][*]: 1, int[2][*]: 0)); /* expected-error {{star modifier used outside of function prototype}}
+ expected-error {{array has incomplete element type 'int[]'}}
+ */
+ static_assert(1 == _Generic(int[n][m], int[*][*]: 1, char[*][*]: 0)); /* expected-error 2 {{star modifier used outside of function prototype}}
+ expected-error {{array has incomplete element type 'int[]'}}
+ */
+ static_assert(1 == _Generic(int(*)[2], int(*)[*]: 1)); // expected-error {{star modifier used outside of function prototype}}
+}
+
+void questionable() {
+ // GCC accepts this despite the * appearing outside of a generic association,
+ // but it's not clear whether that's intentionally supported or an oversight.
+ // It gives a warning about * being used outside of a declaration, but not
+ // with an associated warning group.
+ static_assert(1 == _Generic(int[*][*], int[2][100]: 1)); /* expected-error 2 {{star modifier used outside of function prototype}}
+ expected-error {{array has incomplete element type 'int[]'}}
+ */
+ // GCC claims this matches multiple associations, so the functionality seems
+ // like it may be intended to work?
+ (void)_Generic(int[*][*], /* expected-error 2 {{star modifier used outside of function prototype}}
+ expected-error {{array has incomplete element type 'int[]'}}
+ */
+ int[2][100]: 1,
+ int[3][1000]: 2,
+ );
+}
diff --git a/clang/www/c_status.html b/clang/www/c_status.html
index 2c1f6f4140a91..ccf19ea86957a 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -324,7 +324,7 @@ <h2 id="c2y">C2y implementation status</h2>
<tr>
<td>Matching of Multi-Dimensional Arrays in Generic Selection Expressions</td>
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3348.pdf">N3348</a></td>
- <td class="unknown" align="center">Unknown</td>
+ <td class="none" align="center">No</td>
</tr>
<tr>
<td>The __COUNTER__ predefined macro</td>
|
ckoparkar
added a commit
to ckoparkar/llvm-project
that referenced
this pull request
Nov 10, 2025
* main: (1028 commits) [clang][DebugInfo] Attach `DISubprogram` to additional call variants (llvm#166202) [C2y] Claim nonconformance to WG14 N3348 (llvm#166966) [X86] 2012-01-10-UndefExceptionEdge.ll - regenerate test checks (llvm#167307) Remove unused standard headers: <string>, <optional>, <numeric>, <tuple> (llvm#167232) [DebugInfo] Add Verifier check for incorrectly-scoped retainedNodes (llvm#166855) [VPlan] Don't apply predication discount to non-originally-predicated blocks (llvm#160449) [libc++] Avoid overloaded `operator,` for (`T`, `Iter`) cases (llvm#161049) [tools][llc] Make save-stats.ll test target independent (llvm#167238) [AArch64] Fallback to PRFUM for PRFM with negative or unaligned offset (llvm#166756) [X86] ldexp-avx512.ll - add v8f16/v16f16/v32f16 test coverage for llvm#165694 (llvm#167294) [DropAssumes] Drop dereferenceable assumptions after vectorization. (llvm#166947) [VPlan] Simplify branch-cond with getVectorTripCount (llvm#155604) Remove unused <algorithm> inclusion (llvm#166942) [AArch64] Combine subtract with borrow to SBC. (llvm#165271) [AArch64][SVE] Avoid redundant extend of unsigned i8/i16 extracts. (llvm#165863) [SPIRV] Fix failing assertion in SPIRVAsmPrinter (llvm#166909) [libc++] Merge insert/emplace(const_iterator, Args...) implementations (llvm#166470) [libc++] Replace __libcpp_is_final with a variable template (llvm#167137) [gn build] Port 152bda7 [libc++] Replace the last uses of __tuple_types with __type_list (llvm#167214) ...
ronlieb
added a commit
to ROCm/llvm-project
that referenced
this pull request
Dec 18, 2025
This reverts commit 309729e.
ronlieb
added a commit
to ROCm/llvm-project
that referenced
this pull request
Dec 19, 2025
This reverts commit 309729e.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This paper allows use of * in a multidimensional array extent within a _Generic selection association, as a wildcard for any array extent.
Clang does not currently support this feature, so this is just some initial test coverage along with an update to the conformance site.