fail_modifiers.carbon 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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/alias/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/alias/no_prelude/fail_modifiers.carbon
  10. class Class {}
  11. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+25]]:1: ERROR: `abstract` not allowed on `alias` declaration.
  12. // CHECK:STDERR: abstract base default final alias A = Class;
  13. // CHECK:STDERR: ^~~~~~~~
  14. // CHECK:STDERR:
  15. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+21]]:10: ERROR: `base` not allowed on declaration with `abstract`.
  16. // CHECK:STDERR: abstract base default final alias A = Class;
  17. // CHECK:STDERR: ^~~~
  18. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+18]]:1: `abstract` previously appeared here.
  19. // CHECK:STDERR: abstract base default final alias A = Class;
  20. // CHECK:STDERR: ^~~~~~~~
  21. // CHECK:STDERR:
  22. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+14]]:15: ERROR: `default` not allowed on declaration with `abstract`.
  23. // CHECK:STDERR: abstract base default final alias A = Class;
  24. // CHECK:STDERR: ^~~~~~~
  25. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+11]]:1: `abstract` previously appeared here.
  26. // CHECK:STDERR: abstract base default final alias A = Class;
  27. // CHECK:STDERR: ^~~~~~~~
  28. // CHECK:STDERR:
  29. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+7]]:23: ERROR: `final` not allowed on declaration with `abstract`.
  30. // CHECK:STDERR: abstract base default final alias A = Class;
  31. // CHECK:STDERR: ^~~~~
  32. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: `abstract` previously appeared here.
  33. // CHECK:STDERR: abstract base default final alias A = Class;
  34. // CHECK:STDERR: ^~~~~~~~
  35. // CHECK:STDERR:
  36. abstract base default final alias A = Class;
  37. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: ERROR: `impl` not allowed on `alias` declaration.
  38. // CHECK:STDERR: impl alias B = Class;
  39. // CHECK:STDERR: ^~~~
  40. // CHECK:STDERR:
  41. impl alias B = Class;
  42. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+3]]:1: ERROR: `extern` not allowed on `alias` declaration.
  43. // CHECK:STDERR: extern alias C = Class;
  44. // CHECK:STDERR: ^~~~~~
  45. extern alias C = Class;
  46. // CHECK:STDOUT: --- fail_modifiers.carbon
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: constants {
  49. // CHECK:STDOUT: %Class: type = class_type @Class [template]
  50. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: file {
  54. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  55. // CHECK:STDOUT: .Class = %Class.decl
  56. // CHECK:STDOUT: .A = %A
  57. // CHECK:STDOUT: .B = %B
  58. // CHECK:STDOUT: .C = %C
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {}
  61. // CHECK:STDOUT: %Class.ref.loc38: type = name_ref Class, %Class.decl [template = constants.%Class]
  62. // CHECK:STDOUT: %A: type = bind_alias A, %Class.decl [template = constants.%Class]
  63. // CHECK:STDOUT: %Class.ref.loc44: type = name_ref Class, %Class.decl [template = constants.%Class]
  64. // CHECK:STDOUT: %B: type = bind_alias B, %Class.decl [template = constants.%Class]
  65. // CHECK:STDOUT: %Class.ref.loc49: type = name_ref Class, %Class.decl [template = constants.%Class]
  66. // CHECK:STDOUT: %C: type = bind_alias C, %Class.decl [template = constants.%Class]
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: class @Class {
  70. // CHECK:STDOUT: !members:
  71. // CHECK:STDOUT: .Self = constants.%Class
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: