[all-commits] [llvm/llvm-project] b06305: [Diagnostics] Warn for std::is_constant_evaluated ...

Dávid Bolvanský via All-commits all-commits at lists.llvm.org
Thu Oct 31 02:03:51 PDT 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b06305e44949fb843310d27b139e5064b214a838
      https://github.com/llvm/llvm-project/commit/b06305e44949fb843310d27b139e5064b214a838
  Author: Dávid Bolvanský <david.bolvansky at gmail.com>
  Date:   2019-10-31 (Thu, 31 Oct 2019)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticASTKinds.td
    M clang/lib/AST/ExprConstant.cpp
    M clang/test/SemaCXX/builtin-is-constant-evaluated.cpp
    A clang/test/SemaCXX/warn-constant-evaluated-constexpr.cpp

  Log Message:
  -----------
  [Diagnostics] Warn for std::is_constant_evaluated in constexpr mode

Summary:
constexpr int fn1() {
  if constexpr (std::is_constant_evaluated()) // condition is always true!
    return 0;
  else
    return 1;
}

constexpr int fn2() {
  if (std::is_constant_evaluated())
    return 0;
  else
    return 1;
}

Solves PR42977

Reviewers: rsmith, aaron.ballman

Reviewed By: rsmith

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69518




More information about the All-commits mailing list