Skip to content

Commit

Permalink
Fix test errors
Browse files Browse the repository at this point in the history
Don't report error when checking synthesized constructor, we will
remove this constructor instead.

Change the location where we create the member initialize constructor
signature to SemanticsDeclAttributesVisitor to avoid the circular
checking problem.
  • Loading branch information
kaizhangNV committed Oct 9, 2024
1 parent ce77190 commit f485378
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 157 deletions.
25 changes: 15 additions & 10 deletions source/slang/slang-check-conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,8 @@ namespace Slang

// 4. All of its members have to have the same visibility as the struct itself.
DeclVisibility structVisibility = getDeclVisibility(structDecl);
for (auto varDeclRef : getMembersOfType<VarDeclBase>(getASTBuilder(), structDecl, MemberFilterStyle::Instance))
for (auto varDecl : structDecl->getMembersOfType<VarDeclBase>())
{
auto varDecl = varDeclRef.getDecl();
if (getDeclVisibility(varDecl) != structVisibility)
{
return false;
Expand All @@ -289,24 +288,25 @@ namespace Slang
}

// 5. All its members are legacy C-Style structs or arrays of legacy C-style structs
for (auto varDeclRef : getMembersOfType<VarDeclBase>(getASTBuilder(), structDecl, MemberFilterStyle::Instance))
for (auto varDecl : structDecl->getMembersOfType<VarDeclBase>())
{
auto varDecl = varDeclRef.getDecl();

// if the member is an array, check if the element is legacy C-style rule.
if (auto arrayType = as<ArrayExpressionType>(varDecl->getType()))
{
auto* elementType = arrayType->getElementType();
ArrayExpressionType* nextType = nullptr;
while(nextType = as<ArrayExpressionType>(elementType))
for (;;)
{
ArrayExpressionType* nextType = as<ArrayExpressionType>(elementType);
if(!nextType)
break;

elementType = nextType->getElementType();
}
if(auto structDecl = _getStructDecl(elementType))
if(auto elemStructDecl = _getStructDecl(elementType))
{
if (!_cStyleStructBasicCheck(structDecl))
if (!_cStyleStructBasicCheck(elemStructDecl))
{
getShared()->cacheCStyleStruct(structDecl, false);
getShared()->cacheCStyleStruct(elemStructDecl, false);
return false;
}
}
Expand Down Expand Up @@ -391,6 +391,11 @@ namespace Slang

bool isCStyle = isCStyleStruct(structDecl);

if (structDecl->m_synthesizedCtorMap.getCount() == 0)
{
return false;
}

List<Expr*> coercedArgs;
auto ctorInvokeExpr = _createCtorInvokeExpr(toType, fromInitializerListExpr->loc, fromInitializerListExpr->args);

Expand Down
Loading

0 comments on commit f485378

Please sign in to comment.