This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Discarded statment should be an evaluatable context
ClosedPublic

Authored by erik.pilkington on Jun 19 2018, 6:53 AM.

Details

Summary

The constexpr evaluator was erroring out because these templates weren't defined. Despite being used in a discarded statement, we still need to constexpr evaluate them, which means that we need to instantiate them.

Fixes https://llvm.org/PR37585

Thanks!

Diff Detail

Event Timeline

Hmm, so this will mean that we can have internal linkage declarations marked Used for which there is no definition, and we need to not warn on that.

I think it might be better to avoid marking things used in this case (even though they're still technically odr-used).

Hmm, so this will mean that we can have internal linkage declarations marked Used for which there is no definition, and we need to not warn on that.

I think it might be better to avoid marking things used in this case (even though they're still technically odr-used).

We already return false for discarded statements in isOdrUseContext, so neither MarkVarDeclReferenced nor MarkFunctionReferenced will set Used. With or without this patch, clang doesn't emit -Wundefined-internal for the following code:

static int p();
int main() {
  if constexpr (false) p();
}

Is this what you were concerned about?

rsmith accepted this revision.Jul 3 2018, 2:47 PM

Is this what you were concerned about?

Yes, exactly. Thank you for checking.

This revision is now accepted and ready to land.Jul 3 2018, 2:47 PM
This revision was automatically updated to reflect the committed changes.