[PATCH] D48322: [Sema] Discarded statment should be an evaluatable context

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 2 16:40:39 PDT 2018

erik.pilkington added a comment.

In https://reviews.llvm.org/D48322#1148424, @rsmith wrote:

> 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?

  rC Clang


More information about the cfe-commits mailing list