mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-24 19:55:11 +00:00
This is the final step in landing the _structural_ updates to diagnostic rendering. The key idea here is that we want the primary diagnostic to have a message clearly explaining the problem and attached to the code that has that problem. This should be the starting point for readers working to address the issue, but is rendered attached to the code snippet in question so errors are always "in context" of the code with the error. Everything else in a diagnostic is an additional label attached to code to explain or help the reader understand the problem in the primary message. Previously, `ContextScope` resulted in some confusion here, as diagnostic consumers turned messages into labels and made the message in the context scope the message. In essence, this isn't a scope with context _for_ a diagnostic (with two exceptions that should probably have been an `AnnotationScope`), but a context within `check` where we have a preferred message for a diagnostic emitted by general purpose code we call into. For example, "class was forward declared here" starts as an error, and then consumers render it as a label to make the message from the context scope the error. We also grew an `AnnotationScope` to handle the contextual information we want to show for a diagnostic (what I would have assumed `ContextScope` actually did). Now we have a `Diagnoser`: code in `check` that can better explain the problem than shared logic it is calling into passes a callback that builds a caller-specific diagnostic. The callee then can attach relevant labels and emit it. Diagnostics no longer store `contexts` and consumers no longer need the logic to restructure things. We move all (but two) of the old contexts to be normal messages emitted in this way, and we move some diagnostics to become labels. Each of the new normal messages corresponds to a new diagnostic kind as usual. Common code following this pattern now _requires_ the `Diagnoser` to be passed (or emit nothing), and this uncovered three places where an empty context was used that made the rendered form miss key information. All three are fixed with new diagnostics, one already covered by tests, and two with TODOs to add test coverage. We also completely remove the old `ContextScope` and `CARBON_DIAGNOSTIC_CONTEXT` and rename `AnnotationScope` to `ContextScope`. It is only used to attach information about when/where a diagnostic occurred. Labels also no longer have categories. What were `Primary` are now `ExtraRange`s on the diagnostic rather than labels. Labels are now always informational. `DeclaredName` now narrows the range of a label when the range is a declaration of a named entity to only be the range of that name. For entities that don't have a declared name, the entire declaration remains the range. The code building and emitting these diagnostics can skip them if the declared location isn't distinct from the diagnostic location. Wording is largely unchanged here so we can just review the _structural_ change. #7991 iterates using this to improve locations and adds missing labels. A subsequent PR will iterate on the wording to increasingly fit within this structural model. This is separated out as a way to review incrementally, and so that subsequently we don't have to review wording improvements that only make sense in a new structure that you cannot see yet. It seems easier to look at the structure here even with awkward wording. Assisted-by: Claude Code
808 lines
42 KiB
Plaintext
808 lines
42 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
|
|
//
|
|
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/primitives.carbon
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/class/import/base.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/class/import/base.carbon
|
|
|
|
// --- derived_to_base_conversion.h
|
|
|
|
class Base {};
|
|
class Derived : public Base {};
|
|
|
|
// --- use_derived_to_base_conversion.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "derived_to_base_conversion.h";
|
|
|
|
//@dump-sem-ir-begin
|
|
fn ConvertPtr(d: Cpp.Derived*) -> Cpp.Base* {
|
|
return d;
|
|
}
|
|
//@dump-sem-ir-end
|
|
|
|
fn AcceptVal(b: Cpp.Base);
|
|
|
|
//@dump-sem-ir-begin
|
|
fn ConvertVal(d: Cpp.Derived) {
|
|
AcceptVal(d);
|
|
}
|
|
//@dump-sem-ir-end
|
|
|
|
// --- static_member.h
|
|
|
|
class StaticBase {
|
|
public:
|
|
static auto base_fn() -> void;
|
|
};
|
|
|
|
class StaticDerived : public StaticBase {
|
|
public:
|
|
static auto derived_fn() -> void;
|
|
};
|
|
|
|
// --- use_static_member.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "static_member.h";
|
|
|
|
fn MyF() {
|
|
//@dump-sem-ir-begin
|
|
Cpp.StaticBase.base_fn();
|
|
Cpp.StaticDerived.base_fn();
|
|
Cpp.StaticDerived.derived_fn();
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
// --- base_field.h
|
|
|
|
struct FieldBase {
|
|
int a;
|
|
int b;
|
|
};
|
|
|
|
struct FieldDerived : FieldBase {
|
|
int b;
|
|
};
|
|
|
|
// --- use_base_field.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "base_field.h";
|
|
|
|
fn AccessDirect(d: Cpp.FieldDerived) -> i32 {
|
|
//@dump-sem-ir-begin
|
|
return d.a;
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
fn AccessQualified(d: Cpp.FieldDerived) -> i32 {
|
|
//@dump-sem-ir-begin
|
|
return d.(Cpp.FieldBase.b);
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
// --- base_method.h
|
|
|
|
struct MethodBase {
|
|
void f() const;
|
|
void g() const;
|
|
};
|
|
|
|
struct MethodDerived : MethodBase {
|
|
void g() const;
|
|
};
|
|
|
|
// --- use_base_method.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "base_method.h";
|
|
|
|
fn CallDirect(d: Cpp.MethodDerived) {
|
|
//@dump-sem-ir-begin
|
|
d.f();
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
fn CallQualified(d: Cpp.MethodDerived) {
|
|
//@dump-sem-ir-begin
|
|
d.(Cpp.MethodBase.g)();
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
fn CallBaseQualifiedByDerived(d: Cpp.MethodDerived, b: Cpp.MethodBase) {
|
|
//@dump-sem-ir-begin
|
|
// `Cpp.MethodDerived.f` names a member of `Cpp.MethodBase`, so we allow
|
|
// that to be used when `self` is a `Cpp.MethodBase` or anything that
|
|
// implicitly converts to `Cpp.MethodBase`, such as `Cpp.MethodDerived`.
|
|
d.(Cpp.MethodDerived.f)();
|
|
b.(Cpp.MethodDerived.f)();
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
// --- multiple_inheritance.h
|
|
|
|
struct A { int a; };
|
|
struct B { int b; };
|
|
struct C : A, B {};
|
|
|
|
struct Empty1 {};
|
|
struct Empty2 {};
|
|
struct OneNonEmptyBase : Empty1, A, Empty2 {};
|
|
struct TwoNonEmptyBases : Empty1, A, B, Empty2 {};
|
|
|
|
struct Polymorphic1 {
|
|
virtual void f();
|
|
};
|
|
struct Polymorphic2 {
|
|
virtual void g();
|
|
};
|
|
struct OnePolymorphicBase : A, B, Polymorphic1, Empty1 {};
|
|
struct TwoPolymorphicBases : Polymorphic1, Polymorphic2 {};
|
|
|
|
// --- fail_todo_use_multiple_inheritance.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "multiple_inheritance.h";
|
|
|
|
fn ConvertA(p: Cpp.C*) -> Cpp.A* {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3
|
|
// CHECK:STDERR: -> │ return p;
|
|
// CHECK:STDERR: · ━━━━┳━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `C*` to `Cpp.A*`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return p;
|
|
}
|
|
|
|
fn ConvertB(p: Cpp.C*) -> Cpp.B* {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3
|
|
// CHECK:STDERR: -> │ return p;
|
|
// CHECK:STDERR: · ━━━━┳━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `C*` to `Cpp.B*`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return p;
|
|
}
|
|
|
|
fn ConvertOneNonEmptyBaseToEmpty1(p: Cpp.OneNonEmptyBase*) -> Cpp.Empty1* {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_multiple_inheritance.carbon:[[@LINE+8]]:3
|
|
// CHECK:STDERR: -> │ return p;
|
|
// CHECK:STDERR: · ┳━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `OneNonEmptyBase*` to
|
|
// CHECK:STDERR: · ┃ `Cpp.Empty1*`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return p;
|
|
}
|
|
|
|
fn ConvertOneNonEmptyBaseToEmpty2(p: Cpp.OneNonEmptyBase*) -> Cpp.Empty2* {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_multiple_inheritance.carbon:[[@LINE+8]]:3
|
|
// CHECK:STDERR: -> │ return p;
|
|
// CHECK:STDERR: · ┳━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `OneNonEmptyBase*` to
|
|
// CHECK:STDERR: · ┃ `Cpp.Empty2*`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return p;
|
|
}
|
|
|
|
fn ConvertTwoNonEmptyBasesToA(p: Cpp.TwoNonEmptyBases*) -> Cpp.A* {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_multiple_inheritance.carbon:[[@LINE+8]]:3
|
|
// CHECK:STDERR: -> │ return p;
|
|
// CHECK:STDERR: · ┳━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `TwoNonEmptyBases*`
|
|
// CHECK:STDERR: · ┃ to `Cpp.A*`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return p;
|
|
}
|
|
|
|
fn ConvertTwoNonEmptyBasesToB(p: Cpp.TwoNonEmptyBases*) -> Cpp.B* {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_multiple_inheritance.carbon:[[@LINE+8]]:3
|
|
// CHECK:STDERR: -> │ return p;
|
|
// CHECK:STDERR: · ┳━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `TwoNonEmptyBases*`
|
|
// CHECK:STDERR: · ┃ to `Cpp.B*`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return p;
|
|
}
|
|
|
|
fn ConvertOnePolymorphicBaseToA(p: Cpp.OnePolymorphicBase*) -> Cpp.A* {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_multiple_inheritance.carbon:[[@LINE+8]]:3
|
|
// CHECK:STDERR: -> │ return p;
|
|
// CHECK:STDERR: · ┳━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `OnePolymorphicBase*`
|
|
// CHECK:STDERR: · ┃ to `Cpp.A*`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return p;
|
|
}
|
|
|
|
fn ConvertOnePolymorphicBaseToB(p: Cpp.OnePolymorphicBase*) -> Cpp.B* {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_multiple_inheritance.carbon:[[@LINE+8]]:3
|
|
// CHECK:STDERR: -> │ return p;
|
|
// CHECK:STDERR: · ┳━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `OnePolymorphicBase*`
|
|
// CHECK:STDERR: · ┃ to `Cpp.B*`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return p;
|
|
}
|
|
|
|
fn ConvertTwoPolymorphicBasesToPolymorphic1(p: Cpp.TwoPolymorphicBases*) -> Cpp.Polymorphic1* {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_multiple_inheritance.carbon:[[@LINE+8]]:3
|
|
// CHECK:STDERR: -> │ return p;
|
|
// CHECK:STDERR: · ┳━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type
|
|
// CHECK:STDERR: · ┃ `TwoPolymorphicBases*` to `Cpp.Polymorphic1*`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return p;
|
|
}
|
|
|
|
fn ConvertTwoPolymorphicBasesToPolymorphic2(p: Cpp.TwoPolymorphicBases*) -> Cpp.Polymorphic2* {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_multiple_inheritance.carbon:[[@LINE+8]]:3
|
|
// CHECK:STDERR: -> │ return p;
|
|
// CHECK:STDERR: · ┳━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type
|
|
// CHECK:STDERR: · ┃ `TwoPolymorphicBases*` to `Cpp.Polymorphic2*`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return p;
|
|
}
|
|
|
|
// --- multiple_inheritance_with_preferred_base.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "multiple_inheritance.h";
|
|
|
|
// If there's only one non-empty base, that's our preferred base class. We can
|
|
// convert to that.
|
|
fn ConvertOneNonEmptyBaseToA(p: Cpp.OneNonEmptyBase*) -> Cpp.A* {
|
|
return p;
|
|
}
|
|
|
|
// If there's only one polymorphic base, that's our preferred base class. We can
|
|
// convert to that.
|
|
fn ConvertOnePolymorphicBaseToPolymorphic1(p: Cpp.OnePolymorphicBase*) -> Cpp.Polymorphic1* {
|
|
return p;
|
|
}
|
|
|
|
// --- virtual_inheritance.h
|
|
|
|
struct VirtA { int a; };
|
|
struct VirtB : virtual VirtA {};
|
|
|
|
void UseB(VirtB * _Nonnull p);
|
|
|
|
// --- use_virtual_inheritance_incomplete.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "virtual_inheritance.h";
|
|
|
|
fn Convert(p: Cpp.VirtB*) {
|
|
// OK, doesn't require `Cpp.VirtB` to be a complete type.
|
|
Cpp.UseB(p);
|
|
}
|
|
|
|
// --- fail_todo_use_virtual_inheritance.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "virtual_inheritance.h";
|
|
|
|
fn Convert(p: Cpp.VirtB*) -> Cpp.VirtA* {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_virtual_inheritance.carbon:[[@LINE+8]]:3
|
|
// CHECK:STDERR: -> │ return p;
|
|
// CHECK:STDERR: · ┳━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `VirtB*` to
|
|
// CHECK:STDERR: · ┃ `Cpp.VirtA*`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return p;
|
|
}
|
|
|
|
// --- diamond.h
|
|
|
|
struct DiamondA {
|
|
int a;
|
|
};
|
|
|
|
struct DiamondB : virtual DiamondA {
|
|
int b;
|
|
};
|
|
|
|
struct DiamondC : virtual DiamondA {
|
|
int c;
|
|
};
|
|
|
|
struct DiamondD : DiamondB, DiamondC {
|
|
int d;
|
|
};
|
|
|
|
// --- fail_todo_use_diamond.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "diamond.h";
|
|
|
|
fn ConvertBA(p: Cpp.DiamondB*) -> Cpp.DiamondA* {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_diamond.carbon:[[@LINE+8]]:3
|
|
// CHECK:STDERR: -> │ return p;
|
|
// CHECK:STDERR: · ┳━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `DiamondB*` to
|
|
// CHECK:STDERR: · ┃ `Cpp.DiamondA*`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return p;
|
|
}
|
|
|
|
fn ConvertCA(p: Cpp.DiamondC*) -> Cpp.DiamondA* {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_diamond.carbon:[[@LINE+8]]:3
|
|
// CHECK:STDERR: -> │ return p;
|
|
// CHECK:STDERR: · ┳━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `DiamondC*` to
|
|
// CHECK:STDERR: · ┃ `Cpp.DiamondA*`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return p;
|
|
}
|
|
|
|
fn ConvertDB(p: Cpp.DiamondD*) -> Cpp.DiamondB* {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_diamond.carbon:[[@LINE+8]]:3
|
|
// CHECK:STDERR: -> │ return p;
|
|
// CHECK:STDERR: · ┳━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `DiamondD*` to
|
|
// CHECK:STDERR: · ┃ `Cpp.DiamondB*`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return p;
|
|
}
|
|
|
|
fn ConvertDC(p: Cpp.DiamondD*) -> Cpp.DiamondC* {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_diamond.carbon:[[@LINE+8]]:3
|
|
// CHECK:STDERR: -> │ return p;
|
|
// CHECK:STDERR: · ┳━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `DiamondD*` to
|
|
// CHECK:STDERR: · ┃ `Cpp.DiamondC*`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return p;
|
|
}
|
|
|
|
fn AccessBA(d: Cpp.DiamondD) -> i32 {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_diamond.carbon:[[@LINE+8]]:11
|
|
// CHECK:STDERR: -> │ return (d as Cpp.DiamondB).b;
|
|
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot convert expression of type `DiamondD` to
|
|
// CHECK:STDERR: · ┃ `Cpp.DiamondB` with `as`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return (d as Cpp.DiamondB).b;
|
|
}
|
|
|
|
fn AccessCA(d: Cpp.DiamondD) -> i32 {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_diamond.carbon:[[@LINE+8]]:11
|
|
// CHECK:STDERR: -> │ return (d as Cpp.DiamondC).b;
|
|
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot convert expression of type `DiamondD` to
|
|
// CHECK:STDERR: · ┃ `Cpp.DiamondC` with `as`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return (d as Cpp.DiamondC).b;
|
|
}
|
|
|
|
fn AccessDB(d: Cpp.DiamondD) -> i32 {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_diamond.carbon:[[@LINE+8]]:10
|
|
// CHECK:STDERR: -> │ return d.b;
|
|
// CHECK:STDERR: · ┳━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `DiamondD` to
|
|
// CHECK:STDERR: · ┃ `Cpp.DiamondB`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return d.b;
|
|
}
|
|
|
|
fn AccessDC(d: Cpp.DiamondD) -> i32 {
|
|
// CHECK:STDERR: ╭─┤ fail_todo_use_diamond.carbon:[[@LINE+8]]:10
|
|
// CHECK:STDERR: -> │ return d.c;
|
|
// CHECK:STDERR: · ┳━━
|
|
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `DiamondD` to
|
|
// CHECK:STDERR: · ┃ `Cpp.DiamondC`
|
|
// CHECK:STDERR: · ┃ [ConversionFailure]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
return d.c;
|
|
}
|
|
|
|
// --- final.h
|
|
|
|
struct FinalA final {};
|
|
|
|
// --- fail_derive_from_final.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "final.h";
|
|
|
|
class B {
|
|
// CHECK:STDERR: ╭─┤ fail_derive_from_final.carbon:[[@LINE+8]]:16
|
|
// CHECK:STDERR: -> │ extend base: Cpp.FinalA;
|
|
// CHECK:STDERR: · ┳━━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: deriving from final type `FinalA`; base type must be
|
|
// CHECK:STDERR: · ┃ an `abstract` or `base` class
|
|
// CHECK:STDERR: · ┃ [BaseIsFinal]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
extend base: Cpp.FinalA;
|
|
}
|
|
|
|
// --- union.h
|
|
|
|
union U {};
|
|
|
|
// --- fail_derive_from_union.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "union.h";
|
|
|
|
class V {
|
|
// CHECK:STDERR: ╭─┤ fail_derive_from_union.carbon:[[@LINE+8]]:16
|
|
// CHECK:STDERR: -> │ extend base: Cpp.U;
|
|
// CHECK:STDERR: · ┳━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: deriving from final type `U`; base type must be an
|
|
// CHECK:STDERR: · ┃ `abstract` or `base` class
|
|
// CHECK:STDERR: · ┃ [BaseIsFinal]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
extend base: Cpp.U;
|
|
}
|
|
|
|
// CHECK:STDOUT: --- use_derived_to_base_conversion.carbon = $use_derived_to_base_conversion
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %Derived: type = class_type @Derived [concrete]
|
|
// CHECK:STDOUT: %ptr.976: type = ptr_type %Derived [concrete]
|
|
// CHECK:STDOUT: %pattern_type.d23: type = pattern_type %ptr.976 [concrete]
|
|
// CHECK:STDOUT: %d.param_patt.9b7: %pattern_type.d23 = value_param_pattern [concrete]
|
|
// CHECK:STDOUT: %d.patt.336: %pattern_type.d23 = wrapper_binding_pattern d, %d.param_patt.9b7 [concrete]
|
|
// CHECK:STDOUT: %Base: type = class_type @Base [concrete]
|
|
// CHECK:STDOUT: %ptr.0e0: type = ptr_type %Base [concrete]
|
|
// CHECK:STDOUT: %.866: Core.Form = init_form %ptr.0e0 [concrete]
|
|
// CHECK:STDOUT: %pattern_type.cb0: type = pattern_type %ptr.0e0 [concrete]
|
|
// CHECK:STDOUT: %return.param_patt.b43: %pattern_type.cb0 = out_param_pattern [concrete]
|
|
// CHECK:STDOUT: %return.patt.363: %pattern_type.cb0 = return_slot_pattern %return.param_patt.b43, %ptr.0e0 [concrete]
|
|
// CHECK:STDOUT: %ConvertPtr.type: type = fn_type @ConvertPtr [concrete]
|
|
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
|
// CHECK:STDOUT: %ConvertPtr: %ConvertPtr.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
|
|
// CHECK:STDOUT: %T.67d: type = symbolic_binding T, 0 [symbolic]
|
|
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.type.20f: type = fn_type @ptr.as.Copy.impl.Op, @ptr.as.Copy.impl(%T.67d) [symbolic]
|
|
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.f12: %ptr.as.Copy.impl.Op.type.20f = struct_value () [symbolic]
|
|
// CHECK:STDOUT: %Copy.impl_witness.39c: <witness> = impl_witness imports.%Copy.impl_witness_table.fb0, @ptr.as.Copy.impl(%Base) [concrete]
|
|
// CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %ptr.0e0, (%Copy.impl_witness.39c) [concrete]
|
|
// CHECK:STDOUT: %Copy.WithSelf.Op.type.e2a: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet) [concrete]
|
|
// CHECK:STDOUT: %.2aa: type = fn_type_with_self_type %Copy.WithSelf.Op.type.e2a, %Copy.facet [concrete]
|
|
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.type.903: type = fn_type @ptr.as.Copy.impl.Op, @ptr.as.Copy.impl(%Base) [concrete]
|
|
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.982: %ptr.as.Copy.impl.Op.type.903 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %ptr.as.Copy.impl.Op.982, @ptr.as.Copy.impl.Op(%Base) [concrete]
|
|
// CHECK:STDOUT: %AcceptVal.type: type = fn_type @AcceptVal [concrete]
|
|
// CHECK:STDOUT: %AcceptVal: %AcceptVal.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %pattern_type.2f5: type = pattern_type %Derived [concrete]
|
|
// CHECK:STDOUT: %d.param_patt.0f5: %pattern_type.2f5 = value_param_pattern [concrete]
|
|
// CHECK:STDOUT: %d.patt.0e6: %pattern_type.2f5 = wrapper_binding_pattern d, %d.param_patt.0f5 [concrete]
|
|
// CHECK:STDOUT: %ConvertVal.type: type = fn_type @ConvertVal [concrete]
|
|
// CHECK:STDOUT: %ConvertVal: %ConvertVal.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
|
|
// CHECK:STDOUT: .Derived = %Derived.decl
|
|
// CHECK:STDOUT: .Base = %Base.decl
|
|
// CHECK:STDOUT: import Cpp//...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [concrete = constants.%Derived] {} {}
|
|
// CHECK:STDOUT: %Base.decl: type = class_decl @Base [concrete = constants.%Base] {} {}
|
|
// CHECK:STDOUT: %Core.import_ref.06a: @ptr.as.Copy.impl.%ptr.as.Copy.impl.Op.type (%ptr.as.Copy.impl.Op.type.20f) = import_ref Core//prelude/parts/copy, loc{{\d+_\d+}}, loaded [symbolic = @ptr.as.Copy.impl.%ptr.as.Copy.impl.Op (constants.%ptr.as.Copy.impl.Op.f12)]
|
|
// CHECK:STDOUT: %Copy.impl_witness_table.fb0 = impl_witness_table (%Core.import_ref.06a), @ptr.as.Copy.impl [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: %ConvertPtr.decl: %ConvertPtr.type = fn_decl @ConvertPtr [concrete = constants.%ConvertPtr] {
|
|
// CHECK:STDOUT: %d.param_patt: %pattern_type.d23 = value_param_pattern [concrete = constants.%d.param_patt.9b7]
|
|
// CHECK:STDOUT: %d.patt: %pattern_type.d23 = wrapper_binding_pattern d, %d.param_patt [concrete = constants.%d.patt.336]
|
|
// CHECK:STDOUT: %return.param_patt: %pattern_type.cb0 = out_param_pattern [concrete = constants.%return.param_patt.b43]
|
|
// CHECK:STDOUT: %return.patt: %pattern_type.cb0 = return_slot_pattern %return.param_patt, %ptr.loc7_43 [concrete = constants.%return.patt.363]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %Cpp.ref.loc7_35: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
|
// CHECK:STDOUT: %Base.ref: type = name_ref Base, imports.%Base.decl [concrete = constants.%Base]
|
|
// CHECK:STDOUT: %ptr.loc7_43: type = ptr_type %Base.ref [concrete = constants.%ptr.0e0]
|
|
// CHECK:STDOUT: %.loc7_43: Core.Form = init_form %ptr.loc7_43 [concrete = constants.%.866]
|
|
// CHECK:STDOUT: %d.param: %ptr.976 = value_param call_param0
|
|
// CHECK:STDOUT: %.loc7_29: type = splice_block %ptr.loc7_29 [concrete = constants.%ptr.976] {
|
|
// CHECK:STDOUT: %Cpp.ref.loc7_18: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
|
// CHECK:STDOUT: %Derived.ref: type = name_ref Derived, imports.%Derived.decl [concrete = constants.%Derived]
|
|
// CHECK:STDOUT: %ptr.loc7_29: type = ptr_type %Derived.ref [concrete = constants.%ptr.976]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %d: %ptr.976 = wrapper_binding d, %d.param
|
|
// CHECK:STDOUT: %return.param: ref %ptr.0e0 = out_param call_param1
|
|
// CHECK:STDOUT: %return: ref %ptr.0e0 = return_slot %return.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %ConvertVal.decl: %ConvertVal.type = fn_decl @ConvertVal [concrete = constants.%ConvertVal] {
|
|
// CHECK:STDOUT: %d.param_patt: %pattern_type.2f5 = value_param_pattern [concrete = constants.%d.param_patt.0f5]
|
|
// CHECK:STDOUT: %d.patt: %pattern_type.2f5 = wrapper_binding_pattern d, %d.param_patt [concrete = constants.%d.patt.0e6]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %d.param: %Derived = value_param call_param0
|
|
// CHECK:STDOUT: %.loc15: type = splice_block %Derived.ref [concrete = constants.%Derived] {
|
|
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
|
// CHECK:STDOUT: %Derived.ref: type = name_ref Derived, imports.%Derived.decl [concrete = constants.%Derived]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %d: %Derived = wrapper_binding d, %d.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @ConvertPtr(%d.param: %ptr.976) -> out %return.param: %ptr.0e0 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %d.ref: %ptr.976 = name_ref d, %d
|
|
// CHECK:STDOUT: %.loc8_11.1: ref %Derived = deref %d.ref
|
|
// CHECK:STDOUT: %.loc8_11.2: ref %Base = class_element_access %.loc8_11.1, element0
|
|
// CHECK:STDOUT: %addr: %ptr.0e0 = addr_of %.loc8_11.2
|
|
// CHECK:STDOUT: %.loc8_11.3: %ptr.0e0 = converted %d.ref, %addr
|
|
// CHECK:STDOUT: %impl.elem0: %.2aa = impl_witness_access constants.%Copy.impl_witness.39c, element0 [concrete = constants.%ptr.as.Copy.impl.Op.982]
|
|
// CHECK:STDOUT: %bound_method.loc8_11.1: <bound method> = bound_method %.loc8_11.3, %impl.elem0
|
|
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @ptr.as.Copy.impl.Op(constants.%Base) [concrete = constants.%ptr.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc8_11.2: <bound method> = bound_method %.loc8_11.3, %specific_fn
|
|
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.call: init %ptr.0e0 = call %bound_method.loc8_11.2(%.loc8_11.3)
|
|
// CHECK:STDOUT: return %ptr.as.Copy.impl.Op.call
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @ConvertVal(%d.param: %Derived) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %AcceptVal.ref: %AcceptVal.type = name_ref AcceptVal, file.%AcceptVal.decl [concrete = constants.%AcceptVal]
|
|
// CHECK:STDOUT: %d.ref: %Derived = name_ref d, %d
|
|
// CHECK:STDOUT: %.loc16_13.1: ref %Base = class_element_access %d.ref, element0
|
|
// CHECK:STDOUT: %.loc16_13.2: ref %Base = converted %d.ref, %.loc16_13.1
|
|
// CHECK:STDOUT: %.loc16_13.3: %Base = acquire_value %.loc16_13.2
|
|
// CHECK:STDOUT: %AcceptVal.call: init %empty_tuple.type = call %AcceptVal.ref(%.loc16_13.3)
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- use_static_member.carbon = $use_static_member
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
|
// CHECK:STDOUT: %StaticBase: type = class_type @StaticBase [concrete]
|
|
// CHECK:STDOUT: %StaticBase.base_fn.cpp_overload_set.type: type = cpp_overload_set_type @StaticBase.base_fn.cpp_overload_set [concrete]
|
|
// CHECK:STDOUT: %StaticBase.base_fn.cpp_overload_set.value: %StaticBase.base_fn.cpp_overload_set.type = cpp_overload_set_value @StaticBase.base_fn.cpp_overload_set [concrete]
|
|
// CHECK:STDOUT: %StaticBase.base_fn.type: type = fn_type @StaticBase.base_fn [concrete]
|
|
// CHECK:STDOUT: %StaticBase.base_fn: %StaticBase.base_fn.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %StaticDerived: type = class_type @StaticDerived [concrete]
|
|
// CHECK:STDOUT: %StaticDerived.base_fn.cpp_overload_set.type: type = cpp_overload_set_type @StaticDerived.base_fn.cpp_overload_set [concrete]
|
|
// CHECK:STDOUT: %StaticDerived.base_fn.cpp_overload_set.value: %StaticDerived.base_fn.cpp_overload_set.type = cpp_overload_set_value @StaticDerived.base_fn.cpp_overload_set [concrete]
|
|
// CHECK:STDOUT: %StaticDerived.derived_fn.cpp_overload_set.type: type = cpp_overload_set_type @StaticDerived.derived_fn.cpp_overload_set [concrete]
|
|
// CHECK:STDOUT: %StaticDerived.derived_fn.cpp_overload_set.value: %StaticDerived.derived_fn.cpp_overload_set.type = cpp_overload_set_value @StaticDerived.derived_fn.cpp_overload_set [concrete]
|
|
// CHECK:STDOUT: %StaticDerived.derived_fn.type: type = fn_type @StaticDerived.derived_fn [concrete]
|
|
// CHECK:STDOUT: %StaticDerived.derived_fn: %StaticDerived.derived_fn.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
|
|
// CHECK:STDOUT: .StaticBase = %StaticBase.decl
|
|
// CHECK:STDOUT: .StaticDerived = %StaticDerived.decl
|
|
// CHECK:STDOUT: import Cpp//...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %StaticBase.decl: type = class_decl @StaticBase [concrete = constants.%StaticBase] {} {}
|
|
// CHECK:STDOUT: %StaticBase.base_fn.cpp_overload_set.value: %StaticBase.base_fn.cpp_overload_set.type = cpp_overload_set_value @StaticBase.base_fn.cpp_overload_set [concrete = constants.%StaticBase.base_fn.cpp_overload_set.value]
|
|
// CHECK:STDOUT: %StaticBase.base_fn.decl: %StaticBase.base_fn.type = fn_decl @StaticBase.base_fn [concrete = constants.%StaticBase.base_fn] {} {}
|
|
// CHECK:STDOUT: %StaticDerived.decl: type = class_decl @StaticDerived [concrete = constants.%StaticDerived] {} {}
|
|
// CHECK:STDOUT: %StaticDerived.base_fn.cpp_overload_set.value: %StaticDerived.base_fn.cpp_overload_set.type = cpp_overload_set_value @StaticDerived.base_fn.cpp_overload_set [concrete = constants.%StaticDerived.base_fn.cpp_overload_set.value]
|
|
// CHECK:STDOUT: %StaticDerived.derived_fn.cpp_overload_set.value: %StaticDerived.derived_fn.cpp_overload_set.type = cpp_overload_set_value @StaticDerived.derived_fn.cpp_overload_set [concrete = constants.%StaticDerived.derived_fn.cpp_overload_set.value]
|
|
// CHECK:STDOUT: %StaticDerived.derived_fn.decl: %StaticDerived.derived_fn.type = fn_decl @StaticDerived.derived_fn [concrete = constants.%StaticDerived.derived_fn] {} {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @MyF() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
|
// CHECK:STDOUT: %StaticBase.ref: type = name_ref StaticBase, imports.%StaticBase.decl [concrete = constants.%StaticBase]
|
|
// CHECK:STDOUT: %base_fn.ref.loc8: %StaticBase.base_fn.cpp_overload_set.type = name_ref base_fn, imports.%StaticBase.base_fn.cpp_overload_set.value [concrete = constants.%StaticBase.base_fn.cpp_overload_set.value]
|
|
// CHECK:STDOUT: %StaticBase.base_fn.call.loc8: init %empty_tuple.type = call imports.%StaticBase.base_fn.decl()
|
|
// CHECK:STDOUT: %Cpp.ref.loc9: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
|
// CHECK:STDOUT: %StaticDerived.ref.loc9: type = name_ref StaticDerived, imports.%StaticDerived.decl [concrete = constants.%StaticDerived]
|
|
// CHECK:STDOUT: %base_fn.ref.loc9: %StaticDerived.base_fn.cpp_overload_set.type = name_ref base_fn, imports.%StaticDerived.base_fn.cpp_overload_set.value [concrete = constants.%StaticDerived.base_fn.cpp_overload_set.value]
|
|
// CHECK:STDOUT: %StaticBase.base_fn.call.loc9: init %empty_tuple.type = call imports.%StaticBase.base_fn.decl()
|
|
// CHECK:STDOUT: %Cpp.ref.loc10: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
|
// CHECK:STDOUT: %StaticDerived.ref.loc10: type = name_ref StaticDerived, imports.%StaticDerived.decl [concrete = constants.%StaticDerived]
|
|
// CHECK:STDOUT: %derived_fn.ref: %StaticDerived.derived_fn.cpp_overload_set.type = name_ref derived_fn, imports.%StaticDerived.derived_fn.cpp_overload_set.value [concrete = constants.%StaticDerived.derived_fn.cpp_overload_set.value]
|
|
// CHECK:STDOUT: %StaticDerived.derived_fn.call: init %empty_tuple.type = call imports.%StaticDerived.derived_fn.decl()
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- use_base_field.carbon = $use_base_field
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %FieldDerived: type = class_type @FieldDerived [concrete]
|
|
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
|
// CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
|
|
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
|
// CHECK:STDOUT: %FieldBase: type = class_type @FieldBase [concrete]
|
|
// CHECK:STDOUT: %FieldBase.elem: type = unbound_element_type %FieldBase, %i32 [concrete]
|
|
// CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.type.a1d: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.3c1: %Int.as.Copy.impl.Op.type.a1d = struct_value () [symbolic]
|
|
// CHECK:STDOUT: %Copy.impl_witness.8af: <witness> = impl_witness imports.%Copy.impl_witness_table.f44, @Int.as.Copy.impl(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %i32, (%Copy.impl_witness.8af) [concrete]
|
|
// CHECK:STDOUT: %Copy.WithSelf.Op.type.f76: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet) [concrete]
|
|
// CHECK:STDOUT: %.2b9: type = fn_type_with_self_type %Copy.WithSelf.Op.type.f76, %Copy.facet [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.type.648: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.cae: %Int.as.Copy.impl.Op.type.648 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.cae, @Int.as.Copy.impl.Op(%int_32) [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
|
|
// CHECK:STDOUT: .FieldDerived = %FieldDerived.decl
|
|
// CHECK:STDOUT: .FieldBase = %FieldBase.decl
|
|
// CHECK:STDOUT: import Cpp//...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %FieldDerived.decl: type = class_decl @FieldDerived [concrete = constants.%FieldDerived] {} {}
|
|
// CHECK:STDOUT: %FieldBase.decl: type = class_decl @FieldBase [concrete = constants.%FieldBase] {} {}
|
|
// CHECK:STDOUT: %Core.import_ref.72f: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.a1d) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.3c1)]
|
|
// CHECK:STDOUT: %Copy.impl_witness_table.f44 = impl_witness_table (%Core.import_ref.72f), @Int.as.Copy.impl [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @AccessDirect(%d.param: %FieldDerived) -> out %return.param: %i32 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %d.ref: %FieldDerived = name_ref d, %d
|
|
// CHECK:STDOUT: %a.ref: %FieldBase.elem = name_ref a, @FieldBase.%field_decl.1 [concrete = @FieldBase.%field_decl.1]
|
|
// CHECK:STDOUT: %.loc8_11.1: ref %FieldBase = class_element_access %d.ref, element0
|
|
// CHECK:STDOUT: %.loc8_11.2: ref %FieldBase = converted %d.ref, %.loc8_11.1
|
|
// CHECK:STDOUT: %.loc8_11.3: ref %i32 = class_element_access %.loc8_11.2, element0
|
|
// CHECK:STDOUT: %.loc8_11.4: %i32 = acquire_value %.loc8_11.3
|
|
// CHECK:STDOUT: %impl.elem0: %.2b9 = impl_witness_access constants.%Copy.impl_witness.8af, element0 [concrete = constants.%Int.as.Copy.impl.Op.cae]
|
|
// CHECK:STDOUT: %bound_method.loc8_11.1: <bound method> = bound_method %.loc8_11.4, %impl.elem0
|
|
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc8_11.2: <bound method> = bound_method %.loc8_11.4, %specific_fn
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i32 = call %bound_method.loc8_11.2(%.loc8_11.4)
|
|
// CHECK:STDOUT: return %Int.as.Copy.impl.Op.call
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @AccessQualified(%d.param: %FieldDerived) -> out %return.param: %i32 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %d.ref: %FieldDerived = name_ref d, %d
|
|
// CHECK:STDOUT: %Cpp.ref.loc14: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
|
// CHECK:STDOUT: %FieldBase.ref: type = name_ref FieldBase, imports.%FieldBase.decl [concrete = constants.%FieldBase]
|
|
// CHECK:STDOUT: %b.ref: %FieldBase.elem = name_ref b, @FieldBase.%field_decl.2 [concrete = @FieldBase.%field_decl.2]
|
|
// CHECK:STDOUT: %.loc14_11.1: ref %FieldBase = class_element_access %d.ref, element0
|
|
// CHECK:STDOUT: %.loc14_11.2: ref %FieldBase = converted %d.ref, %.loc14_11.1
|
|
// CHECK:STDOUT: %.loc14_11.3: ref %i32 = class_element_access %.loc14_11.2, element1
|
|
// CHECK:STDOUT: %.loc14_11.4: %i32 = acquire_value %.loc14_11.3
|
|
// CHECK:STDOUT: %impl.elem0: %.2b9 = impl_witness_access constants.%Copy.impl_witness.8af, element0 [concrete = constants.%Int.as.Copy.impl.Op.cae]
|
|
// CHECK:STDOUT: %bound_method.loc14_11.1: <bound method> = bound_method %.loc14_11.4, %impl.elem0
|
|
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc14_11.2: <bound method> = bound_method %.loc14_11.4, %specific_fn
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i32 = call %bound_method.loc14_11.2(%.loc14_11.4)
|
|
// CHECK:STDOUT: return %Int.as.Copy.impl.Op.call
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- use_base_method.carbon = $use_base_method
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %MethodDerived: type = class_type @MethodDerived [concrete]
|
|
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
|
// CHECK:STDOUT: %MethodBase: type = class_type @MethodBase [concrete]
|
|
// CHECK:STDOUT: %MethodDerived.f.cpp_overload_set.type: type = cpp_overload_set_type @MethodDerived.f.cpp_overload_set [concrete]
|
|
// CHECK:STDOUT: %MethodDerived.f.cpp_overload_set.value: %MethodDerived.f.cpp_overload_set.type = cpp_overload_set_value @MethodDerived.f.cpp_overload_set [concrete]
|
|
// CHECK:STDOUT: %f__carbon_thunk.type: type = fn_type @f__carbon_thunk [concrete]
|
|
// CHECK:STDOUT: %f__carbon_thunk: %f__carbon_thunk.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %MethodBase.g.cpp_overload_set.type: type = cpp_overload_set_type @MethodBase.g.cpp_overload_set [concrete]
|
|
// CHECK:STDOUT: %MethodBase.g.cpp_overload_set.value: %MethodBase.g.cpp_overload_set.type = cpp_overload_set_value @MethodBase.g.cpp_overload_set [concrete]
|
|
// CHECK:STDOUT: %g__carbon_thunk.type: type = fn_type @g__carbon_thunk [concrete]
|
|
// CHECK:STDOUT: %g__carbon_thunk: %g__carbon_thunk.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
|
|
// CHECK:STDOUT: .MethodDerived = %MethodDerived.decl
|
|
// CHECK:STDOUT: .MethodBase = %MethodBase.decl
|
|
// CHECK:STDOUT: import Cpp//...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %MethodDerived.decl: type = class_decl @MethodDerived [concrete = constants.%MethodDerived] {} {}
|
|
// CHECK:STDOUT: %MethodBase.decl: type = class_decl @MethodBase [concrete = constants.%MethodBase] {} {}
|
|
// CHECK:STDOUT: %MethodDerived.f.cpp_overload_set.value: %MethodDerived.f.cpp_overload_set.type = cpp_overload_set_value @MethodDerived.f.cpp_overload_set [concrete = constants.%MethodDerived.f.cpp_overload_set.value]
|
|
// CHECK:STDOUT: %f__carbon_thunk.decl: %f__carbon_thunk.type = fn_decl @f__carbon_thunk [concrete = constants.%f__carbon_thunk] {
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %MethodBase.g.cpp_overload_set.value: %MethodBase.g.cpp_overload_set.type = cpp_overload_set_value @MethodBase.g.cpp_overload_set [concrete = constants.%MethodBase.g.cpp_overload_set.value]
|
|
// CHECK:STDOUT: %g__carbon_thunk.decl: %g__carbon_thunk.type = fn_decl @g__carbon_thunk [concrete = constants.%g__carbon_thunk] {
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @CallDirect(%d.param: %MethodDerived) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %d.ref: %MethodDerived = name_ref d, %d
|
|
// CHECK:STDOUT: %f.ref: %MethodDerived.f.cpp_overload_set.type = name_ref f, imports.%MethodDerived.f.cpp_overload_set.value [concrete = constants.%MethodDerived.f.cpp_overload_set.value]
|
|
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %d.ref, %f.ref
|
|
// CHECK:STDOUT: %.loc8_3.1: ref %MethodBase = class_element_access %d.ref, element0
|
|
// CHECK:STDOUT: %.loc8_3.2: ref %MethodBase = converted %d.ref, %.loc8_3.1
|
|
// CHECK:STDOUT: %.loc8_3.3: %MethodBase = acquire_value %.loc8_3.2
|
|
// CHECK:STDOUT: %f__carbon_thunk.call: init %empty_tuple.type = call imports.%f__carbon_thunk.decl(%.loc8_3.3)
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @CallQualified(%d.param: %MethodDerived) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %d.ref: %MethodDerived = name_ref d, %d
|
|
// CHECK:STDOUT: %Cpp.ref.loc14: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
|
// CHECK:STDOUT: %MethodBase.ref: type = name_ref MethodBase, imports.%MethodBase.decl [concrete = constants.%MethodBase]
|
|
// CHECK:STDOUT: %g.ref: %MethodBase.g.cpp_overload_set.type = name_ref g, imports.%MethodBase.g.cpp_overload_set.value [concrete = constants.%MethodBase.g.cpp_overload_set.value]
|
|
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %d.ref, %g.ref
|
|
// CHECK:STDOUT: %.loc14_3.1: ref %MethodBase = class_element_access %d.ref, element0
|
|
// CHECK:STDOUT: %.loc14_3.2: ref %MethodBase = converted %d.ref, %.loc14_3.1
|
|
// CHECK:STDOUT: %.loc14_3.3: %MethodBase = acquire_value %.loc14_3.2
|
|
// CHECK:STDOUT: %g__carbon_thunk.call: init %empty_tuple.type = call imports.%g__carbon_thunk.decl(%.loc14_3.3)
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @CallBaseQualifiedByDerived(%d.param: %MethodDerived, %b.param: %MethodBase) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %d.ref: %MethodDerived = name_ref d, %d
|
|
// CHECK:STDOUT: %Cpp.ref.loc23: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
|
// CHECK:STDOUT: %MethodDerived.ref.loc23: type = name_ref MethodDerived, imports.%MethodDerived.decl [concrete = constants.%MethodDerived]
|
|
// CHECK:STDOUT: %f.ref.loc23: %MethodDerived.f.cpp_overload_set.type = name_ref f, imports.%MethodDerived.f.cpp_overload_set.value [concrete = constants.%MethodDerived.f.cpp_overload_set.value]
|
|
// CHECK:STDOUT: %bound_method.loc23: <bound method> = bound_method %d.ref, %f.ref.loc23
|
|
// CHECK:STDOUT: %.loc23_3.1: ref %MethodBase = class_element_access %d.ref, element0
|
|
// CHECK:STDOUT: %.loc23_3.2: ref %MethodBase = converted %d.ref, %.loc23_3.1
|
|
// CHECK:STDOUT: %.loc23_3.3: %MethodBase = acquire_value %.loc23_3.2
|
|
// CHECK:STDOUT: %f__carbon_thunk.call.loc23: init %empty_tuple.type = call imports.%f__carbon_thunk.decl(%.loc23_3.3)
|
|
// CHECK:STDOUT: %b.ref: %MethodBase = name_ref b, %b
|
|
// CHECK:STDOUT: %Cpp.ref.loc24: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
|
// CHECK:STDOUT: %MethodDerived.ref.loc24: type = name_ref MethodDerived, imports.%MethodDerived.decl [concrete = constants.%MethodDerived]
|
|
// CHECK:STDOUT: %f.ref.loc24: %MethodDerived.f.cpp_overload_set.type = name_ref f, imports.%MethodDerived.f.cpp_overload_set.value [concrete = constants.%MethodDerived.f.cpp_overload_set.value]
|
|
// CHECK:STDOUT: %bound_method.loc24: <bound method> = bound_method %b.ref, %f.ref.loc24
|
|
// CHECK:STDOUT: %f__carbon_thunk.call.loc24: init %empty_tuple.type = call imports.%f__carbon_thunk.decl(%b.ref)
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|