[clang] [clang][test] Make new absurdly_big_struct test more targeted (PR #219897)

via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 31 00:12:14 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

The previous version of `y()` used `c2[i]`, which can't be evaluated at compile-time.
The emitted diagnostic depends on something calling `ASTContext::getASTRecordLayout()` for `b`, which currently happens in the constant evaluator. If the evaluator decides to evaluate `c2[i]` before calling `getASTRecordLayout()`, the test fails since the diagnostic is never emitted.

Fix this by simply using `c2[0]` instead.

---
Full diff: https://github.com/llvm/llvm-project/pull/219897.diff


1 Files Affected:

- (modified) clang/test/AST/absurdly_big_struct.cpp (+1-1) 


``````````diff
diff --git a/clang/test/AST/absurdly_big_struct.cpp b/clang/test/AST/absurdly_big_struct.cpp
index 69e191aaf70fa..de44de2754727 100644
--- a/clang/test/AST/absurdly_big_struct.cpp
+++ b/clang/test/AST/absurdly_big_struct.cpp
@@ -20,5 +20,5 @@ struct b { // bit32-error {{structure 'b' is too large, which exceeds maximum al
   char c2[2];
 };
 
-long long y(int i) { return __builtin_offsetof(b, c2[i]); }
+long long y() { return __builtin_offsetof(b, c2[0]); }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/219897


More information about the cfe-commits mailing list