================
@@ -24377,6 +24378,39 @@ VarDecl
*SemaOpenMP::ActOnOpenMPDeclareReductionInitializerStart(Scope *S,
void SemaOpenMP::ActOnOpenMPDeclareReductionInitializerEnd(
Decl *D, Expr *Initializer, VarDecl *OmpPrivParm) {
auto *DRD = cast<OMPDeclareReductionDecl>(D);
+
+ // For non-trivial types with user initializers, build an AST that
+ // includes default construction first to initialize members before user
+ // initializer. This must be done before popping contexts.
+ if (Initializer && !DRD->getDeclContext()->isDependentContext()) {
+ QualType ReductionType = DRD->getType();
+ if (const auto *RD = ReductionType->getAsCXXRecordDecl()) {
+ CXXConstructorDecl *DefaultCtor =
+ SemaRef.LookupDefaultConstructor(const_cast<CXXRecordDecl *>(RD));
----------------
alexey-bataev wrote:
```suggestion
if (CXXRecordDecl *RD = ReductionType->getAsCXXRecordDecl()) {
CXXConstructorDecl *DefaultCtor = SemaRef.LookupDefaultConstructor(RD);
```
https://github.com/llvm/llvm-project/pull/219265
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits