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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jul 15 15:30:06 UTC 2023


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

--- Comment #8 from Dlang Bot <dlang-bot at dlang.rocks> ---
dlang/dmd pull request #15417 "merge stable" was merged into master:

- 11d8f17c0f0917ed53154577a8cc7b2d5196e909 by Dmytro Katyukha:
  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/15417

--


More information about the Digitalmars-d-bugs mailing list