llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Akash Manna (akash-manna-sky)

<details>
<summary>Changes</summary>

Fixes #<!-- -->158529

Calling a variadic constructor through a `using` declaration used to hit 
`assert(false &amp;&amp; "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.

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


1 Files Affected:

- (modified) clang/test/AST/ByteCode/records.cpp (+35) 


``````````diff
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 {

``````````

</details>


https://github.com/llvm/llvm-project/pull/225611
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to