Convert assertion in memset checking to a runtime check (because real code may provide a deviant definition of memset).

llvm-svn: 130368
This commit is contained in:
Ted Kremenek 2011-04-28 01:38:02 +00:00
parent d25f8eb393
commit b5fabb2f9f
2 changed files with 12 additions and 1 deletions

View File

@ -1804,7 +1804,12 @@ void Sema::CheckFormatString(const StringLiteral *FExpr,
///
/// \param Call The call expression to diagnose.
void Sema::CheckMemsetArguments(const CallExpr *Call) {
assert(Call->getNumArgs() == 3 && "Unexpected number of arguments to memset");
// It is possible to have a non-standard definition of memset. Validate
// we have the proper number of arguments, and if not, abort further
// checking.
if (Call->getNumArgs() != 3)
return;
const Expr *Dest = Call->getArg(0)->IgnoreParenImpCasts();
QualType DestTy = Dest->getType();

View File

@ -0,0 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only %s -verify
char memset(); // expected-warning {{incompatible redeclaration of library function 'memset'}} expected-note{{'memset' is a builtin with type}}
char test() {
return memset();
}