Skip to content

[cxx-interop] Support forward declared records inside other records. #34864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions test/Interop/Cxx/class/Inputs/nested-records.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,27 @@ struct HasForwardDeclaredTemplateChild {

// TODO: Nested class templates (SR-13853).

namespace NestedDeclIsAFirstForwardDeclaration {

struct ForwardDeclaresFriend {
friend struct ForwardDeclaredFriend;
friend void takesFriend(struct ForwardDeclaredFriend f);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
friend void takesFriend(struct ForwardDeclaredFriend f);
friend void takesFriend(ForwardDeclaredFriend f);

Not needed in C++.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. This was part of the reproducer, IIRC it didn't crash without it. I can't verify this now that it no longer crashes, but I think we should keep it.

};

struct ForwardDeclaredFriend { };

inline void takesFriend(ForwardDeclaredFriend b) { }

struct HasNestedForwardDeclaration {
struct IsNestedForwardDeclaration;
};

struct HasNestedForwardDeclaration::IsNestedForwardDeclaration {
int a;
};

inline void takesHasNestedForwardDeclaration(HasNestedForwardDeclaration) { }

}

#endif // TEST_INTEROP_CXX_CLASS_INPUTS_NESTED_RECORDS_H
19 changes: 19 additions & 0 deletions test/Interop/Cxx/class/nested-records-module-interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,22 @@
// CHECK: }
// CHECK: init()
// CHECK: }

// CHECK: extension NestedDeclIsAFirstForwardDeclaration {
// CHECK: struct ForwardDeclaresFriend {
// CHECK: init()
// CHECK: }
// CHECK: struct ForwardDeclaredFriend {
// CHECK: init()
// CHECK: }
// CHECK: static func takesFriend(_ b: NestedDeclIsAFirstForwardDeclaration.ForwardDeclaredFriend)
// CHECK: struct HasNestedForwardDeclaration {
// CHECK: struct IsNestedForwardDeclaration {
// CHECK: var a: Int32
// CHECK: init()
// CHECK: init(a: Int32)
// CHECK: }
// CHECK: init()
// CHECK: }
// CHECK: static func takesHasNestedForwardDeclaration(_: NestedDeclIsAFirstForwardDeclaration.HasNestedForwardDeclaration)
// CHECK: }