aaron.ballman added inline comments.

================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6922
 def ext_typecheck_indirection_through_void_pointer : ExtWarn<
-  "ISO C++ does not allow indirection on operand of type %0">,
+  "ISO %select{C++|C}0 does not allow indirection on operand of type %1">,
   InGroup<DiagGroup<"void-ptr-dereference">>;
----------------
Swapping these so the logic is more straightforward elsewhere.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:14538-14544
+    if (S.getLangOpts().CPlusPlus)
+      S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
+          << /* C++ mode */ 0 << OpTy << Op->getSourceRange();
+    else if (!S.getLangOpts().CPlusPlus)
+      if (!(S.getLangOpts().C99 && IsAfterAmp))
+        S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
+            << /* C mode */ 1 << OpTy << Op->getSourceRange();
----------------
Simplifying the logic a bit.


================
Comment at: clang/test/C/drs/dr1xx.c:140
   /* The behavior changed between C89 and C99. */
-  (void)&*p; /* c89only-warning {{ISO C forbids taking the address of an 
expression of type 'void'}} */
+  (void)&*p; /* c89only-warning {{ISO C forbids taking the address of an 
expression of type 'void'}} c89only-warning {{ISO C does not allow indirection 
on operand of type 'void *'}} */
   /* The behavior of all three of these is undefined. */
----------------
Can you switch all of the warning changes in this file to use this style where 
each expected diagnostic is on its own line? That makes it easier to notice 
which diagnostics happen on the line (it's easy to lose sight of the trailing 
expected diagnostics otherwise).


================
Comment at: clang/test/C/drs/dr1xx.c:143
+  (void)*p; /* expected-warning {{ISO C does not allow indirection on operand 
of type 'void *'}}*/
+  (void)&(*p); /* c89only-warning {{ISO C forbids taking the address of an 
expression of type 'void'}} expected-warning {{ISO C does not allow indirection 
on operand of type 'void *'}}*/
+  (void)(i ? *p : *p); /* expected-warning {{ISO C does not allow indirection 
on operand of type 'void *'}} expected-warning {{ISO C does not allow 
indirection on operand of type 'void *'}}*/
----------------
This looks wrong to me -- this should be an `expected-warning` instead of a 
`c89only-warning`, same as two lines above, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134461

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to