Skip to content

Commit 3df57d4

Browse files
committed
Disable using named return value(s) with short function body syntax, closes #55
1 parent 2e795d8 commit 3df57d4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

source/cppfront.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,6 +2104,14 @@ class cppfront
21042104
assert(n.expr);
21052105

21062106
if (function_body_start != source_position{}) {
2107+
if (!function_returns.empty() && function_returns.back() != nullptr && function_returns.back() != &single_anon) {
2108+
errors.emplace_back(
2109+
n.position(),
2110+
"a function with named return value(s) must have a full { } body"
2111+
);
2112+
return;
2113+
}
2114+
21072115
printer.print_cpp2(" { ", function_body_start);
21082116
if (!function_void_ret) {
21092117
printer.print_cpp2("return ", n.position());

0 commit comments

Comments
 (0)