[clang] e916c8d - Revert "[Clang] Warn about 'z' printf modifier in old MSVC."

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 28 06:28:28 PST 2020


Author: Nico Weber
Date: 2020-01-28T09:27:54-05:00
New Revision: e916c8dfe461e272aa7ea115851db7ddda36b971

URL: https://github.com/llvm/llvm-project/commit/e916c8dfe461e272aa7ea115851db7ddda36b971
DIFF: https://github.com/llvm/llvm-project/commit/e916c8dfe461e272aa7ea115851db7ddda36b971.diff

LOG: Revert "[Clang] Warn about 'z' printf modifier in old MSVC."

This reverts commit fe0d1b6a8ac5048b8007e5e7cc2aeb4e3291bda0.
Makes Analysis/taint-generic.c fail on some Windows systems.

Added: 
    

Modified: 
    clang/lib/AST/FormatString.cpp
    clang/test/Sema/format-strings-ms.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp
index 2ca8fee67bf0..fcc0b3b11e25 100644
--- a/clang/lib/AST/FormatString.cpp
+++ b/clang/lib/AST/FormatString.cpp
@@ -748,15 +748,6 @@ bool FormatSpecifier::hasValidLengthModifier(const TargetInfo &Target,
     case LengthModifier::AsIntMax:
     case LengthModifier::AsSizeT:
     case LengthModifier::AsPtrDiff:
-      if (LM.getKind() == LengthModifier::AsSizeT &&
-          Target.getTriple().isOSMSVCRT() &&
-          !LO.isCompatibleWithMSVC(LangOptions::MSVC2015)) {
-        // The standard libraries before MSVC2015 didn't support the 'z' length
-        // modifier for size_t. So if the MS compatibility version is less than
-        // that, reject.
-        return false;
-      }
-
       switch (CS.getKind()) {
         case ConversionSpecifier::dArg:
         case ConversionSpecifier::DArg:

diff  --git a/clang/test/Sema/format-strings-ms.c b/clang/test/Sema/format-strings-ms.c
index c4d3e5664db0..56a349051d42 100644
--- a/clang/test/Sema/format-strings-ms.c
+++ b/clang/test/Sema/format-strings-ms.c
@@ -1,6 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 -fms-compatibility-version=18 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 -fms-compatibility-version=19 -DSIZE_T_OK %s
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 -Wformat-non-iso -DNON_ISO_WARNING %s
 
 int printf(const char *format, ...) __attribute__((format(printf, 1, 2)));
@@ -87,11 +85,4 @@ void z_test(void *p) {
   scanf("%Z", p); // expected-warning{{invalid conversion specifier 'Z'}}
 }
 
-void size_t_test(size_t s) {
-  printf("%zu", s);
-#ifndef SIZE_T_OK
-  // expected-warning at -2 {{length modifier 'z' results in undefined behavior or no effect with 'u' conversion specifier}}
-#endif
-}
-
 #endif


        


More information about the cfe-commits mailing list