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)
|
void BfExprEvaluator::Visit(BfAttributedExpression* attribExpr)
|
||||||
{
|
{
|
||||||
BfAttributeState attributeState;
|
BfAttributeState attributeState;
|
||||||
|
attributeState.mSrc = attribExpr->mAttributes;
|
||||||
attributeState.mTarget = (BfAttributeTargets)(BfAttributeTargets_Invocation | BfAttributeTargets_MemberAccess);
|
attributeState.mTarget = (BfAttributeTargets)(BfAttributeTargets_Invocation | BfAttributeTargets_MemberAccess);
|
||||||
if (auto block = BfNodeDynCast<BfBlock>(attribExpr->mExpression))
|
if (auto block = BfNodeDynCast<BfBlock>(attribExpr->mExpression))
|
||||||
attributeState.mTarget = BfAttributeTargets_Block;
|
attributeState.mTarget = BfAttributeTargets_Block;
|
||||||
|
@ -2606,10 +2607,7 @@ void BfExprEvaluator::Visit(BfAttributedExpression* attribExpr)
|
||||||
VisitChild(attribExpr->mExpression);
|
VisitChild(attribExpr->mExpression);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!attributeState.mUsed)
|
mModule->FinishAttributeState(&attributeState);
|
||||||
{
|
|
||||||
mModule->Fail("Unused attributes", attribExpr->mAttributes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfExprEvaluator::Visit(BfBlock* blockExpr)
|
void BfExprEvaluator::Visit(BfBlock* blockExpr)
|
||||||
|
@ -13769,6 +13767,10 @@ void BfExprEvaluator::InjectMixin(BfAstNode* targetSrc, BfTypedValue target, boo
|
||||||
{
|
{
|
||||||
//TODO: Implement
|
//TODO: Implement
|
||||||
}
|
}
|
||||||
|
else if (newLocalVar->mResolvedType->IsValuelessType())
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BfIRValue value = newLocalVar->mValue;
|
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);
|
mResult = MatchMethod(methodNodeSrc, methodBoundExpr, thisValue, allowImplicitThis, bypassVirtual, targetFunctionName, argValues, methodGenericArguments, checkedKind);
|
||||||
argValues.HandleFixits(mModule);
|
argValues.HandleFixits(mModule);
|
||||||
|
|
||||||
if ((mModule->mAttributeState == &attributeState) && (!attributeState.mUsed))
|
if (mModule->mAttributeState == &attributeState)
|
||||||
{
|
mModule->FinishAttributeState(&attributeState);
|
||||||
mModule->Fail("Unused attributes", attributeState.mSrc);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isCascade)
|
if (isCascade)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10544,6 +10544,12 @@ BfCustomAttributes* BfModule::GetCustomAttributes(BfAttributeDirective* attribut
|
||||||
return customAttributes;
|
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)
|
void BfModule::ProcessTypeInstCustomAttributes(bool& isPacked, bool& isUnion, bool& isCRepr, bool& isOrdered)
|
||||||
{
|
{
|
||||||
if (mCurTypeInstance->mCustomAttributes != NULL)
|
if (mCurTypeInstance->mCustomAttributes != NULL)
|
||||||
|
|
|
@ -1466,6 +1466,7 @@ public:
|
||||||
void ValidateCustomAttributes(BfCustomAttributes* customAttributes, BfAttributeTargets attrTarget);
|
void ValidateCustomAttributes(BfCustomAttributes* customAttributes, BfAttributeTargets attrTarget);
|
||||||
void GetCustomAttributes(BfCustomAttributes* customAttributes, BfAttributeDirective* attributesDirective, BfAttributeTargets attrType, bool allowNonConstArgs = false, BfCaptureInfo* captureInfo = NULL);
|
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);
|
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 ProcessTypeInstCustomAttributes(bool& isPacked, bool& isUnion, bool& isCRepr, bool& isOrdered);
|
||||||
void ProcessCustomAttributeData();
|
void ProcessCustomAttributeData();
|
||||||
bool TryGetConstString(BfIRConstHolder* constHolder, BfIRValue irValue, StringImpl& str);
|
bool TryGetConstString(BfIRConstHolder* constHolder, BfIRValue irValue, StringImpl& str);
|
||||||
|
|
|
@ -3760,7 +3760,7 @@ void BfModule::Visit(BfLocalMethodDeclaration* methodDecl)
|
||||||
void BfModule::Visit(BfAttributedStatement* attribStmt)
|
void BfModule::Visit(BfAttributedStatement* attribStmt)
|
||||||
{
|
{
|
||||||
BfAttributeState attributeState;
|
BfAttributeState attributeState;
|
||||||
|
attributeState.mSrc = attribStmt->mAttributes;
|
||||||
attributeState.mTarget = (BfAttributeTargets)(BfAttributeTargets_Invocation | BfAttributeTargets_MemberAccess);
|
attributeState.mTarget = (BfAttributeTargets)(BfAttributeTargets_Invocation | BfAttributeTargets_MemberAccess);
|
||||||
if (auto block = BfNodeDynCast<BfBlock>(attribStmt->mStatement))
|
if (auto block = BfNodeDynCast<BfBlock>(attribStmt->mStatement))
|
||||||
attributeState.mTarget = BfAttributeTargets_Block;
|
attributeState.mTarget = BfAttributeTargets_Block;
|
||||||
|
@ -3786,10 +3786,7 @@ void BfModule::Visit(BfAttributedStatement* attribStmt)
|
||||||
VisitChild(attribStmt->mStatement);
|
VisitChild(attribStmt->mStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!attributeState.mUsed)
|
FinishAttributeState(&attributeState);
|
||||||
{
|
|
||||||
Fail("Unused attributes", attribStmt->mAttributes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfModule::Visit(BfExpression* expression)
|
void BfModule::Visit(BfExpression* expression)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue