diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 299a0f4043c..84f94991689 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -421,6 +421,17 @@ void Verifier::VerifyAttrs(ParameterAttributes Attrs, const Type *Ty, ParameterAttributes TypeI = Attrs & ParamAttr::typeIncompatible(Ty); Assert1(!TypeI, "Wrong type for attribute " + ParamAttr::getAsString(TypeI), V); + + ParameterAttributes ByValI = Attrs & ParamAttr::ByVal; + if (const PointerType *PTy = dyn_cast(Ty)) { + Assert1(!ByValI || PTy->getElementType()->isSized(), + "Attribute " + ParamAttr::getAsString(ByValI) + + " does not support unsized types!", V); + } else { + Assert1(!ByValI, + "Attribute " + ParamAttr::getAsString(ByValI) + + " only applies to parameters with pointer type!", V); + } } // VerifyFunctionAttrs - Check parameter attributes against a function type. diff --git a/test/Verifier/byval-2.ll b/test/Verifier/byval-2.ll index d7bfedfcd6a..1d03715bc32 100644 --- a/test/Verifier/byval-2.ll +++ b/test/Verifier/byval-2.ll @@ -1,3 +1,4 @@ -; RUN: llvm-as %s -o /dev/null -f +; RUN: not llvm-as < %s >& /dev/null +; PR2711 %s = type opaque declare void @h(%s* byval %num)