Skip to content

Commit 91193fc

Browse files
committed
Extend NTTP call test
1 parent ac4d417 commit 91193fc

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎cpp2rust/converter/converter_lib.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <clang/AST/Mangle.h>
99
#include <clang/AST/ParentMapContext.h>
1010
#include <clang/Basic/SourceManager.h>
11+
#include <llvm/Support/ErrorHandling.h>
1112
#include <llvm/Support/Path.h>
1213
#include <llvm/Support/raw_ostream.h>
1314

@@ -767,7 +768,10 @@ std::string GetNamedDeclAsString(const clang::NamedDecl *decl) {
767768

768769
if (name.empty()) {
769770
auto *pdecl = llvm::dyn_cast<clang::ParmVarDecl>(decl);
770-
assert(pdecl && "Unexpected unnamed construct");
771+
if (!pdecl) {
772+
decl->dump();
773+
llvm::report_fatal_error("Unexpected unnamed construct");
774+
}
771775

772776
const auto *fn =
773777
llvm::dyn_cast<clang::FunctionDecl>(pdecl->getDeclContext());

‎tests/unit/lambda_to_fn_ptr.cpp‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ADDITIONAL_COMPILE_FLAGS: -std=c++23
2-
// no-compile
2+
// translation-fail
33
#include <assert.h>
44
#include <stdarg.h>
55

@@ -25,6 +25,8 @@ int main() {
2525
assert(p(2) == 6);
2626

2727
assert(call_nttp<+[](int x) { return x - 1; }>(5) == 4);
28+
assert(call_nttp<+[](int x) { return x * 10; }>(5) == 50);
29+
assert(call_nttp<[](int x) { return x + 100; }>(5) == 105);
2830

2931
auto sum = [](int n, ...) {
3032
va_list ap;

0 commit comments

Comments
 (0)