This is an archive of the discontinued LLVM Phabricator instance.

[clang][Interp] Diagnose unknown parameter values
ClosedPublic

Authored by tbaeder on Jul 27 2023, 11:42 PM.

Diff Detail

Event Timeline

tbaeder created this revision.Jul 27 2023, 11:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2023, 11:42 PM
tbaeder requested review of this revision.Jul 27 2023, 11:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2023, 11:42 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tbaeder updated this revision to Diff 545028.Jul 27 2023, 11:59 PM
tbaeder edited the summary of this revision. (Show Details)Jul 28 2023, 5:08 AM
aaron.ballman added inline comments.Jul 28 2023, 7:40 AM
clang/lib/AST/Interp/Interp.cpp
551–555

No need for this given all code paths return false.

However, what should we do for calls to this for something other than a ParmVarDecl? Should we issue a generic note so the constant expression fails but we get notified to the missing cases?

clang/test/AST/Interp/functions.cpp
316–323

I'd like another test along the lines of:

consteval void param(bool b) {
  static_assert(b); // Same error despite this being a consteval function where `b`'s value is always going to be known at compile time
}
tbaeder updated this revision to Diff 545193.Jul 28 2023, 9:21 AM
tbaeder marked an inline comment as done.Jul 28 2023, 9:22 AM
tbaeder added inline comments.
clang/lib/AST/Interp/Interp.cpp
551–555

I think the return false; is basically fine, it will show the usual "is not an integral constant expression" error message, and if there's no other note, we can investigate and improve diagnostics.

This revision is now accepted and ready to land.Aug 2 2023, 6:51 AM
This revision was landed with ongoing or failed builds.Sep 15 2023, 4:17 AM
This revision was automatically updated to reflect the committed changes.