fail_base_misplaced.carbon 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/fail_base_misplaced.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_base_misplaced.carbon
  10. base class B {}
  11. // CHECK:STDERR: fail_base_misplaced.carbon:[[@LINE+4]]:1: error: `base` declaration outside class
  12. // CHECK:STDERR: extend base: B;
  13. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  14. // CHECK:STDERR:
  15. extend base: B;
  16. fn F() {
  17. // CHECK:STDERR: fail_base_misplaced.carbon:[[@LINE+7]]:3: error: expected expression
  18. // CHECK:STDERR: extend base: B;
  19. // CHECK:STDERR: ^~~~~~
  20. // CHECK:STDERR:
  21. // CHECK:STDERR: fail_base_misplaced.carbon:[[@LINE+3]]:3: error: semantics TODO: `HandleInvalidParse`
  22. // CHECK:STDERR: extend base: B;
  23. // CHECK:STDERR: ^~~~~~
  24. extend base: B;
  25. }
  26. // CHECK:STDOUT: --- fail_base_misplaced.carbon
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: constants {
  29. // CHECK:STDOUT: %B: type = class_type @B [template]
  30. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  31. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  32. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  33. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  34. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: file {}
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: class @B {
  40. // CHECK:STDOUT: %.loc11: <witness> = complete_type_witness %.1 [template = constants.%.2]
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: !members:
  43. // CHECK:STDOUT: .Self = constants.%B
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: fn @F() {
  47. // CHECK:STDOUT: !entry:
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: