Summary: This patch introduces the skeleton of the constexpr interpreter, capable of evaluating a simple constexpr functions consisting of if statements. The interpreter is described in more detail in the RFC. Further patches will add more features. Reviewers: Bigcheese, jfb, rsmith Subscribers: bruno, uenoku, ldionne, Tyker, thegameg, tschuett, dexonsmith, mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64146 llvm-svn: 371834
12 lines
297 B
C++
12 lines
297 B
C++
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fforce-experimental-new-constant-interpreter %s -verify
|
|
// RUN: %clang_cc1 -std=c++17 -fsyntax-only %s -verify
|
|
// expected-no-diagnostics
|
|
|
|
constexpr int cond_then_else(int a, int b) {
|
|
if (a < b) {
|
|
return b - a;
|
|
} else {
|
|
return a - b;
|
|
}
|
|
}
|