diff --git a/gen/inlineir.cpp b/gen/inlineir.cpp index b0062204915..b9cedfd706d 100644 --- a/gen/inlineir.cpp +++ b/gen/inlineir.cpp @@ -162,9 +162,8 @@ DValue *DtoInlineIRExpr(Loc &loc, FuncDeclaration *fdecl, } stream << "define " << *DtoType(ret) << " @" << mangled_name << "("; - for (size_t i = 0;;) { + for (size_t i = 0; i < arg_types.length; ++i) { Type *ty = isType(arg_types[i]); - // assert(ty); if (!ty) { error(tinst->loc, "All parameters of a template defined with pragma " @@ -172,14 +171,9 @@ DValue *DtoInlineIRExpr(Loc &loc, FuncDeclaration *fdecl, ", should be types"); fatal(); } + if (i != 0) + stream << ", "; stream << *DtoType(ty); - - i++; - if (i >= arg_types.length) { - break; - } - - stream << ", "; } stream << ")\n{\n" << code; diff --git a/tests/codegen/inline_ir_noparams.d b/tests/codegen/inline_ir_noparams.d new file mode 100644 index 00000000000..815d20d1051 --- /dev/null +++ b/tests/codegen/inline_ir_noparams.d @@ -0,0 +1,25 @@ +// RUN: %ldc -O -output-ll -of=%t.ll %s && FileCheck %s < %t.ll + +// CHECK: define {{.*}}11unreachableFZv +void unreachable() +{ + import ldc.llvmasm; + // CHECK-NEXT: unreachable + __ir!("unreachable", void)(); +// CHECK-NEXT: } +} + +extern bool flag; + +// CHECK: define {{.*}}3bar +int bar() +{ + int r = 123; + if (flag) + { + r = 456; + unreachable(); + } + // CHECK: ret i32 123 + return r; +}