fail_extend_cycle.carbon 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  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_extend_cycle.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_extend_cycle.carbon
  12. base class A {
  13. }
  14. base class B {
  15. // This ensures that the compiler treats A as complete.
  16. extend base: A;
  17. }
  18. // CHECK:STDERR: fail_extend_cycle.carbon:[[@LINE+7]]:1: error: redefinition of `class A` [RedeclRedef]
  19. // CHECK:STDERR: base class A {
  20. // CHECK:STDERR: ^~~~~~~~~~~~~~
  21. // CHECK:STDERR: fail_extend_cycle.carbon:[[@LINE-11]]:1: note: previously defined here [RedeclPrevDef]
  22. // CHECK:STDERR: base class A {
  23. // CHECK:STDERR: ^~~~~~~~~~~~~~
  24. // CHECK:STDERR:
  25. base class A {
  26. extend base: A;
  27. // CHECK:STDERR: fail_extend_cycle.carbon:[[@LINE+4]]:10: error: name `C` not found [NameNotFound]
  28. // CHECK:STDERR: var c: C;
  29. // CHECK:STDERR: ^
  30. // CHECK:STDERR:
  31. var c: C;
  32. }