Skip to content

Commit

Permalink
Merge pull request #4314 from 9rnsr/fix14010
Browse files Browse the repository at this point in the history
Issue 14010 - Support mangleof property for opaque enum and struct type
  • Loading branch information
yebblies committed Jan 19, 2015
2 parents b33b4ca + e658b4a commit 4675d9e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
23 changes: 15 additions & 8 deletions src/mtype.c
Expand Up @@ -7183,6 +7183,10 @@ Expression *TypeEnum::dotExp(Scope *sc, Expression *e, Identifier *ident, int fl
#if LOGDOTEXP
printf("TypeEnum::dotExp(e = '%s', ident = '%s') '%s'\n", e->toChars(), ident->toChars(), toChars());
#endif
// Bugzilla 14010
if (ident == Id::mangleof)
return getProperty(e->loc, ident, flag);

if (sym->scope)
sym->semantic(sym->scope);
if (!sym->members)
Expand All @@ -7202,8 +7206,7 @@ Expression *TypeEnum::dotExp(Scope *sc, Expression *e, Identifier *ident, int fl
{
if (ident == Id::max ||
ident == Id::min ||
ident == Id::init ||
ident == Id::mangleof)
ident == Id::init)
{
return getProperty(e->loc, ident, flag);
}
Expand Down Expand Up @@ -7425,6 +7428,10 @@ Expression *TypeStruct::dotExp(Scope *sc, Expression *e, Identifier *ident, int
#if LOGDOTEXP
printf("TypeStruct::dotExp(e = '%s', ident = '%s')\n", e->toChars(), ident->toChars());
#endif
// Bugzilla 14010
if (ident == Id::mangleof)
return getProperty(e->loc, ident, flag);

if (!sym->members)
{
error(e->loc, "struct %s is forward referenced", sym->toChars());
Expand Down Expand Up @@ -7987,6 +7994,12 @@ Expression *TypeClass::dotExp(Scope *sc, Expression *e, Identifier *ident, int f
}
}

// Bugzilla 12543
if (ident == Id::__sizeof || ident == Id::__xalignof || ident == Id::mangleof)
{
return Type::getProperty(e->loc, ident, 0);
}

if (ident == Id::tupleof)
{
/* Create a TupleExp
Expand Down Expand Up @@ -8043,12 +8056,6 @@ Expression *TypeClass::dotExp(Scope *sc, Expression *e, Identifier *ident, int f
return e;
}

// Bugzilla 12543
if (ident == Id::__sizeof || ident == Id::__xalignof || ident == Id::mangleof)
{
return Type::getProperty(e->loc, ident, 0);
}

s = sym->search(e->loc, ident);
L1:
if (!s)
Expand Down
10 changes: 9 additions & 1 deletion test/compilable/fwdref12543.d
@@ -1,7 +1,15 @@
// PERMUTE_ARGS:

class C12543;

static assert(C12543.sizeof == (void*).sizeof);
static assert(C12543.alignof == (void*).sizeof);
static assert(C12543.mangleof == "C11fwdref125436C12543");

/***************************************************/
// 13564

enum E14010;
static assert(E14010.mangleof == "E11fwdref125436E14010");

struct S14010;
static assert(S14010.mangleof == "S11fwdref125436S14010");

0 comments on commit 4675d9e

Please sign in to comment.