mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add namespace-scoped private keyword support. (#4026)
Adds access to the name lookup table in name scopes. This is so that we can quickly check access during name lookup without resolving the entity itself. Does this for names in general, but does not implement handling for entity-scoped names, only namespace-scoped names (where they're essentially just not exported). Excludes `private` names from exports. Although names should be accessible to `impl` files, that's not implemented here because we'll probably want to do it by directly copying name lookup tables.
This commit is contained in:
+1
-5
@@ -34,10 +34,6 @@ default protected fn WrongOrder();
|
||||
// CHECK:STDERR:
|
||||
virtual virtual fn DuplicateVirtual() {}
|
||||
|
||||
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+11]]:1: ERROR: Semantics TODO: `access modifier`.
|
||||
// CHECK:STDERR: private protected fn TwoAccess();
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+7]]:9: ERROR: `protected` not allowed on declaration with `private`.
|
||||
// CHECK:STDERR: private protected fn TwoAccess();
|
||||
// CHECK:STDERR: ^~~~~~~~~
|
||||
@@ -122,7 +118,7 @@ extern private fn ExternOrderAndConflict() {}
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .WrongOrder = %WrongOrder.decl
|
||||
// CHECK:STDOUT: .DuplicateVirtual = %DuplicateVirtual.decl
|
||||
// CHECK:STDOUT: .TwoAccess = %TwoAccess.decl
|
||||
// CHECK:STDOUT: .TwoAccess [private] = %TwoAccess.decl
|
||||
// CHECK:STDOUT: .ModifiersConflict = %ModifiersConflict.decl
|
||||
// CHECK:STDOUT: .InvalidModifier = %InvalidModifier.decl
|
||||
// CHECK:STDOUT: .ModifiersConflict2 = %ModifiersConflict2.decl
|
||||
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
// 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/function/declaration/no_prelude/fail_todo_modifiers.carbon
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/no_prelude/fail_todo_modifiers.carbon
|
||||
|
||||
// CHECK:STDERR: fail_todo_modifiers.carbon:[[@LINE+3]]:1: ERROR: Semantics TODO: `access modifier`.
|
||||
// CHECK:STDERR: private fn F();
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
private fn F();
|
||||
|
||||
// CHECK:STDOUT: --- fail_todo_modifiers.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %F: type = fn_type @F [template]
|
||||
// CHECK:STDOUT: %.1: type = tuple_type () [template]
|
||||
// CHECK:STDOUT: %struct: F = struct_value () [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .F = %F.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %F.decl: F = fn_decl @F [template = constants.%struct] {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @F();
|
||||
// CHECK:STDOUT:
|
||||
Reference in New Issue
Block a user