diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-10-13 14:27:47 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-10-13 14:27:47 +0000 |
commit | 2841c4c7413b075f5196c4ad970330e9eb6476ae (patch) | |
tree | 04cfc90c00589bef21198cfbfb42128b47b5edc0 /contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp | |
parent | ec1e5e05cc237d3c9ee0347bb2c933191e5844f5 (diff) | |
download | FreeBSD-src-2841c4c7413b075f5196c4ad970330e9eb6476ae.zip FreeBSD-src-2841c4c7413b075f5196c4ad970330e9eb6476ae.tar.gz |
Extend this check for const unsigned char *.
Approved by: rpaulo (mentor)
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp index 9c2606e..3429d86 100644 --- a/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp +++ b/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp @@ -1519,10 +1519,14 @@ CheckPrintfHandler::HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier // Now type check the data expression that matches the // format specifier. const Expr *Ex = getDataArg(argIndex); + QualType Pointee = S.Context.UnsignedCharTy; + Pointee.addConst(); + QualType constType = (CS.getKind() == ConversionSpecifier::bArg) ? S.Context.IntTy : S.Context.getPointerType(Pointee); QualType type = (CS.getKind() == ConversionSpecifier::bArg) ? S.Context.IntTy : S.Context.getPointerType(S.Context.UnsignedCharTy); - //const analyze_printf::ArgTypeResult &ATR = S.Context.IntTy; + const analyze_printf::ArgTypeResult &ConstATR = constType; const analyze_printf::ArgTypeResult &ATR = type; - if (ATR.isValid() && !ATR.matchesType(S.Context, Ex->getType())) + if (ATR.isValid() && !ATR.matchesType(S.Context, Ex->getType()) && + !ConstATR.matchesType(S.Context, Ex->getType())) S.Diag(getLocationOfByte(CS.getStart()), diag::warn_printf_conversion_argument_type_mismatch) << ATR.getRepresentativeType(S.Context) << Ex->getType() |