From 115bc7113ed82abfcb8a086052b1ecbb896f5924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jernej=20Krempu=C5=A1?= Date: Wed, 3 Oct 2012 03:44:34 +0200 Subject: [PATCH] Improved error messages. --- gen/toir.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gen/toir.cpp b/gen/toir.cpp index d9bfdcfd..be25b755 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -45,6 +45,8 @@ #include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/raw_ostream.h" + llvm::cl::opt checkPrintf("check-printf-calls", llvm::cl::desc("Validate printf call format strings against arguments"), llvm::cl::ZeroOrMore); @@ -994,8 +996,8 @@ DValue* CallExp::toElem(IRState* p) llvm::SmallVector mask; for(int i = 2, n = arguments->dim; i < n; i++){ Expression* exp = static_cast(arguments->data[i]); - if(exp->op != TOKint64){ - error("Function %s was declared with pragma shufflevector. Because of that all of its arguments except the first two must be integer literals.", fndecl->toChars()); + if(exp->op != TOKint64 || exp->type->ty != Tint32){ + error("Function %s was declared with pragma shufflevector. Because of that all of its arguments except for the first two must be int literals.", fndecl->toChars()); fatal(); } IntegerExp* iexp = static_cast(arguments->data[i]); @@ -1011,8 +1013,8 @@ DValue* CallExp::toElem(IRState* p) // extractelement else if(fndecl->llvmInternal == LLVMextractelement) { Expression* exp2 = static_cast(arguments->data[1]); - if(exp2->op != TOKint64){ - error("Function %s was declared with pragma extractelement. Because of that its second argument must be an integer literal.", fndecl->toChars()); + if(exp2->op != TOKint64 || exp2->type->ty != Tint32){ + error("Function %s was declared with pragma extractelement. Because of that its second argument must be an int literal.", fndecl->toChars()); fatal(); } LLValue* idx = exp2->toElem(p)->getRVal(); @@ -1023,8 +1025,8 @@ DValue* CallExp::toElem(IRState* p) // insertelement else if(fndecl->llvmInternal == LLVMinsertelement) { Expression* exp3 = static_cast(arguments->data[2]); - if(exp3->op != TOKint64){ - error("Function %s was declared with pragma extractelement. Because of that its second argument must be an integer literal.", fndecl->toChars()); + if(exp3->op != TOKint64 || exp3->type->ty != Tint32){ + error("Function %s was declared with pragma insertelement. Because of that its third argument must be an int literal.", fndecl->toChars()); fatal(); } LLValue* idx = exp3->toElem(p)->getRVal();