fail_collapse.carbon 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/const/fail_collapse.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/const/fail_collapse.carbon
  10. // CHECK:STDERR: fail_collapse.carbon:[[@LINE+4]]:9: WARNING: `const` applied repeatedly to the same type has no additional effect.
  11. // CHECK:STDERR: fn G(p: const (const i32)**) -> i32** {
  12. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  13. // CHECK:STDERR:
  14. fn G(p: const (const i32)**) -> i32** {
  15. // CHECK:STDERR: fail_collapse.carbon:[[@LINE+3]]:3: ERROR: Cannot implicitly convert from `const i32**` to `i32**`.
  16. // CHECK:STDERR: return p;
  17. // CHECK:STDERR: ^~~~~~~~~
  18. return p;
  19. }
  20. // CHECK:STDOUT: --- fail_collapse.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  24. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  25. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  26. // CHECK:STDOUT: %.2: type = const_type i32 [template]
  27. // CHECK:STDOUT: %.3: type = ptr_type %.2 [template]
  28. // CHECK:STDOUT: %.4: type = ptr_type %.3 [template]
  29. // CHECK:STDOUT: %.5: type = ptr_type i32 [template]
  30. // CHECK:STDOUT: %.6: type = ptr_type %.5 [template]
  31. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  32. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  37. // CHECK:STDOUT: .Core = %Core
  38. // CHECK:STDOUT: .G = %G.decl
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  41. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  42. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  43. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  44. // CHECK:STDOUT: %int.make_type_32.loc15_22: init type = call constants.%Int32() [template = i32]
  45. // CHECK:STDOUT: %.loc15_16.1: type = value_of_initializer %int.make_type_32.loc15_22 [template = i32]
  46. // CHECK:STDOUT: %.loc15_16.2: type = converted %int.make_type_32.loc15_22, %.loc15_16.1 [template = i32]
  47. // CHECK:STDOUT: %.loc15_16.3: type = const_type i32 [template = constants.%.2]
  48. // CHECK:STDOUT: %.loc15_9: type = const_type %.2 [template = constants.%.2]
  49. // CHECK:STDOUT: %.loc15_26: type = ptr_type %.2 [template = constants.%.3]
  50. // CHECK:STDOUT: %.loc15_27: type = ptr_type %.3 [template = constants.%.4]
  51. // CHECK:STDOUT: %p.loc15_6.1: %.4 = param p
  52. // CHECK:STDOUT: @G.%p: %.4 = bind_name p, %p.loc15_6.1
  53. // CHECK:STDOUT: %int.make_type_32.loc15_33: init type = call constants.%Int32() [template = i32]
  54. // CHECK:STDOUT: %.loc15_36.1: type = value_of_initializer %int.make_type_32.loc15_33 [template = i32]
  55. // CHECK:STDOUT: %.loc15_36.2: type = converted %int.make_type_32.loc15_33, %.loc15_36.1 [template = i32]
  56. // CHECK:STDOUT: %.loc15_36.3: type = ptr_type i32 [template = constants.%.5]
  57. // CHECK:STDOUT: %.loc15_37: type = ptr_type %.5 [template = constants.%.6]
  58. // CHECK:STDOUT: @G.%return: ref %.6 = var <return slot>
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: fn @G(%p: %.4) -> %.6 {
  65. // CHECK:STDOUT: !entry:
  66. // CHECK:STDOUT: %p.ref: %.4 = name_ref p, %p
  67. // CHECK:STDOUT: return <error>
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT: