58 changes: 58 additions & 0 deletions test/compilable/test9701.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// https://issues.dlang.org/show_bug.cgi?id=9701

template AliasSeq(TList...)
{
alias AliasSeq = TList;
}

enum
{
uda4,
uda5,
uda6,
uda8,
uda9
}

enum Enum
{
value0,
@("uda1") value1,
@("uda2", "uda3", 42) value2,
@uda4 value3,
@uda5 @uda6 value4,
@("uda7") @uda8 value5,
@uda9 @("uda10") value6,
deprecated value7,
deprecated("message") value8,
}

@("uda0")
enum
{
value0,
@("uda1") value1,
@("uda2") @("uda3") value2,
@uda4 value3,
@uda5 @uda6 value4,
@("uda7") @uda8 value5,
@uda9 @("uda10") value6
}

static assert(__traits(getAttributes, Enum.value0).length == 0);
static assert(__traits(getAttributes, Enum.value1) == AliasSeq!("uda1"));
static assert(__traits(getAttributes, Enum.value2) == AliasSeq!("uda2", "uda3", 42));
static assert(__traits(getAttributes, Enum.value3) == AliasSeq!(uda4));
static assert(__traits(getAttributes, Enum.value4) == AliasSeq!(uda5, uda6));
static assert(__traits(getAttributes, Enum.value5) == AliasSeq!("uda7", uda8));
static assert(__traits(getAttributes, Enum.value6) == AliasSeq!(uda9, "uda10"));
static assert(__traits(isDeprecated, Enum.value7));
static assert(__traits(isDeprecated, Enum.value8));

static assert(__traits(getAttributes, value0) == AliasSeq!("uda0"));
static assert(__traits(getAttributes, value1) == AliasSeq!("uda0", "uda1"));
static assert(__traits(getAttributes, value2) == AliasSeq!("uda0", "uda2", "uda3"));
static assert(__traits(getAttributes, value3) == AliasSeq!("uda0", uda4));
static assert(__traits(getAttributes, value4) == AliasSeq!("uda0", uda5, uda6));
static assert(__traits(getAttributes, value5) == AliasSeq!("uda0", "uda7", uda8));
static assert(__traits(getAttributes, value6) == AliasSeq!("uda0", uda9, "uda10"));
26 changes: 17 additions & 9 deletions test/fail_compilation/disable.d
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
/*
TEST_OUTPUT:
---
fail_compilation/disable.d(50): Error: function `disable.DisabledOpAssign.opAssign` is not callable because it is annotated with `@disable`
fail_compilation/disable.d(53): Error: function `disable.DisabledPostblit.opAssign` is not callable because it is annotated with `@disable`
fail_compilation/disable.d(56): Error: function `disable.HasDtor.opAssign` is not callable because it is annotated with `@disable`
fail_compilation/disable.d(60): Error: generated function `disable.Nested!(DisabledOpAssign).Nested.opAssign` is not callable because it is annotated with `@disable`
fail_compilation/disable.d(63): Error: generated function `disable.Nested!(DisabledPostblit).Nested.opAssign` is not callable because it is annotated with `@disable`
fail_compilation/disable.d(66): Error: generated function `disable.Nested!(HasDtor).Nested.opAssign` is not callable because it is annotated with `@disable`
fail_compilation/disable.d(70): Error: generated function `disable.NestedDtor!(DisabledOpAssign).NestedDtor.opAssign` is not callable because it is annotated with `@disable`
fail_compilation/disable.d(73): Error: generated function `disable.NestedDtor!(DisabledPostblit).NestedDtor.opAssign` is not callable because it is annotated with `@disable`
fail_compilation/disable.d(76): Error: generated function `disable.NestedDtor!(HasDtor).NestedDtor.opAssign` is not callable because it is annotated with `@disable`
fail_compilation/disable.d(56): Error: function `disable.DisabledOpAssign.opAssign` cannot be used because it is annotated with `@disable`
fail_compilation/disable.d(59): Error: function `disable.DisabledPostblit.opAssign` cannot be used because it is annotated with `@disable`
fail_compilation/disable.d(62): Error: function `disable.HasDtor.opAssign` cannot be used because it is annotated with `@disable`
fail_compilation/disable.d(66): Error: generated function `disable.Nested!(DisabledOpAssign).Nested.opAssign` cannot be used because it is annotated with `@disable`
fail_compilation/disable.d(69): Error: generated function `disable.Nested!(DisabledPostblit).Nested.opAssign` cannot be used because it is annotated with `@disable`
fail_compilation/disable.d(72): Error: generated function `disable.Nested!(HasDtor).Nested.opAssign` cannot be used because it is annotated with `@disable`
fail_compilation/disable.d(76): Error: generated function `disable.NestedDtor!(DisabledOpAssign).NestedDtor.opAssign` cannot be used because it is annotated with `@disable`
fail_compilation/disable.d(79): Error: generated function `disable.NestedDtor!(DisabledPostblit).NestedDtor.opAssign` cannot be used because it is annotated with `@disable`
fail_compilation/disable.d(82): Error: generated function `disable.NestedDtor!(HasDtor).NestedDtor.opAssign` cannot be used because it is annotated with `@disable`
fail_compilation/disable.d(84): Error: enum member `disable.Enum1.value` cannot be used because it is annotated with `@disable`
---
*/
struct DisabledOpAssign {
Expand Down Expand Up @@ -44,6 +45,11 @@ struct NestedDtor (T)
~this() {}
}

enum Enum1
{
@disable value
}

