[PATCH] D73457: [Clang] Warn about 'z' printf modifier in old MSVC.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 27 09:33:01 PST 2020


aaron.ballman added reviewers: rnk, majnemer, zturner.
aaron.ballman added a comment.

Adding some more Windows reviewers to see if there are more opinions on how to handle this.



================
Comment at: clang/lib/AST/FormatString.cpp:754
+          LO.isMSCompatibilityVersionSpecified() &&
+          !LO.isCompatibleWithMSVC(LangOptions::MSVC2015)) {
+        // The standard libraries before MSVC2015 didn't support the 'z' length
----------------
simon_tatham wrote:
> aaron.ballman wrote:
> > I'd rather not see `isMSCompatibilityVersionSpecified()` be introduced, but instead make `isCompatibleWithMSVC()` do the right thing when it's not specified.
> I tried making `isCompatibleWithMSVC` return true if `MSCompatibilityVersion == 0` on the basis that it should be considered 'newest' rather than 'oldest'. That caused a lot of knock-on test failures which I don't really understand all of:
> ```    Clang :: CodeGenCXX/dllexport-no-dllexport-inlines.cpp
>     Clang :: CodeGenCXX/exceptions-cxx-new.cpp
>     Clang :: CodeGenCXX/mangle-ms-exception-spec.cpp
>     Clang :: CodeGenCXX/msabi-blocks.cpp
>     Clang :: Rewriter/properties.m
>     Clang :: SemaCXX/microsoft-cxx0x.cpp
>     Clang :: SemaCXX/pragma-init_seg.cpp
>     Clang :: SemaCXX/warn-static-outside-class-definition.cpp
> ```
> `mangle-ms-exception-spec.cpp` in particular looks as if it's expecting some kind of completely different mangling without any compatibility version.
> 
> Perhaps I should go with the existing behavior and make 'unspecified' keep defaulting to oldest rather than newest? I think in general the driver will not leave it unspecified, so perhaps it won't make much difference outside the test suite anyway. Hmmm.
I would have expected passing `-fms-compatibility` without passing `-fms-compatibility-version` would default to compatibility with the newest version of MSVC instead of the oldest version (unless there is more specific information from the environment). However, then I found D20136 and it seems that we do default to an old version on purpose:
```
      // FIXME: Consider bumping this to 19 (MSVC2015) soon.
      return VersionTuple(18);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73457/new/

https://reviews.llvm.org/D73457





More information about the cfe-commits mailing list