mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 21:51:12 +01:00
I guess this technically would also allow code to pass check that hasn't before, and that isn't covered by tests (since it's masked by other failures in the tests that already test this functionality) - should I add another test/add some code to a valid test case? Also, this'll miscompile in lowering, since there's no support there yet - should I do anything about that to make lowering fail in some way? Or is it acceptable that some things just silently mis-lower? (I could add a currently-miscompiling test case too, to demonstrate this? (not sure if the autogenerated tests leave space for comments that would explain that the currently-tested behavior is incorrect?)) Is the addition to EntityWithParamsBase suitable? of course not all functions can be virtual, so it's a wasted bit at the moment for all those cases (though it's free, since it's bitpacked - but as we want to add more bits in there it might not be a scalable solution)? --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
101 lines
3.8 KiB
Plaintext
101 lines
3.8 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
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/virtual_modifiers.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/virtual_modifiers.carbon
|
|
|
|
|
|
base class Base {
|
|
virtual fn H();
|
|
|
|
impl fn I();
|
|
}
|
|
|
|
abstract class Abstract {
|
|
abstract fn J();
|
|
|
|
virtual fn K();
|
|
|
|
impl fn L();
|
|
}
|
|
|
|
// CHECK:STDOUT: --- virtual_modifiers.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %Base: type = class_type @Base [template]
|
|
// CHECK:STDOUT: %H.type: type = fn_type @H [template]
|
|
// CHECK:STDOUT: %.1: type = tuple_type () [template]
|
|
// CHECK:STDOUT: %H: %H.type = struct_value () [template]
|
|
// CHECK:STDOUT: %I.type: type = fn_type @I [template]
|
|
// CHECK:STDOUT: %I: %I.type = struct_value () [template]
|
|
// CHECK:STDOUT: %.2: type = struct_type {} [template]
|
|
// CHECK:STDOUT: %Abstract: type = class_type @Abstract [template]
|
|
// CHECK:STDOUT: %J.type: type = fn_type @J [template]
|
|
// CHECK:STDOUT: %J: %J.type = struct_value () [template]
|
|
// CHECK:STDOUT: %K.type: type = fn_type @K [template]
|
|
// CHECK:STDOUT: %K: %K.type = struct_value () [template]
|
|
// CHECK:STDOUT: %L.type: type = fn_type @L [template]
|
|
// CHECK:STDOUT: %L: %L.type = struct_value () [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
|
// CHECK:STDOUT: import Core//prelude
|
|
// CHECK:STDOUT: import Core//prelude/operators
|
|
// CHECK:STDOUT: import Core//prelude/types
|
|
// CHECK:STDOUT: import Core//prelude/operators/arithmetic
|
|
// CHECK:STDOUT: import Core//prelude/operators/as
|
|
// CHECK:STDOUT: import Core//prelude/operators/bitwise
|
|
// CHECK:STDOUT: import Core//prelude/operators/comparison
|
|
// CHECK:STDOUT: import Core//prelude/types/bool
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .Core = imports.%Core
|
|
// CHECK:STDOUT: .Base = %Base.decl
|
|
// CHECK:STDOUT: .Abstract = %Abstract.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {}
|
|
// CHECK:STDOUT: %Abstract.decl: type = class_decl @Abstract [template = constants.%Abstract] {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Base {
|
|
// CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {}
|
|
// CHECK:STDOUT: %I.decl: %I.type = fn_decl @I [template = constants.%I] {}
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%Base
|
|
// CHECK:STDOUT: .H = %H.decl
|
|
// CHECK:STDOUT: .I = %I.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Abstract {
|
|
// CHECK:STDOUT: %J.decl: %J.type = fn_decl @J [template = constants.%J] {}
|
|
// CHECK:STDOUT: %K.decl: %K.type = fn_decl @K [template = constants.%K] {}
|
|
// CHECK:STDOUT: %L.decl: %L.type = fn_decl @L [template = constants.%L] {}
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%Abstract
|
|
// CHECK:STDOUT: .J = %J.decl
|
|
// CHECK:STDOUT: .K = %K.decl
|
|
// CHECK:STDOUT: .L = %L.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: virtual fn @H();
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: impl fn @I();
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: abstract fn @J();
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: virtual fn @K();
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: impl fn @L();
|
|
// CHECK:STDOUT:
|