[PATCH] D149154: [clang][Interp] Emit diagnostic when comparing function pointers
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 25 12:21:24 PDT 2023
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
LGTM
================
Comment at: clang/lib/AST/Interp/Interp.h:652-653
+ const SourceInfo &Loc = S.Current->getSource(OpPC);
+ S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_unspecified)
+ << LS << RS;
+ return false;
----------------
tbaeder wrote:
> aaron.ballman wrote:
> > Can we pass in the result of `getType()` instead of doing this string conversion dance?
> Well the diagnostic doesn't print the result of the LHS/RHS:
> ```
> ./array.cpp:202:18: error: constexpr variable 'u13' must be initialized by a constant expression
> 202 | constexpr bool u13 = pf < pg; // ref-warning {{ordered comparison of function pointers}}
> | ^ ~~~~~~~
> ./array.cpp:202:27: note: comparison between '&f' and '&g' has unspecified value
> 202 | constexpr bool u13 = pf < pg; // ref-warning {{ordered comparison of function pointers}}
> | ^
> ```
>
> I'm not exactly a fan of how the code looks though. I might add a helper function for this later.
Ah of course, good point. And yeah, a helper function for this would probably not be a bad idea.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149154/new/
https://reviews.llvm.org/D149154
More information about the cfe-commits
mailing list