Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13783,9 +13783,11 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
VDecl->getLocation(), DirectInit, Init);

MultiExprArg Args = Init;
if (CXXDirectInit)
Args = MultiExprArg(CXXDirectInit->getExprs(),
CXXDirectInit->getNumExprs());
if (auto *CXXDirectInit = dyn_cast<ParenListExpr>(Init))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove line 13778 now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good catch

Args =
MultiExprArg(CXXDirectInit->getExprs(), CXXDirectInit->getNumExprs());
else if (auto *CXXDirectInit = dyn_cast<CXXParenListInitExpr>(Init))
Args = CXXDirectInit->getInitExprs();

// Try to correct any TypoExprs in the initialization arguments.
for (size_t Idx = 0; Idx < Args.size(); ++Idx) {
Expand Down
22 changes: 22 additions & 0 deletions clang/test/SemaCXX/paren-list-agg-init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,25 @@ void test() {
S<int>{}.f(); // beforecxx20-note {{requested here}}
}
}

namespace GH72880_regression {
struct E {
int i = 42;
};
struct G {
E e;
};
template <typename>
struct Test {
void f() {
constexpr E e;
//FIXME: We should only warn one
constexpr G g(e); // beforecxx20-warning 2{{C++20 extension}}
static_assert(g.e.i == 42);
}
};
void test() {
Test<int>{}.f(); // beforecxx20-note {{requested here}}
}

}
Loading