[clang] [clang] Add tests for some of CWG issues resolved in Croydon (2026-03) (PR #189299)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon May 4 07:21:33 PDT 2026
================
@@ -21,3 +21,14 @@ void f(
}
} // namespace cwg3005
+
+namespace cwg3035 { // cwg3035: no
+#if __cplusplus >= 201103L
+static union {
+ int x = [] { return 42; }();
+ // FIXME-error at -1 {{lambda expressions are not allowed in anonymous unions}}
+};
+#endif
+} // namespace cwg3035
----------------
AaronBallman wrote:
I can see the argument either way. We need the test coverage, so it has to live somewhere, and the question is: do we simplify the test by removing the `#if` and that gets us the coverage we need, or do we duplicate some of the test in another file in `SemaCXX` to get us the coverage? Vlad is suggesting we add another file, Corentin is suggesting we use the existing DR test, both are pretty reasonable suggestions.
Personally, I would not want to see DR tests for Clang extensions which are not standardized in other language modes. e.g., I would not want to see tests for vector data types in DR tests because vector data types are non-standard. But when the feature is standardized and we're backporting it to an older language mode, like here with lambdas, I think it maybe does make more sense to test DR behavior of those extensions as part of the DR tests instead of splitting into multiple places. Basically, we're saying lambdas are a C++feature and we support that feature in all C++ language modes, so the DR applies 'as far back as makes sense' which for us includes C++98.
https://github.com/llvm/llvm-project/pull/189299
More information about the cfe-commits
mailing list