summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-01-29 23:32:22 +0000
committerTed Kremenek <kremenek@apple.com>2010-01-29 23:32:22 +0000
commit605b0113f3be459c2681b4bb504c76ede8d0cbd9 (patch)
tree5eb86da8dcafbbc603086d07ff5cbfcc4dc4533b /clang/lib/Sema/SemaChecking.cpp
parent34a6afc68d32d5f0fac5112ad102fee5cebb0067 (diff)
downloadbcm5719-llvm-605b0113f3be459c2681b4bb504c76ede8d0cbd9.tar.gz
bcm5719-llvm-605b0113f3be459c2681b4bb504c76ede8d0cbd9.zip
Be a little more permissive than C99: allow 'unsigned' to be used for
the field width and precision of a format specifier instead of just 'int'. This matches GCC, and fixes <rdar://problem/6079850>. llvm-svn: 94856
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 38f3f2df473..f10c8a17fca 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1151,10 +1151,14 @@ CheckPrintfHandler::HandleAmount(const analyze_printf::OptionalAmount &Amt,
}
// Type check the data argument. It should be an 'int'.
+ // Although not in conformance with C99, we also allow the argument to be
+ // an 'unsigned int' as that is a reasonably safe case. GCC also
+ // doesn't emit a warning for that case.
const Expr *Arg = getDataArg(NumConversions);
QualType T = Arg->getType();
- const BuiltinType *BT = T->getAs<BuiltinType>();
- if (!BT || BT->getKind() != BuiltinType::Int) {
+ const BuiltinType *BT = T->getAs<BuiltinType>();
+ if (!BT || (BT->getKind() != BuiltinType::Int &&
+ BT->getKind() != BuiltinType::UInt)) {
S.Diag(getLocationOfByte(Amt.getStart()), BadTypeDiag)
<< T
<< getFormatSpecifierRange(startSpecifier, specifierLen)
OpenPOWER on IntegriCloud