MaskRay created this revision. MaskRay added reviewers: aaron.ballman, dim, enh. Herald added a project: All. MaskRay requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Fix https://github.com/llvm/llvm-project/issues/62247 D131057 <https://reviews.llvm.org/D131057> added `bArg` and `BArg` in the `AsLongLong` label in `FormatSpecifier::hasValidLengthModifier`, but missed the `AsLong` label, therefore `%llb` is allowed while `%lb` has a spurious warning. Add the missing case labels. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D148779 Files: clang/lib/AST/FormatString.cpp clang/test/Sema/format-strings.c Index: clang/test/Sema/format-strings.c =================================================================== --- clang/test/Sema/format-strings.c +++ clang/test/Sema/format-strings.c @@ -304,6 +304,7 @@ printf("%qp", (void *)0); // expected-warning{{length modifier 'q' results in undefined behavior or no effect with 'p' conversion specifier}} printf("hhX %hhX", (unsigned char)10); // no-warning printf("llX %llX", (long long) 10); // no-warning + printf("%lb %lB", (long) 10, (long) 10); // no-warning printf("%llb %llB", (long long) 10, (long long) 10); // no-warning // This is fine, because there is an implicit conversion to an int. printf("%d", (unsigned char) 10); // no-warning Index: clang/lib/AST/FormatString.cpp =================================================================== --- clang/lib/AST/FormatString.cpp +++ clang/lib/AST/FormatString.cpp @@ -848,6 +848,8 @@ } switch (CS.getKind()) { + case ConversionSpecifier::bArg: + case ConversionSpecifier::BArg: case ConversionSpecifier::dArg: case ConversionSpecifier::DArg: case ConversionSpecifier::iArg:
Index: clang/test/Sema/format-strings.c =================================================================== --- clang/test/Sema/format-strings.c +++ clang/test/Sema/format-strings.c @@ -304,6 +304,7 @@ printf("%qp", (void *)0); // expected-warning{{length modifier 'q' results in undefined behavior or no effect with 'p' conversion specifier}} printf("hhX %hhX", (unsigned char)10); // no-warning printf("llX %llX", (long long) 10); // no-warning + printf("%lb %lB", (long) 10, (long) 10); // no-warning printf("%llb %llB", (long long) 10, (long long) 10); // no-warning // This is fine, because there is an implicit conversion to an int. printf("%d", (unsigned char) 10); // no-warning Index: clang/lib/AST/FormatString.cpp =================================================================== --- clang/lib/AST/FormatString.cpp +++ clang/lib/AST/FormatString.cpp @@ -848,6 +848,8 @@ } switch (CS.getKind()) { + case ConversionSpecifier::bArg: + case ConversionSpecifier::BArg: case ConversionSpecifier::dArg: case ConversionSpecifier::DArg: case ConversionSpecifier::iArg:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits