From b2768cb37be1ad207fd23cea3006586eeab2b49d Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Fri, 11 Aug 2023 10:40:17 +0100 Subject: [PATCH 1/2] Make enum function a deprecation, not an error --- changelog/dmd.enum-function.dd | 3 +++ compiler/src/dmd/parse.d | 4 +++- compiler/test/fail_compilation/enum_function.d | 9 +++++---- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 changelog/dmd.enum-function.dd diff --git a/changelog/dmd.enum-function.dd b/changelog/dmd.enum-function.dd new file mode 100644 index 000000000000..5caf34d24e4b --- /dev/null +++ b/changelog/dmd.enum-function.dd @@ -0,0 +1,3 @@ +A function with enum storage class is now deprecated, not an error + +The error was introduced in 2.105.0. diff --git a/compiler/src/dmd/parse.d b/compiler/src/dmd/parse.d index d15e448150fa..0a154da08868 100644 --- a/compiler/src/dmd/parse.d +++ b/compiler/src/dmd/parse.d @@ -4581,8 +4581,10 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer } else if (t.ty == Tfunction) { + /* @@@DEPRECATED_2.105.1@@@ + * change to error */ 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); diff --git a/compiler/test/fail_compilation/enum_function.d b/compiler/test/fail_compilation/enum_function.d index b22f2ceccef7..52b71d12f5d9 100644 --- a/compiler/test/fail_compilation/enum_function.d +++ b/compiler/test/fail_compilation/enum_function.d @@ -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; } From d3a03da858c7ad4e375d3a42fda8c908a1bacf85 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Fri, 11 Aug 2023 10:48:53 +0100 Subject: [PATCH 2/2] Fix error date --- compiler/src/dmd/parse.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/dmd/parse.d b/compiler/src/dmd/parse.d index 0a154da08868..a42cc14664b9 100644 --- a/compiler/src/dmd/parse.d +++ b/compiler/src/dmd/parse.d @@ -4581,8 +4581,8 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer } else if (t.ty == Tfunction) { - /* @@@DEPRECATED_2.105.1@@@ - * change to error */ + /* @@@DEPRECATED_2.115@@@ + * change to error, deprecated in 2.105.1 */ if (storage_class & STC.manifest) deprecation("function cannot have enum storage class");