Skip to content

Commit

Permalink
Fix #15180: [REG2.069.0-b1] Segfault with empty struct used as UDA
Browse files Browse the repository at this point in the history
Thanks to Kenji Hara for the fix.
  • Loading branch information
jacob-carlborg committed Oct 9, 2015
1 parent f09bb06 commit 6efbee2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/objc.d
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
@@ -0,0 +1,7 @@
/************************************************/
// 15180: [REG2.069.0-b1] Segfault with empty struct used as UDA

struct foo { }
@foo bar () { }

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

0 comments on commit 6efbee2

Please sign in to comment.