summaryrefslogtreecommitdiff
path: root/lib/VMCore
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-08-27 14:48:06 +0000
committerDan Gohman <gohman@apple.com>2008-08-27 14:48:06 +0000
commit39dfc2cb9c1fb53c8699cff033f6fa6c5b618e95 (patch)
tree63dbebce13a05b0d521f903d94153b872b1efc30 /lib/VMCore
parent9f50eeea8c561dd9410846ef09315acc75b55b9b (diff)
downloadllvm-39dfc2cb9c1fb53c8699cff033f6fa6c5b618e95.tar.gz
llvm-39dfc2cb9c1fb53c8699cff033f6fa6c5b618e95.tar.bz2
llvm-39dfc2cb9c1fb53c8699cff033f6fa6c5b618e95.tar.xz
Diagnose uses of unsized types with the byval attribute in the
verifier. See PR2711 for details. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55414 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Verifier.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 299a0f4043..84f9499168 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<PointerType>(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.