mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 05:30:13 +03:00
Parse UDAs like template arguments (#14881)
This commit is contained in:
parent
d98f586771
commit
ef1bca90e0
4 changed files with 93 additions and 14 deletions
22
compiler/test/compilable/user_defined_attributes.d
Normal file
22
compiler/test/compilable/user_defined_attributes.d
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
enum Test;
|
||||
|
||||
@true @null @byte int x;
|
||||
@(int) int y;
|
||||
@"test" @`test2` @30 @'a' @__LINE__ void f();
|
||||
|
||||
@Test void h();
|
||||
|
||||
static assert( __traits(getAttributes, x)[0] == true);
|
||||
static assert( __traits(getAttributes, x)[1] == null);
|
||||
static assert(is(__traits(getAttributes, x)[2] == byte));
|
||||
|
||||
static assert(is(__traits(getAttributes, y)[0] == int));
|
||||
|
||||
static assert( __traits(getAttributes, f)[0] == "test");
|
||||
static assert( __traits(getAttributes, f)[1] == "test2");
|
||||
static assert( __traits(getAttributes, f)[2] == 30);
|
||||
static assert( __traits(getAttributes, f)[3] == 'a');
|
||||
static assert( __traits(getAttributes, f)[4] == 6);
|
||||
|
||||
static assert(is(__traits(getAttributes, h)[0] == enum));
|
Loading…
Add table
Add a link
Reference in a new issue