http://llvm.org/bugs/show_bug.cgi?id=12159
Bug #: 12159
Summary: Feature request: exit funnels
Product: clang
Version: unspecified
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Classification: Unclassified
I would like to propose a language extension that would cause all exits from a
block to funnel through another block (except if an exception were raised
during execution of the block).
Imagine the following syntax:
void f(int b) {
after {
printf("Inside f");
if (b > 0)
return;
printf("Still inside f");
b += 100;
} do {
printf("Leaving f; b is %d", b);
}
}
All code paths that leave the after block normally will enter the following do
block. Exceptions will _not_ enter the do block; if you want to handle
exceptions, you would need to use your language's exception handling syntax.
Note that the variable b is visible within the do block; all variables at the
scope of the after block are visible within the corresponding do block.
I would also like to extend this syntax to functions, to help provide contract
programming features:
after void f(int b) {
int did_log = 0;
if (b > 0)
break;
printf("Logging!");
did_log = 1;
} do {
assert(!b || did_log);
}
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs