Showing with 13 additions and 4 deletions.
  1. +6 −4 src/objc.d
  2. +7 −0 test/compilable/uda.d
10 changes: 6 additions & 4 deletions src/objc.d
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,24 @@ extern (C++) void objc_InterfaceDeclaration_semantic_objcExtern(InterfaceDeclara
// MARK: semantic
extern (C++) void objc_FuncDeclaration_semantic_setSelector(FuncDeclaration fd, Scope* sc)
{
import ddmd.tokens;

if (!fd.userAttribDecl)
return;
Expressions* udas = fd.userAttribDecl.getAttributes();
arrayExpressionSemantic(udas, sc, true);
for (size_t i = 0; i < udas.dim; i++)
{
Expression uda = (*udas)[i];
assert(uda.type);
if (uda.type.ty != Ttuple)
assert(uda);
if (uda.op != TOKtuple)
continue;
Expressions* exps = (cast(TupleExp)uda).exps;
for (size_t j = 0; j < exps.dim; j++)
{
Expression e = (*exps)[j];
assert(e.type);
if (e.type.ty != Tstruct)
assert(e);
if (e.op != TOKstructliteral)
continue;
StructLiteralExp literal = cast(StructLiteralExp)e;
assert(literal.sd);
Expand Down
7 changes: 7 additions & 0 deletions test/compilable/uda.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/************************************************/
// 15180: [REG2.069.0-b1] Segfault with empty struct used as UDA

struct foo { }
@foo bar () { }

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