aboutsummaryrefslogtreecommitdiff
path: root/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
commit31f8e32788adb299acad455363eb7fd244642c82 (patch)
tree22829ee42a02abf32e5853c6fe7d3bdfed4093c6 /lib/Sema/SemaChecking.cpp
parent40888ada6022cfd4ab2a7c07ab276639860ffc5a (diff)
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>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94856 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 38f3f2df47..f10c8a17fc 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/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)