fail_import_misuses.carbon 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/fail_import_misuses.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_import_misuses.carbon
  12. // --- a.carbon
  13. library "[[@TEST_NAME]]";
  14. class Empty {
  15. }
  16. class Incomplete;
  17. // --- fail_b.carbon
  18. library "[[@TEST_NAME]]";
  19. import library "a";
  20. // CHECK:STDERR: fail_b.carbon:[[@LINE+8]]:1: error: redeclaration of `class Empty` is redundant [RedeclRedundant]
  21. // CHECK:STDERR: class Empty {
  22. // CHECK:STDERR: ^~~~~~~~~~~~~
  23. // CHECK:STDERR: fail_b.carbon:[[@LINE-5]]:1: in import [InImport]
  24. // CHECK:STDERR: a.carbon:4:1: note: previously declared here [RedeclPrevDecl]
  25. // CHECK:STDERR: class Empty {
  26. // CHECK:STDERR: ^~~~~~~~~~~~~
  27. // CHECK:STDERR:
  28. class Empty {
  29. }
  30. // CHECK:STDERR: fail_b.carbon:[[@LINE+8]]:8: error: binding pattern has incomplete type `Incomplete` in name binding declaration [IncompleteTypeInBindingDecl]
  31. // CHECK:STDERR: var a: Incomplete;
  32. // CHECK:STDERR: ^~~~~~~~~~
  33. // CHECK:STDERR: fail_b.carbon:[[@LINE-16]]:1: in import [InImport]
  34. // CHECK:STDERR: a.carbon:7:1: note: class was forward declared here [ClassForwardDeclaredHere]
  35. // CHECK:STDERR: class Incomplete;
  36. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  37. // CHECK:STDERR:
  38. var a: Incomplete;