void main ()
{
DisabledOpAssign o;
Expand Down Expand Up @@ -74,4 +80,6 @@ void main ()

NestedDtor!(HasDtor) ndd;
ndd = NestedDtor!(HasDtor)();

auto v1 = Enum1.value;
}
4 changes: 2 additions & 2 deletions test/fail_compilation/disable_new.d
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
TEST_OUTPUT:
---
fail_compilation/disable_new.d(23): Error: allocator `disable_new.C.new` is not callable because it is annotated with `@disable`
fail_compilation/disable_new.d(24): Error: allocator `disable_new.S.new` is not callable because it is annotated with `@disable`
fail_compilation/disable_new.d(23): Error: allocator `disable_new.C.new` cannot be used because it is annotated with `@disable`
fail_compilation/disable_new.d(24): Error: allocator `disable_new.S.new` cannot be used because it is annotated with `@disable`
---
*/

Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/fail15044.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail15044.d(30): Error: generated function `fail15044.V.opAssign` is not callable because it is annotated with `@disable`
fail_compilation/fail15044.d(30): Error: generated function `fail15044.V.opAssign` cannot be used because it is annotated with `@disable`
---
*/

Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/fail341.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
TEST_OUTPUT:
---
fail_compilation/fail341.d(26): Error: struct `fail341.S` is not copyable because it is annotated with `@disable`
fail_compilation/fail341.d(27): Error: function `fail341.foo` is not callable because it is annotated with `@disable`
fail_compilation/fail341.d(27): Error: function `fail341.foo` cannot be used because it is annotated with `@disable`
---
*/

Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/test17908a.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/test17908a.d(10): Error: function `test17908a.foo` is not callable because it is annotated with `@disable`
fail_compilation/test17908a.d(10): Error: function `test17908a.foo` cannot be used because it is annotated with `@disable`
---
*/

Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/test17908b.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/test17908b.d(13): Error: function `test17908b.foobar` is not callable because it is annotated with `@disable`
fail_compilation/test17908b.d(13): Error: function `test17908b.foobar` cannot be used because it is annotated with `@disable`
---
*/
void foobar() {}
Expand Down
63 changes: 63 additions & 0 deletions test/fail_compilation/test9701.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
TEST_OUTPUT
---
fail_compilation/test9701.d(38): Error: `@safe` is not a valid attribute for enum members
fail_compilation/test9701.d(39): Error: `@system` is not a valid attribute for enum members
fail_compilation/test9701.d(40): Error: `@trusted` is not a valid attribute for enum members
fail_compilation/test9701.d(41): Error: `@nogc` is not a valid attribute for enum members
fail_compilation/test9701.d(42): Error: `pure` is not a valid attribute for enum members
fail_compilation/test9701.d(43): Error: `shared` is not a valid attribute for enum members
fail_compilation/test9701.d(44): Error: `inout` is not a valid attribute for enum members
fail_compilation/test9701.d(45): Error: `immutable` is not a valid attribute for enum members
fail_compilation/test9701.d(46): Error: `const` is not a valid attribute for enum members
fail_compilation/test9701.d(47): Error: `synchronized` is not a valid attribute for enum members
fail_compilation/test9701.d(48): Error: `scope` is not a valid attribute for enum members
fail_compilation/test9701.d(49): Error: `auto` is not a valid attribute for enum members
fail_compilation/test9701.d(50): Error: `ref` is not a valid attribute for enum members
fail_compilation/test9701.d(51): Error: `__gshared` is not a valid attribute for enum members
fail_compilation/test9701.d(52): Error: `final` is not a valid attribute for enum members
fail_compilation/test9701.d(53): Error: `extern` is not a valid attribute for enum members
fail_compilation/test9701.d(54): Error: `export` is not a valid attribute for enum members
fail_compilation/test9701.d(55): Error: `nothrow` is not a valid attribute for enum members
fail_compilation/test9701.d(56): Error: `public` is not a valid attribute for enum members
fail_compilation/test9701.d(57): Error: `private` is not a valid attribute for enum members
fail_compilation/test9701.d(58): Error: `package` is not a valid attribute for enum members
fail_compilation/test9701.d(59): Error: `static` is not a valid attribute for enum members
fail_compilation/test9701.d(60): Error: `static` is not a valid attribute for enum members
fail_compilation/test9701.d(61): Error: `static` is not a valid attribute for enum members
fail_compilation/test9701.d(62): Error: `static` is not a valid attribute for enum members
---
*/

// This test exists to verify that parsing of enum member attributes rejects invalid attributes

// https://issues.dlang.org/show_bug.cgi?id=9701

enum Enum
{
@safe safe,
@system system,
@trusted trusted,
@nogc nogc,
pure pure_,
shared shared_,
inout inout_,
immutable immutable_,
const const_,
synchronized synchronized_,
scope scope_,
auto auto_,
ref ref_,
__gshared __gshared_,
final final_,
extern extern_,
export export_,
nothrow nothrow_,
public public_,
private private_,
package package_,
static static1,
@("a") static static2,
static @("a") static3,
@("a") static @("b") static3,
}
22 changes: 22 additions & 0 deletions test/fail_compilation/test9701b.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
REQUIRED_ARGS: -de
TEST_OUTPUT
---
fail_compilation/test9701b.d(20): Deprecation: enum member `test9701b.Enum.e0` is deprecated
fail_compilation/test9701b.d(21): Deprecation: enum member `test9701b.Enum.e1` is deprecated - message
---
*/

// https://issues.dlang.org/show_bug.cgi?id=9701

enum Enum
{
deprecated e0,
deprecated("message") e1,
}

void main()
{
auto value = Enum.e0;
auto value2 = Enum.e1;
}