D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21219 - Invalid C++ header generated for extern(C++, [class|struct])
Summary: Invalid C++ header generated for extern(C++, [class|struct])
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-09-03 22:52 UTC by moonlightsentinel
Modified: 2020-09-04 06:09 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description moonlightsentinel 2020-09-03 22:52:43 UTC
Example:

===============================================
extern(C++, class) struct ClassFromStruct {}

extern(C++, class) class ClassFromClass {}

extern(C++, struct) struct StructFromStruct {}

extern(C++, struct) class StructFromClass {}
===============================================


dmd  -c -o- -HC missing_class.d
===============================================
// Automatically generated by Digital Mars D Compiler v2092

#pragma once

#include <stddef.h>
#include <stdint.h>


// ignoring non-cpp struct ClassFromStruct because of linkage
class ClassFromClass
{
public:
};

// ignoring non-cpp struct StructFromStruct because of linkage
class StructFromClass
{
public:
};
===============================================

There are mutliple issues here:

- ClassFromStruct and StructFromStruct are missing
- StructFromClass is declared as class.
Comment 1 Dlang Bot 2020-09-03 23:14:15 UTC
@MoonlightSentinel created dlang/dmd pull request #11681 "Fix 21219 - Invalid C++ header generated for extern(C++, [class|struct])" fixing this issue:

- Fix 21219 - Invalid C++ header generated for extern(C++, [class|struct])
  
  Fixed in three steps:
  - recognize that `extern(C++, [class|struct])` means `extern(C++)`
  - select the right identifier based on the `CPPMANGLE`
  - add `public:` if required by `CPPMANGLE`, not the AST type

https://github.com/dlang/dmd/pull/11681
Comment 2 Dlang Bot 2020-09-04 06:09:07 UTC
dlang/dmd pull request #11681 "Fix 21219 - Invalid C++ header generated for extern(C++, [class|struct])" was merged into master:

- 0cce92d5116d5156344faeb64ecdffb405fad493 by MoonlightSentinel:
  Fix 21219 - Invalid C++ header generated for extern(C++, [class|struct])
  
  Fixed in three steps:
  - recognize that `extern(C++, [class|struct])` means `extern(C++)`
  - select the right identifier based on the `CPPMANGLE`
  - add `public:` if required by `CPPMANGLE`, not the AST type

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