Skip to content

Commit

Permalink
Merge pull request #432 from andreasfertig/addConstevalTest
Browse files Browse the repository at this point in the history
Add consteval test
  • Loading branch information
andreasfertig authored Feb 3, 2022
2 parents 04a0e33 + ea62717 commit 6a4150e
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2436,6 +2436,8 @@ void CodeGenerator::InsertArg(const AccessSpecDecl* stmt)

void CodeGenerator::InsertArg(const StaticAssertDecl* stmt)
{
LAMBDA_SCOPE_HELPER(CallExpr);

if(!stmt->isFailed()) {
mOutputFormatHelper.Append("/* PASSED: "sv);
} else {
Expand Down
17 changes: 17 additions & 0 deletions tests/ConstevalTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// cmdline:-std=c++20

consteval bool ConstantFun()
{
return true;
}

static_assert(ConstantFun());

struct Test {
consteval bool Fun() { return true; }
};

static_assert(Test{}.Fun());

static_assert([]() consteval { return true; }());

55 changes: 55 additions & 0 deletions tests/ConstevalTest.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// cmdline:-std=c++20

inline consteval bool ConstantFun()
{
return true;
}


/* PASSED: static_assert(ConstantFun()); */


struct Test
{
inline consteval bool Fun()
{
return true;
}

};



/* PASSED: static_assert(Test{}.Fun()); */



class __lambda_16_15
{
public:
inline consteval bool operator()() const
{
return true;
}

using retType_16_15 = bool (*)();
inline /*constexpr */ operator retType_16_15 () const noexcept
{
return __invoke;
};

private:
static inline bool __invoke()
{
return true;
}


public:
// /*constexpr */ __lambda_16_15() = default;

} __lambda_16_15{};

/* PASSED: static_assert(__lambda_16_15.operator()()); */


10 changes: 10 additions & 0 deletions tests/ConstraintAutoParameterTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// cmdline:-std=c++20

template<typename T>
concept C = true;

auto lambda = [](C auto container) { };

int main() {
lambda(4);
}
40 changes: 40 additions & 0 deletions tests/ConstraintAutoParameterTest.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// cmdline:-std=c++20

template<typename T>
concept C = true;


class __lambda_6_15
{
public:
template<C type_parameter_0_0>
inline /*constexpr */ auto operator()(type_parameter_0_0 container) const
{
}

#ifdef INSIGHTS_USE_TEMPLATE
template<>
inline /*constexpr */ void operator()(int container) const
{
}
#endif

private:
template<C type_parameter_0_0>
static inline auto __invoke(type_parameter_0_0 container)
{
}

public:
// /*constexpr */ __lambda_6_15() = default;

};

__lambda_6_15 lambda = __lambda_6_15{};


int main()
{
lambda.operator()(4);
}

0 comments on commit 6a4150e

Please sign in to comment.