mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
While forward declarations in impl files are allowed, having one in the impl file is redundant when we also have one in the API file.
104 lines
3.0 KiB
Plaintext
104 lines
3.0 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/none.carbon
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/no_definition_in_impl_file.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/no_definition_in_impl_file.carbon
|
|
|
|
// --- decl_in_api_definition_in_impl.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
class A;
|
|
|
|
// --- decl_in_api_definition_in_impl.impl.carbon
|
|
|
|
impl library "[[@TEST_NAME]]";
|
|
|
|
class A {}
|
|
|
|
// --- use_decl_in_api.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
// --- use_decl_in_api.impl.carbon
|
|
|
|
impl library "[[@TEST_NAME]]";
|
|
|
|
import library "decl_in_api_definition_in_impl";
|
|
|
|
// --- decl_only_in_api.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
class B;
|
|
|
|
// --- decl_only_in_api.impl.carbon
|
|
|
|
impl library "[[@TEST_NAME]]";
|
|
|
|
// --- decl_in_api_decl_in_impl.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
class C;
|
|
|
|
// --- fail_decl_in_api_decl_in_impl.impl.carbon
|
|
|
|
impl library "[[@TEST_NAME]]";
|
|
|
|
// CHECK:STDERR: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE+12]]:1: error: redeclaration of `class C` is redundant [RedeclRedundant]
|
|
// CHECK:STDERR: class C;
|
|
// CHECK:STDERR: ^~~~~~~~
|
|
// CHECK:STDERR: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE-5]]:1: in import [InImport]
|
|
// CHECK:STDERR: decl_in_api_decl_in_impl.carbon:4:1: note: previously declared here [RedeclPrevDecl]
|
|
// CHECK:STDERR: class C;
|
|
// CHECK:STDERR: ^~~~~~~~
|
|
// CHECK:STDERR:
|
|
// CHECK:STDERR: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE+4]]:1: error: no definition found for declaration in impl file [MissingDefinitionInImpl]
|
|
// CHECK:STDERR: class C;
|
|
// CHECK:STDERR: ^~~~~~~~
|
|
// CHECK:STDERR:
|
|
class C;
|
|
|
|
// --- decl_in_api_decl_and_definition_in_impl.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
class D;
|
|
|
|
// --- fail_decl_in_api_decl_and_definition_in_impl.impl.carbon
|
|
|
|
impl library "[[@TEST_NAME]]";
|
|
|
|
// CHECK:STDERR: fail_decl_in_api_decl_and_definition_in_impl.impl.carbon:[[@LINE+8]]:1: error: redeclaration of `class D` is redundant [RedeclRedundant]
|
|
// CHECK:STDERR: class D;
|
|
// CHECK:STDERR: ^~~~~~~~
|
|
// CHECK:STDERR: fail_decl_in_api_decl_and_definition_in_impl.impl.carbon:[[@LINE-5]]:1: in import [InImport]
|
|
// CHECK:STDERR: decl_in_api_decl_and_definition_in_impl.carbon:4:1: note: previously declared here [RedeclPrevDecl]
|
|
// CHECK:STDERR: class D;
|
|
// CHECK:STDERR: ^~~~~~~~
|
|
// CHECK:STDERR:
|
|
class D;
|
|
|
|
class D {}
|
|
|
|
// --- decl_only_in_impl.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
// --- fail_decl_only_in_impl.impl.carbon
|
|
|
|
impl library "[[@TEST_NAME]]";
|
|
|
|
// CHECK:STDERR: fail_decl_only_in_impl.impl.carbon:[[@LINE+4]]:1: error: no definition found for declaration in impl file [MissingDefinitionInImpl]
|
|
// CHECK:STDERR: class E;
|
|
// CHECK:STDERR: ^~~~~~~~
|
|
// CHECK:STDERR:
|
|
class E;
|