[all-commits] [llvm/llvm-project] ab2ca8: consteval if does not form a discarded statement

Aaron Ballman via All-commits all-commits at lists.llvm.org
Wed Oct 20 04:25:11 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ab2ca8496d54573de1c8bec204009567ba2b4086
      https://github.com/llvm/llvm-project/commit/ab2ca8496d54573de1c8bec204009567ba2b4086
  Author: Aaron Ballman <aaron at aaronballman.com>
  Date:   2021-10-20 (Wed, 20 Oct 2021)

  Changed paths:
    M clang/lib/Parse/ParseStmt.cpp
    A clang/test/SemaCXX/cxx2b-consteval-if.cpp

  Log Message:
  -----------
  consteval if does not form a discarded statement

When we added support for if consteval, we accidentally formed a discarded
statement evaluation context for the branch-not-taken. However, a discarded
statement is a property of an if constexpr statement, not an if consteval
statement (https://eel.is/c++draft/stmt.if#2.sentence-2). This turned out to
cause issues when deducing the return type from a function with a consteval if
statement -- we wouldn't consider the branch-not-taken when deducing the return
type.

This fixes PR52206.

Note, there is additional work left to be done. We need to track discarded
statement and immediate evaluation contexts separately rather than as being
mutually exclusive.




More information about the All-commits mailing list