Files
carbon-lang/toolchain/check/testdata/interface/fail_add_member_outside_definition.carbon
T
Richard Smith a6f4752a7b Collapse empty braces onto a single line. (#3733)
Don't write out `.members` section at all if it's empty.
2024-02-28 23:21:43 +00:00

78 lines
2.7 KiB
Plaintext

// 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
interface Interface { }
// CHECK:STDERR: fail_add_member_outside_definition.carbon:[[@LINE+3]]:14: ERROR: Out-of-line declaration requires a declaration in scoped entity.
// CHECK:STDERR: fn Interface.F() {}
// CHECK:STDERR: ^
fn Interface.F() {}
// Nesting interfaces like this is not valid, but make sure we don't crash.
interface Outer {
interface Inner {
// CHECK:STDERR: fail_add_member_outside_definition.carbon:[[@LINE+3]]:8: ERROR: Name `Outer` not found.
// CHECK:STDERR: fn Outer.F();
// CHECK:STDERR: ^~~~~
fn Outer.F();
}
// CHECK:STDERR: fail_add_member_outside_definition.carbon:[[@LINE+3]]:12: ERROR: Out-of-line declaration requires a declaration in scoped entity.
// CHECK:STDERR: fn Inner.F();
// CHECK:STDERR: ^
fn Inner.F();
}
// CHECK:STDOUT: --- fail_add_member_outside_definition.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.1: type = interface_type @Interface [template]
// CHECK:STDOUT: %.2: type = interface_type @Outer [template]
// CHECK:STDOUT: %.3: type = interface_type @Inner [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {
// CHECK:STDOUT: .Interface = %Interface.decl
// CHECK:STDOUT: .Outer = %Outer.decl
// CHECK:STDOUT: } [template]
// CHECK:STDOUT: %Interface.decl = interface_decl @Interface {} [template = constants.%.1]
// CHECK:STDOUT: %F: <function> = fn_decl @F.1 {} [template]
// CHECK:STDOUT: %Outer.decl = interface_decl @Outer {} [template = constants.%.2]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: interface @Interface {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .F = file.%F
// CHECK:STDOUT: witness = ()
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: interface @Outer {
// CHECK:STDOUT: %Inner.decl = interface_decl @Inner {} [template = constants.%.3]
// CHECK:STDOUT: %F: <function> = fn_decl @F.2 {} [template]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Inner = %Inner.decl
// CHECK:STDOUT: witness = ()
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: interface @Inner {
// CHECK:STDOUT: %.loc20: <function> = fn_decl @.1 {} [template]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .F = @Outer.%F
// CHECK:STDOUT: witness = ()
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F.1() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @.1();
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F.2();
// CHECK:STDOUT: