diff options
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r-- | lib/Sema/SemaType.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index c7dc80e7ce..5901737389 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1898,6 +1898,20 @@ bool ProcessFnAttr(Sema &S, QualType &Type, const AttributeList &Attr) { !NumParamsExpr->isIntegerConstantExpr(NumParams, S.Context)) return false; + if (S.Context.Target.getRegParmMax() == 0) { + S.Diag(Attr.getLoc(), diag::err_attribute_regparm_wrong_platform) + << NumParamsExpr->getSourceRange(); + Attr.setInvalid(); + return; + } + + if (NumParams.getLimitedValue(255) > S.Context.Target.getRegParmMax()) { + S.Diag(Attr.getLoc(), diag::err_attribute_regparm_invalid_number) + << S.Context.Target.getRegParmMax() << NumParamsExpr->getSourceRange(); + Attr.setInvalid(); + return; + } + Type = S.Context.getRegParmType(Type, NumParams.getZExtValue()); return false; } |