fail_modifiers.carbon 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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/interface/no_prelude/fail_modifiers.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/no_prelude/fail_modifiers.carbon
  10. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: ERROR: `abstract` not allowed on `interface` declaration.
  11. // CHECK:STDERR: abstract interface Abstract {
  12. // CHECK:STDERR: ^~~~~~~~
  13. // CHECK:STDERR:
  14. abstract interface Abstract {
  15. }
  16. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: ERROR: `default` not allowed on `interface` declaration.
  17. // CHECK:STDERR: default interface Default;
  18. // CHECK:STDERR: ^~~~~~~
  19. // CHECK:STDERR:
  20. default interface Default;
  21. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: ERROR: `virtual` not allowed on `interface` declaration.
  22. // CHECK:STDERR: virtual interface Virtual {
  23. // CHECK:STDERR: ^~~~~~~
  24. // CHECK:STDERR:
  25. virtual interface Virtual {
  26. }
  27. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+3]]:1: ERROR: `protected` not allowed on `interface` declaration at file scope, `protected` is only allowed on class members.
  28. // CHECK:STDERR: protected interface Protected;
  29. // CHECK:STDERR: ^~~~~~~~~
  30. protected interface Protected;
  31. // CHECK:STDOUT: --- fail_modifiers.carbon
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: constants {
  34. // CHECK:STDOUT: %.1: type = interface_type @Abstract [template]
  35. // CHECK:STDOUT: %Self.1: %.1 = bind_symbolic_name Self 0 [symbolic]
  36. // CHECK:STDOUT: %.2: type = interface_type @Default [template]
  37. // CHECK:STDOUT: %.3: type = interface_type @Virtual [template]
  38. // CHECK:STDOUT: %Self.2: %.3 = bind_symbolic_name Self 0 [symbolic]
  39. // CHECK:STDOUT: %.4: type = interface_type @Protected [template]
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: file {
  43. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  44. // CHECK:STDOUT: .Abstract = %Abstract.decl
  45. // CHECK:STDOUT: .Default = %Default.decl
  46. // CHECK:STDOUT: .Virtual = %Virtual.decl
  47. // CHECK:STDOUT: .Protected = %Protected.decl
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Abstract.decl: type = interface_decl @Abstract [template = constants.%.1] {}
  50. // CHECK:STDOUT: %Default.decl: type = interface_decl @Default [template = constants.%.2] {}
  51. // CHECK:STDOUT: %Virtual.decl: type = interface_decl @Virtual [template = constants.%.3] {}
  52. // CHECK:STDOUT: %Protected.decl: type = interface_decl @Protected [template = constants.%.4] {}
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: interface @Abstract {
  56. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: !members:
  59. // CHECK:STDOUT: .Self = %Self
  60. // CHECK:STDOUT: witness = ()
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: interface @Default;
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: interface @Virtual {
  66. // CHECK:STDOUT: %Self: %.3 = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: !members:
  69. // CHECK:STDOUT: .Self = %Self
  70. // CHECK:STDOUT: witness = ()
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: interface @Protected;
  74. // CHECK:STDOUT: