[cfe-commits] r116469 - /cfe/trunk/lib/Sema/SemaType.cpp

John McCall rjmccall at apple.com
Wed Oct 13 18:57:10 PDT 2010


Author: rjmccall
Date: Wed Oct 13 20:57:10 2010
New Revision: 116469

URL: http://llvm.org/viewvc/llvm-project?rev=116469&view=rev
Log:
Perform range restrictions on regparm when applied to a type and
not a decl.


Modified:
    cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=116469&r1=116468&r2=116469&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Oct 13 20:57:10 2010
@@ -1898,6 +1898,20 @@
         !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;
   }





More information about the cfe-commits mailing list