aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a minor nit in the tests. Thank you for this!



================
Comment at: clang/test/C/drs/dr1xx.c:191-194
+  return *vvp; /* expected-warning {{void function 'dr113_v' should not return 
void expression}} expected-warning{{ISO C does not allow indirection on operand 
of type 'volatile void *'}} */
 }
 const void dr113_c(const void *cvp) { /* expected-warning {{function cannot 
return qualified void type 'const void'}} */
+  return *cvp; /* expected-warning {{void function 'dr113_c' should not return 
void expression}} expected-warning{{ISO C does not allow indirection on operand 
of type 'const void *'}} */
----------------
Can you separate these diagnostics onto their own lines as well?


================
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. */
----------------
junaire wrote:
> aaron.ballman wrote:
> > 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).
> > Yes, basically, the language rule is that &*void_ptr is well defined in C99 
> > and later
> 
> IIUC, you mean this should be warned in C89 mode, right?
>> Yes, basically, the language rule is that &*void_ptr is well defined in C99 
>> and later
>IIUC, you mean this should be warned in C89 mode, right?

Correct; I think there's two warnings that would fire there in C89: 
dereferencing a void pointer is one, and taking the address of void is the 
other.


================
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 *'}}*/
----------------
junaire wrote:
> aaron.ballman wrote:
> > This looks wrong to me -- this should be an `expected-warning` instead of a 
> > `c89only-warning`, same as two lines above, right?
> I'm a bit confused. Maybe I made the trailing comments too hard to read. This 
> is an `expected-warning`, `c89only-warning` is for `ISO C forbids taking the 
> address of an expression of type 'void'`, which is not part of this patch.
You're right, I think I just confused myself. Sorry for the noise! Though it is 
a bit strange that `ISO C does not allow indirection on operand of type 'void 
*'` is a c89 only warning on line 140 while it's an expected warning on line 
146. Something odd is happening there, but I don't think it's the fault of this 
patch.


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