nested_const.carbon 2.5 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. // TODO: The `const` in the return type should not be necessary.
  7. fn F(p: const (const (const i32*)*)) -> const i32 {
  8. return **p;
  9. }
  10. // CHECK:STDOUT: --- nested_const.carbon
  11. // CHECK:STDOUT:
  12. // CHECK:STDOUT: constants {
  13. // CHECK:STDOUT: %.1: type = const_type i32 [template]
  14. // CHECK:STDOUT: %.2: type = ptr_type const i32 [template]
  15. // CHECK:STDOUT: %.3: type = const_type const i32* [template]
  16. // CHECK:STDOUT: %.4: type = ptr_type const (const i32*) [template]
  17. // CHECK:STDOUT: %.5: type = const_type const (const i32*)* [template]
  18. // CHECK:STDOUT: %F: type = fn_type @F [template]
  19. // CHECK:STDOUT: %.6: type = tuple_type () [template]
  20. // CHECK:STDOUT: %struct: F = struct_value () [template]
  21. // CHECK:STDOUT: }
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: file {
  24. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  25. // CHECK:STDOUT: .Core = %Core
  26. // CHECK:STDOUT: .F = %F.decl
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  29. // CHECK:STDOUT: %F.decl: F = fn_decl @F [template = constants.%struct] {
  30. // CHECK:STDOUT: %.loc8_23: type = const_type i32 [template = constants.%.1]
  31. // CHECK:STDOUT: %.loc8_32: type = ptr_type const i32 [template = constants.%.2]
  32. // CHECK:STDOUT: %.loc8_16: type = const_type const i32* [template = constants.%.3]
  33. // CHECK:STDOUT: %.loc8_34: type = ptr_type const (const i32*) [template = constants.%.4]
  34. // CHECK:STDOUT: %.loc8_9: type = const_type const (const i32*)* [template = constants.%.5]
  35. // CHECK:STDOUT: %p.loc8_6.1: const (const (const i32*)*) = param p
  36. // CHECK:STDOUT: @F.%p: const (const (const i32*)*) = bind_name p, %p.loc8_6.1
  37. // CHECK:STDOUT: %.loc8_41: type = const_type i32 [template = constants.%.1]
  38. // CHECK:STDOUT: @F.%return: ref const i32 = var <return slot>
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: fn @F(%p: const (const (const i32*)*)) -> const i32 {
  43. // CHECK:STDOUT: !entry:
  44. // CHECK:STDOUT: %p.ref: const (const (const i32*)*) = name_ref p, %p
  45. // CHECK:STDOUT: %.loc9_11.1: ref const (const i32*) = deref %p.ref
  46. // CHECK:STDOUT: %.loc9_11.2: const (const i32*) = bind_value %.loc9_11.1
  47. // CHECK:STDOUT: %.loc9_10.1: ref const i32 = deref %.loc9_11.2
  48. // CHECK:STDOUT: %.loc9_10.2: const i32 = bind_value %.loc9_10.1
  49. // CHECK:STDOUT: return %.loc9_10.2
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: