Skip to content
Closed
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
16 changes: 0 additions & 16 deletions src/dmd/attrib.d
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import dmd.dscope;
import dmd.dsymbol;
import dmd.dsymbolsem : dsymbolSemantic;
import dmd.expression;
import dmd.expressionsem : arrayExpressionSemantic;
import dmd.func;
import dmd.globals;
import dmd.hdrgen : protectionToBuffer;
Expand Down Expand Up @@ -1407,21 +1406,6 @@ extern (C++) final class UserAttributeDeclaration : AttribDeclaration
return udas;
}

Expressions* getAttributes()
{
if (auto sc = _scope)
{
_scope = null;
arrayExpressionSemantic(atts, sc);
}
auto exps = new Expressions();
if (userAttribDecl && userAttribDecl !is this)
exps.push(new TupleExp(Loc.initial, userAttribDecl.getAttributes()));
if (atts && atts.dim)
exps.push(new TupleExp(Loc.initial, atts));
return exps;
}

override const(char)* kind() const
{
return "UserAttribute";
Expand Down
3 changes: 2 additions & 1 deletion src/dmd/attrib.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ class UserAttributeDeclaration : public AttribDeclaration
Dsymbol *syntaxCopy(Dsymbol *s);
Scope *newScope(Scope *sc);
void setScope(Scope *sc);
Expressions *getAttributes();
const char *kind() const;
void accept(Visitor *v) { v->visit(this); }
};

Expressions *getAttributes(UserAttributeDeclaration *uad);
15 changes: 15 additions & 0 deletions src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -12337,6 +12337,21 @@ bool checkAddressVar(Scope* sc, Expression exp, VarDeclaration v)
return true;
}

extern (C++) Expressions* getAttributes(UserAttributeDeclaration uad)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it also needs to be in the headers somewhere too.

{
if (auto sc = uad._scope)
{
uad._scope = null;
arrayExpressionSemantic(uad.atts, sc);
}
auto exps = new Expressions();
if (uad.userAttribDecl && uad.userAttribDecl !is uad)
exps.push(new TupleExp(Loc.initial, uad.userAttribDecl.getAttributes()));
if (uad.atts && uad.atts.dim)
exps.push(new TupleExp(Loc.initial, uad.atts));
return exps;
}

/*******************************
* Checks the attributes of a function.
* Purity (`pure`), safety (`@safe`), no GC allocations(`@nogc`)
Expand Down
3 changes: 2 additions & 1 deletion src/dmd/frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -2119,7 +2119,6 @@ class UserAttributeDeclaration : public AttribDeclaration
Dsymbol* syntaxCopy(Dsymbol* s);
Scope* newScope(Scope* sc);
void setScope(Scope* sc);
Array<Expression*>* getAttributes();
Copy link
Contributor

@RazvanN7 RazvanN7 Sep 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably need to add it too here.

const char* kind() const;
void accept(Visitor* v);
static bool isGNUABITag(Expression* e);
Expand Down Expand Up @@ -4615,6 +4614,8 @@ extern Expression* resolveProperties(Scope* sc, Expression* e);

extern Expression* expressionSemantic(Expression* e, Scope* sc);

extern Array<Expression*>* getAttributes(UserAttributeDeclaration* uad);

enum class ILS
{
uninitialized = 0,
Expand Down
11 changes: 11 additions & 0 deletions src/tests/cxxfrontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,16 @@ void test_outbuffer()

/**********************************/

void test_attributes()
{
UserAttributeDeclaration *uad = (UserAttributeDeclaration*)Dsymbol::create(NULL);
assert(uad);
Expressions *e = getAttributes(uad);
assert(e);
}

/**********************************/

int main(int argc, char **argv)
{
frontend_init();
Expand All @@ -479,6 +489,7 @@ int main(int argc, char **argv)
test_location();
test_array();
test_outbuffer();
test_attributes();

frontend_term();

Expand Down