Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gen/funcgenstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ llvm::CallSite FuncGenState::callOrInvoke(llvm::Value *callee,

// Intrinsics don't support invoking and 'nounwind' functions don't need it.
const bool doesNotThrow =
isNothrow ||
isNothrow || global.params.betterC ||
(calleeFn && (calleeFn->isIntrinsic() || calleeFn->doesNotThrow()));

// calls inside a funclet must be annotated with its value
Expand Down
36 changes: 36 additions & 0 deletions tests/linking/betterc_cleanups.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// RUN: %ldc -betterC -run %s > %t.stdout
// RUN: FileCheck %s < %t.stdout

import core.stdc.stdio;

void notNothrow() { printf("notNothrow\n"); }

struct WithDtor
{
~this() { printf("destructing\n"); }
}

void foo(WithDtor a, bool skip)
{
if (skip)
return;

notNothrow();
}

extern(C) int main()
{
WithDtor a;
scope(exit) printf("exiting\n");

foo(a, true);
// CHECK: destructing

foo(a, false);
// CHECK-NEXT: notNothrow
// CHECK-NEXT: destructing

return 0;
// CHECK-NEXT: exiting
// CHECK-NEXT: destructing
}