diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-07-20 20:04:47 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-07-20 20:04:47 +0000 |
commit | 1e51c200b17cb6b0238c10a8760ae04765688f16 (patch) | |
tree | 1bea6f2a78b3483dc83a03e9082e79533a25ab32 /lib/Sema/SemaChecking.cpp | |
parent | a412a499162c46211c10ad92045b9b5fd2298ede (diff) |
Hookup checking for invalid length modifiers in scanf format strings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108907 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 8846c25724..2887a50d52 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -1701,9 +1701,17 @@ bool CheckScanfHandler::HandleScanfSpecifier( CoveredArgs.set(argIndex); } - // FIXME: Check that the length modifier is valid with the given - // conversion specifier. - + // Check the length modifier is valid with the given conversion specifier. + const LengthModifier &LM = FS.getLengthModifier(); + if (!FS.hasValidLengthModifier()) { + S.Diag(getLocationOfByte(LM.getStart()), + diag::warn_format_nonsensical_length) + << LM.toString() << CS.toString() + << getSpecifierRange(startSpecifier, specifierLen) + << FixItHint::CreateRemoval(getSpecifierRange(LM.getStart(), + LM.getLength())); + } + // The remaining checks depend on the data arguments. if (HasVAListArg) return true; |