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
3 changes: 3 additions & 0 deletions changelog/dmd.enum-function.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
A function with enum storage class is now deprecated, not an error

The error was introduced in 2.105.0.
4 changes: 3 additions & 1 deletion compiler/src/dmd/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -4581,8 +4581,10 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
}
else if (t.ty == Tfunction)
{
/* @@@DEPRECATED_2.115@@@
* change to error, deprecated in 2.105.1 */
if (storage_class & STC.manifest)
error("function cannot have enum storage class");
deprecation("function cannot have enum storage class");

AST.Expression constraint = null;
//printf("%s funcdecl t = %s, storage_class = x%lx\n", loc.toChars(), t.toChars(), storage_class);
Expand Down
9 changes: 5 additions & 4 deletions compiler/test/fail_compilation/enum_function.d
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/*
REQUIRED_ARGS: -de
TEST_OUTPUT:
---
fail_compilation/enum_function.d(10): Error: function cannot have enum storage class
fail_compilation/enum_function.d(11): Error: function cannot have enum storage class
fail_compilation/enum_function.d(12): Error: function cannot have enum storage class
fail_compilation/enum_function.d(13): Error: function cannot have enum storage class
fail_compilation/enum_function.d(11): Deprecation: function cannot have enum storage class
fail_compilation/enum_function.d(12): Deprecation: function cannot have enum storage class
fail_compilation/enum_function.d(13): Deprecation: function cannot have enum storage class
fail_compilation/enum_function.d(14): Deprecation: function cannot have enum storage class
---
*/
enum void f1() { return; }
Expand Down