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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 5 11:00:53 UTC 2023


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

--- Comment #5 from Dlang Bot <dlang-bot at dlang.rocks> ---
dlang/dmd pull request #15365 "ImportC: Issue 24022 - Error: attribute
`__anonymous` is used as a type" was merged into stable:

- 0c004d2fb731b063cfb2523d67f5d107987915a5 by Dmytro Katyukha:
  Implement test case for Issue 24022

- 32744ee558c39930c30bd88a2bff725e72761a78 by Dmytro Katyukha:
  [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/15365

--


More information about the Digitalmars-d-bugs mailing list