[clang] 7fdffde - [clang][bytecode] Add test for variadic inherited constructor calls (#225611)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 23 01:12:02 PDT 2026
Author: Akash Manna
Date: 2026-09-23T10:11:56+02:00
New Revision: 7fdffde1a3a932069d1aeb38c8c949166838476c
URL: https://github.com/llvm/llvm-project/commit/7fdffde1a3a932069d1aeb38c8c949166838476c
DIFF: https://github.com/llvm/llvm-project/commit/7fdffde1a3a932069d1aeb38c8c949166838476c.diff
LOG: [clang][bytecode] Add test for variadic inherited constructor calls (#225611)
Fixes #158529
Calling a variadic constructor through a `using` declaration used to hit
`assert(false && "Can't get arguments from that expression type")` in
`cleanupAfterFunctionCall`. The call site is a
`CXXInheritedCtorInitExpr`, and the cleanup only knew how to count
variadic arguments from a `CallExpr` or `CXXConstructExpr`. A single
level of `using` crashed the same way, the second level in the
reproducer just adds a frame.
This was fixed as a side effect of #207393, which now takes the variadic
size from the frame instead of the call expression. Adding the
reproducer plus a few value checks (single and double level, mixed
vararg types, inside a constexpr function) so it stays fixed.
Added:
Modified:
clang/test/AST/ByteCode/records.cpp
Removed:
################################################################################
diff --git a/clang/test/AST/ByteCode/records.cpp b/clang/test/AST/ByteCode/records.cpp
index 39d2b948ee59f..ee47c8206f4ff 100644
--- a/clang/test/AST/ByteCode/records.cpp
+++ b/clang/test/AST/ByteCode/records.cpp
@@ -1251,6 +1251,41 @@ namespace InheritedConstructor {
constexpr S s(1);
}
+
+ namespace GH158529 {
+ /// Used to assert when popping the variadic arguments of an inherited
+ /// constructor, since the call site is a CXXInheritedCtorInitExpr.
+ struct foo {
+ constexpr foo(int, ...) {}
+ };
+ struct boo : foo {
+ using foo::foo;
+ };
+ struct bar : boo {
+ using boo::boo;
+ };
+ bar u(0, 1);
+
+ struct A {
+ int a;
+ constexpr A(int a, ...) : a(a) {}
+ };
+ struct B : A { using A::A; };
+ struct C : B { using B::B; };
+
+ constexpr B b(1, 2);
+ static_assert(b.a == 1, "");
+ constexpr C c(3, 4, 5);
+ static_assert(c.a == 3, "");
+ constexpr C c2(6, 7.5, 'c', 8L);
+ static_assert(c2.a == 6, "");
+
+ constexpr int f() {
+ C x(9, 10);
+ return x.a;
+ }
+ static_assert(f() == 9, "");
+ }
}
namespace InvalidCtorInitializer {
More information about the cfe-commits
mailing list