]> granicus.if.org Git - clang/commitdiff
Perform range restrictions on regparm when applied to a type and
authorJohn McCall <rjmccall@apple.com>
Thu, 14 Oct 2010 01:57:10 +0000 (01:57 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 14 Oct 2010 01:57:10 +0000 (01:57 +0000)
not a decl.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116469 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaType.cpp

index c7dc80e7ce8c3b7bea284e7bf572dee91e322381..5901737389e249996720e06f367a3710030532ad 100644 (file)
@@ -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;
   }