fix Issue 23913 - __traits(getMember) fails for some C symbols (#15234)

This commit is contained in:
Walter Bright 2023-05-16 00:07:19 -07:00 committed by GitHub
parent 2a650f7609
commit 16ec7b681b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 1 deletions

View file

@ -13175,10 +13175,20 @@ Expression dotIdSemanticProp(DotIdExp exp, Scope* sc, bool gag)
Expression se = new ScopeExp(exp.loc, imp.pkg);
return se.expressionSemantic(sc);
}
if (auto attr = s.isAttribDeclaration())
{
if (auto sm = ie.sds.search(exp.loc, exp.ident, flags))
{
auto es = new DsymbolExp(exp.loc, sm);
return es;
}
}
// BUG: handle other cases like in IdentifierExp::semantic()
debug
{
printf("s = '%s', kind = '%s'\n", s.toChars(), s.kind());
printf("s = %p '%s', kind = '%s'\n", s, s.toChars(), s.kind());
}
assert(0);
}

View file

@ -0,0 +1,5 @@
typedef enum SomeEnum
{
foo = 0,
bar = -10000,
} SomeEnum;

View file

@ -0,0 +1,7 @@
// EXTRA_FILES: imports/library.c
// https://issues.dlang.org/show_bug.cgi?id=23913
import imports.library;
alias x = __traits(getMember, imports.library, "SomeEnum");