Make output match actual condition tested. Thanks, Duncan.
[oota-llvm.git] / lib / VMCore / Verifier.cpp
index 16e87f4f7a176337cd205b6430652fceec9a2c8b..ffca88bfabc307a67c3f4ffc196f4298434698f4 100644 (file)
@@ -361,6 +361,14 @@ void Verifier::visitFunction(Function &F) {
 
   if (const ParamAttrsList *Attrs = FT->getParamAttrs()) {
     unsigned Idx = 1;
+
+    Assert1(!Attrs->paramHasAttr(0, ParamAttr::ByVal),
+            "Attribute ByVal should not apply to functions!", &F);
+    Assert1(!Attrs->paramHasAttr(0, ParamAttr::StructRet),
+            "Attribute SRet should not apply to functions!", &F);
+    Assert1(!Attrs->paramHasAttr(0, ParamAttr::InReg),
+            "Attribute InReg should not apply to functions!", &F);
+
     for (FunctionType::param_iterator I = FT->param_begin(), 
          E = FT->param_end(); I != E; ++I, ++Idx) {
       if (Attrs->paramHasAttr(Idx, ParamAttr::ZExt) ||
@@ -370,9 +378,23 @@ void Verifier::visitFunction(Function &F) {
       if (Attrs->paramHasAttr(Idx, ParamAttr::NoAlias))
         Assert1(isa<PointerType>(FT->getParamType(Idx-1)),
                 "Attribute NoAlias should only apply to Pointer type!", &F);
-      if (Attrs->paramHasAttr(Idx, ParamAttr::ByVal))
+      if (Attrs->paramHasAttr(Idx, ParamAttr::ByVal)) {
         Assert1(isa<PointerType>(FT->getParamType(Idx-1)),
-                "Attribute ByVal should only apply to Pointer type!", &F);
+                "Attribute ByVal should only apply to pointer to structs!", &F);
+
+        Assert1(!Attrs->paramHasAttr(Idx, ParamAttr::StructRet),
+                "Attributes ByVal and StructRet are incompatible!", &F);
+
+        const PointerType *Ty =
+            cast<PointerType>(FT->getParamType(Idx-1));
+        Assert1(isa<StructType>(Ty->getElementType()),
+                "Attribute ByVal should only apply to pointer to structs!", &F);
+      }
+
+      Assert1(!Attrs->paramHasAttr(Idx, ParamAttr::NoReturn), 
+             "Attribute NoReturn should only be applied to function", &F);
+      Assert1(!Attrs->paramHasAttr(Idx, ParamAttr::NoUnwind),
+             "Attribute NoUnwind should only be applied to function", &F);
     }
   }
 
@@ -1100,7 +1122,7 @@ void Verifier::VerifyIntrinsicPrototype(Intrinsic::ID ID, Function *F, ...) {
           break;
       }
     } else if (TypeID == Type::VectorTyID) {
-      // If this is a packed argument, verify the number and type of elements.
+      // If this is a vector argument, verify the number and type of elements.
       const VectorType *PTy = cast<VectorType>(Ty);
       int ElemTy = va_arg(VA, int);
       if (ElemTy != PTy->getElementType()->getTypeID()) {