
Fix https://github.com/llvm/llvm-project/issues/68885 When build expression from a deduced argument whose kind is `Declaration` and `NTTPType`(which declared as `decltype(auto)`) is deduced as a reference type, `BuildExpressionFromDeclTemplateArgument` just create a `DeclRef`. This is incorrect while we get type from the expression since we can't get the original reference type from `DeclRef`. Creating a `SubstNonTypeTemplateParmExpr` expression and make the deduction correct. `Replacement` expression of `SubstNonTypeTemplateParmExpr` just helps the deduction and may not be same with the original expression. Co-authored-by: huqizhi <836744285@qq.com>
22 lines
402 B
C++
22 lines
402 B
C++
// RUN: %clang_cc1 -verify -std=c++20 -fsyntax-only %s
|
|
|
|
// expected-no-diagnostics
|
|
|
|
template <decltype(auto) a>
|
|
struct S {
|
|
static constexpr int i = 42;
|
|
};
|
|
|
|
template <decltype(auto) a> requires true
|
|
struct S<a> {
|
|
static constexpr int i = 0;
|
|
};
|
|
|
|
static constexpr int a = 0;
|
|
|
|
void test() {
|
|
static_assert(S<a>::i == 0);
|
|
static_assert(S<(a)>::i == 0);
|
|
static_assert(S<((a))>::i == 0);
|
|
}
|