From: John McCall Date: Thu, 14 Oct 2010 01:57:10 +0000 (+0000) Subject: Perform range restrictions on regparm when applied to a type and X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1e030eb1194763b42c1752723be23b1515f48981;p=clang Perform range restrictions on regparm when applied to a type and not a decl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116469 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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; }