-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add C++ struct parameter tests with data members #5540
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
Open
bricknerb
wants to merge
6
commits into
carbon-language:trunk
Choose a base branch
from
bricknerb:tests2
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c4b2357
Test C++ structs as parameters and return types as declarations and d…
bricknerb 9c95e51
Fix `fail_todo_import_struct_definition_return_type.carbon` to import…
bricknerb 4f6fc1b
Copy `function.carbon` to `function_param_struct.carbon` as preparati…
bricknerb ea25b65
Keep only struct param tests in `function_param_struct.carbon` and re…
bricknerb 30b79d1
Rename tests given the file context
bricknerb 30e0619
Add C++ struct parameter tests with data members
bricknerb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
264 changes: 264 additions & 0 deletions
264
toolchain/check/testdata/interop/cpp/no_prelude/function_param_struct.carbon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,264 @@ | ||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM | ||
// Exceptions. See /LICENSE for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// AUTOUPDATE | ||
// TIP: To test this file alone, run: | ||
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/no_prelude/function_param_struct.carbon | ||
// TIP: To dump output, run: | ||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/no_prelude/function_param_struct.carbon | ||
|
||
// ============================================================================ | ||
// Declaration | ||
// ============================================================================ | ||
|
||
// --- decl.h | ||
|
||
struct S; | ||
|
||
auto foo(S) -> void; | ||
|
||
// --- fail_todo_import_decl.carbon | ||
|
||
library "[[@TEST_NAME]]"; | ||
|
||
import Cpp library "decl.h"; | ||
|
||
fn F() { | ||
// CHECK:STDERR: fail_todo_import_decl.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: struct S` [SemanticsTodo] | ||
// CHECK:STDERR: Cpp.foo({}); | ||
// CHECK:STDERR: ^~~~~~~ | ||
// CHECK:STDERR: fail_todo_import_decl.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] | ||
// CHECK:STDERR: Cpp.foo({}); | ||
// CHECK:STDERR: ^~~~~~~ | ||
// CHECK:STDERR: | ||
Cpp.foo({}); | ||
} | ||
|
||
// ============================================================================ | ||
// Empty | ||
// ============================================================================ | ||
|
||
// --- empty.h | ||
|
||
struct S {}; | ||
|
||
auto foo(S) -> void; | ||
|
||
// --- fail_todo_import_empty.carbon | ||
|
||
library "[[@TEST_NAME]]"; | ||
|
||
import Cpp library "empty.h"; | ||
|
||
fn F() { | ||
// CHECK:STDERR: fail_todo_import_empty.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: struct S` [SemanticsTodo] | ||
// CHECK:STDERR: Cpp.foo({}); | ||
// CHECK:STDERR: ^~~~~~~ | ||
// CHECK:STDERR: fail_todo_import_empty.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] | ||
// CHECK:STDERR: Cpp.foo({}); | ||
// CHECK:STDERR: ^~~~~~~ | ||
// CHECK:STDERR: | ||
Cpp.foo({}); | ||
} | ||
|
||
// ============================================================================ | ||
// Single data member | ||
// ============================================================================ | ||
|
||
// --- single_data_member.h | ||
|
||
struct D {}; | ||
|
||
struct S { | ||
D d; | ||
}; | ||
|
||
auto foo(S) -> void; | ||
|
||
// --- fail_todo_import_single_data_member.carbon | ||
|
||
library "[[@TEST_NAME]]"; | ||
|
||
import Cpp library "single_data_member.h"; | ||
|
||
fn F() { | ||
// CHECK:STDERR: fail_todo_import_single_data_member.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: struct S` [SemanticsTodo] | ||
// CHECK:STDERR: Cpp.foo({}); | ||
// CHECK:STDERR: ^~~~~~~ | ||
// CHECK:STDERR: fail_todo_import_single_data_member.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] | ||
// CHECK:STDERR: Cpp.foo({}); | ||
// CHECK:STDERR: ^~~~~~~ | ||
// CHECK:STDERR: | ||
Cpp.foo({}); | ||
} | ||
|
||
// ============================================================================ | ||
// Multiple data members | ||
// ============================================================================ | ||
|
||
// --- multiple_data_members.h | ||
|
||
struct D {}; | ||
|
||
struct S { | ||
D d1; | ||
D d2; | ||
D d3; | ||
}; | ||
|
||
auto foo(S) -> void; | ||
|
||
// --- fail_todo_import_multiple_data_members.carbon | ||
|
||
library "[[@TEST_NAME]]"; | ||
|
||
import Cpp library "multiple_data_members.h"; | ||
|
||
fn F() { | ||
// CHECK:STDERR: fail_todo_import_multiple_data_members.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: struct S` [SemanticsTodo] | ||
// CHECK:STDERR: Cpp.foo({}); | ||
// CHECK:STDERR: ^~~~~~~ | ||
// CHECK:STDERR: fail_todo_import_multiple_data_members.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] | ||
// CHECK:STDERR: Cpp.foo({}); | ||
// CHECK:STDERR: ^~~~~~~ | ||
// CHECK:STDERR: | ||
Cpp.foo({}); | ||
} | ||
|
||
// CHECK:STDOUT: --- fail_todo_import_decl.carbon | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: constants { | ||
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete] | ||
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete] | ||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: imports { | ||
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] { | ||
// CHECK:STDOUT: .foo = <error> | ||
// CHECK:STDOUT: import Cpp//... | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: file { | ||
// CHECK:STDOUT: package: <namespace> = namespace [concrete] { | ||
// CHECK:STDOUT: .Cpp = imports.%Cpp | ||
// CHECK:STDOUT: .F = %F.decl | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: %Cpp.import_cpp = import_cpp { | ||
// CHECK:STDOUT: import Cpp "decl.h" | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {} | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: fn @F() { | ||
// CHECK:STDOUT: !entry: | ||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] | ||
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>] | ||
// CHECK:STDOUT: %.loc14: %empty_struct_type = struct_literal () | ||
// CHECK:STDOUT: return | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: --- fail_todo_import_empty.carbon | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: constants { | ||
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete] | ||
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete] | ||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: imports { | ||
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] { | ||
// CHECK:STDOUT: .foo = <error> | ||
// CHECK:STDOUT: import Cpp//... | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: file { | ||
// CHECK:STDOUT: package: <namespace> = namespace [concrete] { | ||
// CHECK:STDOUT: .Cpp = imports.%Cpp | ||
// CHECK:STDOUT: .F = %F.decl | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: %Cpp.import_cpp = import_cpp { | ||
// CHECK:STDOUT: import Cpp "empty.h" | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {} | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: fn @F() { | ||
// CHECK:STDOUT: !entry: | ||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] | ||
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>] | ||
// CHECK:STDOUT: %.loc14: %empty_struct_type = struct_literal () | ||
// CHECK:STDOUT: return | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: --- fail_todo_import_single_data_member.carbon | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: constants { | ||
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete] | ||
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete] | ||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: imports { | ||
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] { | ||
// CHECK:STDOUT: .foo = <error> | ||
// CHECK:STDOUT: import Cpp//... | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: file { | ||
// CHECK:STDOUT: package: <namespace> = namespace [concrete] { | ||
// CHECK:STDOUT: .Cpp = imports.%Cpp | ||
// CHECK:STDOUT: .F = %F.decl | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: %Cpp.import_cpp = import_cpp { | ||
// CHECK:STDOUT: import Cpp "single_data_member.h" | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {} | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: fn @F() { | ||
// CHECK:STDOUT: !entry: | ||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] | ||
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>] | ||
// CHECK:STDOUT: %.loc14: %empty_struct_type = struct_literal () | ||
// CHECK:STDOUT: return | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: --- fail_todo_import_multiple_data_members.carbon | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: constants { | ||
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete] | ||
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete] | ||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: imports { | ||
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] { | ||
// CHECK:STDOUT: .foo = <error> | ||
// CHECK:STDOUT: import Cpp//... | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: file { | ||
// CHECK:STDOUT: package: <namespace> = namespace [concrete] { | ||
// CHECK:STDOUT: .Cpp = imports.%Cpp | ||
// CHECK:STDOUT: .F = %F.decl | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: %Cpp.import_cpp = import_cpp { | ||
// CHECK:STDOUT: import Cpp "multiple_data_members.h" | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {} | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: fn @F() { | ||
// CHECK:STDOUT: !entry: | ||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] | ||
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>] | ||
// CHECK:STDOUT: %.loc14: %empty_struct_type = struct_literal () | ||
// CHECK:STDOUT: return | ||
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bricknerb @geoffromer As a reminder, when adding new tests, please add ranges.
For more information, please see:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Jon!
I believe this new file is actually added in the base PR #5539, which would probably become redundant with #5537.
See #5539 (comment)
I'll update this PR after #5537 is merged.