[PATCH] D86369: [Sema][MSVC] warn at dynamic_cast when /GR- is given

Hans Wennborg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 3 06:02:31 PDT 2020


hans added a comment.

Okay, almost there..



================
Comment at: clang/lib/Sema/SemaCast.cpp:897
+                  DiagnosticOptions::MSVC;
+    if (isMSVC || !DestPointee->isVoidType())
+      Self.Diag(OpRange.getBegin(),
----------------
I don't think the if-statement is necessary. I thought we concluded we want to warn even for void*? Also note that "isMSVC" here is only checking the driver mode, i.e. just the user interface to the compiler. The user could still be compiling in MSVC mode.


================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:649
 
+  // Warns when typeid is used with RTTI disabled.
+  if (!getLangOpts().RTTIData)
----------------
s/RTTI/RTTI data/
(the "RTTI disabled" case is on line 646)


================
Comment at: clang/test/SemaCXX/ms_no_dynamic_cast.cpp:19
+  auto d = dynamic_cast<D1 *>(b); // expected-warning{{dynamic_cast will not work since RTTI data is disabled by /GR-}}
+  (void)typeid(int);              // expected-warning{{typeid will not work since RTTI data is disabled by /GR-}}
+}
----------------
Is the cast to void necessary? Same comment for the next file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86369



More information about the cfe-commits mailing list