This fixes https://github.com/llvm/llvm-project/issues/64347. The CTAD for an aggregate class is missing to handle the explicit type conversion case, e.g. `TemplateFooClass(1, 2);`. Per C++ expr.type.conv p1, the deduced type is the return type of the deduction guide selected by the CTAD for the reminder. In the deduction implementation `DeduceTemplateSpecializationFromInitializer`, the parenthesized express-list case relies on the `ParenListExpr` parameter (default is nullptr), the AST `ParenListExpr` node is not built for all variant initializer cases (`BuildCXXTypeConstructorExpr`, `BuildCXXNew` etc), thus the deduction doesn't perform for these cases. This patch fixes it by removing the `ParenListExpr` and using the `Inits` instead (which also simplifies the interface and implementation).
20 lines
366 B
C++
20 lines
366 B
C++
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value -std=c++20 %s
|
|
// expected-no-diagnostics
|
|
|
|
namespace GH64347 {
|
|
|
|
template<typename X, typename Y> struct A { X x; Y y;};
|
|
void test() {
|
|
A(1, 2);
|
|
new A(1, 2);
|
|
}
|
|
|
|
template<A a>
|
|
void f() { (void)a; }
|
|
void k() {
|
|
// Test CTAD works for non-type template arguments.
|
|
f<A(0, 0)>();
|
|
}
|
|
|
|
} // namespace GH64347
|