mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed valueless alias, warn on unused attribute
This commit is contained in:
parent
83ed41e81a
commit
5a3701fa90
4 changed files with 17 additions and 13 deletions
|
@ -2582,6 +2582,7 @@ void BfExprEvaluator::Visit(BfTypeReference* typeRef)
|
|||
void BfExprEvaluator::Visit(BfAttributedExpression* attribExpr)
|
||||
{
|
||||
BfAttributeState attributeState;
|
||||
attributeState.mSrc = attribExpr->mAttributes;
|
||||
attributeState.mTarget = (BfAttributeTargets)(BfAttributeTargets_Invocation | BfAttributeTargets_MemberAccess);
|
||||
if (auto block = BfNodeDynCast<BfBlock>(attribExpr->mExpression))
|
||||
attributeState.mTarget = BfAttributeTargets_Block;
|
||||
|
@ -2606,10 +2607,7 @@ void BfExprEvaluator::Visit(BfAttributedExpression* attribExpr)
|
|||
VisitChild(attribExpr->mExpression);
|
||||
}
|
||||
|
||||
if (!attributeState.mUsed)
|
||||
{
|
||||
mModule->Fail("Unused attributes", attribExpr->mAttributes);
|
||||
}
|
||||
mModule->FinishAttributeState(&attributeState);
|
||||
}
|
||||
|
||||
void BfExprEvaluator::Visit(BfBlock* blockExpr)
|
||||
|
@ -13769,6 +13767,10 @@ void BfExprEvaluator::InjectMixin(BfAstNode* targetSrc, BfTypedValue target, boo
|
|||
{
|
||||
//TODO: Implement
|
||||
}
|
||||
else if (newLocalVar->mResolvedType->IsValuelessType())
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
BfIRValue value = newLocalVar->mValue;
|
||||
|
@ -14682,10 +14684,8 @@ void BfExprEvaluator::DoInvocation(BfAstNode* target, BfMethodBoundExpression* m
|
|||
mResult = MatchMethod(methodNodeSrc, methodBoundExpr, thisValue, allowImplicitThis, bypassVirtual, targetFunctionName, argValues, methodGenericArguments, checkedKind);
|
||||
argValues.HandleFixits(mModule);
|
||||
|
||||
if ((mModule->mAttributeState == &attributeState) && (!attributeState.mUsed))
|
||||
{
|
||||
mModule->Fail("Unused attributes", attributeState.mSrc);
|
||||
}
|
||||
if (mModule->mAttributeState == &attributeState)
|
||||
mModule->FinishAttributeState(&attributeState);
|
||||
|
||||
if (isCascade)
|
||||
{
|
||||
|
|
|
@ -10544,6 +10544,12 @@ BfCustomAttributes* BfModule::GetCustomAttributes(BfAttributeDirective* attribut
|
|||
return customAttributes;
|
||||
}
|
||||
|
||||
void BfModule::FinishAttributeState(BfAttributeState* attributeState)
|
||||
{
|
||||
if ((!attributeState->mUsed) && (attributeState->mSrc != NULL))
|
||||
Warn(0, "Unused attributes", attributeState->mSrc);
|
||||
}
|
||||
|
||||
void BfModule::ProcessTypeInstCustomAttributes(bool& isPacked, bool& isUnion, bool& isCRepr, bool& isOrdered)
|
||||
{
|
||||
if (mCurTypeInstance->mCustomAttributes != NULL)
|
||||
|
|
|
@ -1466,6 +1466,7 @@ public:
|
|||
void ValidateCustomAttributes(BfCustomAttributes* customAttributes, BfAttributeTargets attrTarget);
|
||||
void GetCustomAttributes(BfCustomAttributes* customAttributes, BfAttributeDirective* attributesDirective, BfAttributeTargets attrType, bool allowNonConstArgs = false, BfCaptureInfo* captureInfo = NULL);
|
||||
BfCustomAttributes* GetCustomAttributes(BfAttributeDirective* attributesDirective, BfAttributeTargets attrType, bool allowNonConstArgs = false, BfCaptureInfo* captureInfo = NULL);
|
||||
void FinishAttributeState(BfAttributeState* attributeState);
|
||||
void ProcessTypeInstCustomAttributes(bool& isPacked, bool& isUnion, bool& isCRepr, bool& isOrdered);
|
||||
void ProcessCustomAttributeData();
|
||||
bool TryGetConstString(BfIRConstHolder* constHolder, BfIRValue irValue, StringImpl& str);
|
||||
|
|
|
@ -3760,7 +3760,7 @@ void BfModule::Visit(BfLocalMethodDeclaration* methodDecl)
|
|||
void BfModule::Visit(BfAttributedStatement* attribStmt)
|
||||
{
|
||||
BfAttributeState attributeState;
|
||||
|
||||
attributeState.mSrc = attribStmt->mAttributes;
|
||||
attributeState.mTarget = (BfAttributeTargets)(BfAttributeTargets_Invocation | BfAttributeTargets_MemberAccess);
|
||||
if (auto block = BfNodeDynCast<BfBlock>(attribStmt->mStatement))
|
||||
attributeState.mTarget = BfAttributeTargets_Block;
|
||||
|
@ -3786,10 +3786,7 @@ void BfModule::Visit(BfAttributedStatement* attribStmt)
|
|||
VisitChild(attribStmt->mStatement);
|
||||
}
|
||||
|
||||
if (!attributeState.mUsed)
|
||||
{
|
||||
Fail("Unused attributes", attribStmt->mAttributes);
|
||||
}
|
||||
FinishAttributeState(&attributeState);
|
||||
}
|
||||
|
||||
void BfModule::Visit(BfExpression* expression)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue