This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Avoid emitting warnings for constant destruction.
ClosedPublic

Authored by pkasting on May 2 2023, 7:00 PM.

Diff Detail

Event Timeline

pkasting created this revision.May 2 2023, 7:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2023, 7:00 PM
pkasting requested review of this revision.May 2 2023, 7:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2023, 7:00 PM
rsmith added a comment.May 3 2023, 9:55 AM

I think this would be an interesting test:

struct S {
  /*not constexpr*/ S();
  constexpr ~S() {}
};
S s; // no warning

struct T {
  /*not constexpr*/ T();
  constexpr ~T() { if (b) {} }
  bool b;
};
T t; // expected-warning {{exit-time destructor}}

(For a non-constexpr variable with a constexpr destructor, our behaviour depends on whether the destructor call is a constant expression.)

rsmith accepted this revision.May 3 2023, 9:55 AM

LGTM with the extra test

This revision is now accepted and ready to land.May 3 2023, 9:55 AM
pkasting updated this revision to Diff 519188.May 3 2023, 11:40 AM

Update test per review comments.

Thanks @rsmith; I don't have commit access, so can you land the updated patch for me?

This revision was automatically updated to reflect the committed changes.