[Issue 24022] ImportC: Error: attribute `__anonymous` is used as a type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 12 14:41:29 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=24022

--- Comment #6 from Dlang Bot <dlang-bot at dlang.rocks> ---
@RazvanN7 updated dlang/dmd pull request #15406 "Fix Issue 23951 -
traits(getMember) does not follow alias this" mentioning this issue:

- ImportC: Issue 24022 - Error: attribute `__anonymous` is used as a type
(#15365)

  * Implement test case for Issue 24022

  * [FIX] Issue 24022

  Bug investigation info
  ======================

  Currently (before this fix) on attempt to use `enum`
  declared as `typedef enum {A=1} E;` as type of argument in D function,
  it (`enum`) will be resolved as `kind=attribute` on during semantic
  analysis for D
 
([typesem.d](https://github.com/dlang/dmd/blob/5e1e97078faff33afbb999bc986ead7bdb0b2653/compiler/src/dmd/typesem.d#L1504)),
  but it have to be resolved as type.

  The `enum` declared this way is handled by this
 
[code](https://github.com/dlang/dmd/blob/5e1e97078faff33afbb999bc986ead7bdb0b2653/compiler/src/dmd/cparse.d#L1907),
  and `declareTag` returns the attribute instead of type, but
  later, there is [code that create alias for
attribute](https://github.com/dlang/dmd/blob/5e1e97078faff33afbb999bc986ead7bdb0b2653/compiler/src/dmd/cparse.d#L1918C29-L1918C79),
  though, it seems, that alias have to be created to type, instead of
attribute.

  Investigating
 
[declareTag](https://github.com/dlang/dmd/blob/5e1e97078faff33afbb999bc986ead7bdb0b2653/compiler/src/dmd/cparse.d#L1715)
  function shows that the returned value changed by call to
[applySpecifier](https://github.com/dlang/dmd/blob/5e1e97078faff33afbb999bc986ead7bdb0b2653/compiler/src/dmd/cparse.d#L5234),
  that applies `AlignDeclaration` when `if
  (!specifier.packalign.isDefault())`.

  Fix info
  ========

  With this commit the alias will be created to TypeTag, instead of
  attribute produced by declared tag.

  Also, the code simplified, because there is no more need for special
  handling of enums in modified piece of code.

https://github.com/dlang/dmd/pull/15406

--


More information about the Digitalmars-d-bugs mailing list