[PATCH] D104680: [clang] Eliminate relational function pointer comparisons in all C++ modes

Matheus Izvekov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 22 15:35:47 PDT 2021


mizvekov added inline comments.


================
Comment at: clang/test/SemaTemplate/resolve-single-template-id.cpp:73-75
+  oneT<int> < oneT<int>; // expected-warning {{self-comparison always evaluates to false}} \
+                         // expected-warning {{relational comparison result unused}}       \
+                         // expected-error   {{ordered comparison of function pointers}}
----------------
mizvekov wrote:
> Quuxplusone wrote:
> > Cast `(void)(x < y)` here to suppress one of these irrelevant warnings.
> > The combination of warning "expr always evaluates to false" and erroring "expr is ill-formed" is also silly, but I suppose we can't do much about it.
> I tried avoid changing the original test because I am not sure what the original intention was, but I agree in principle the two errors already give enough indication that the compiler is figuring out what is happening here correctly.
Taking another look at this test, it is doing too much weird stuff like this all over the place, and I am a bit hesitant to make such a change because the test scope is really not clear here...

I would be more open to suppressing this warning by passing a command line flag, but even then I would wait for a second opinion.

Some crazy talk on my part here, but I wonder a bit if this is somehow bothering us because there are so many diagnostics thrown in such small amount of code. Perhaps a bit like how we might feel pointing someone out for too many errors is not very social?
Suppose the user writes this 10 character statement and he gets one error and two warnings, that might offend him a little bit, maybe?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104680



More information about the cfe-commits mailing list