nested_const.carbon 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  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: }
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: file {
  21. // CHECK:STDOUT: package: <namespace> = namespace {.F = %F} [template]
  22. // CHECK:STDOUT: %F: <function> = fn_decl @F [template]
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: fn @F(%p: const (const (const i32*)*)) -> const i32 {
  26. // CHECK:STDOUT: !entry:
  27. // CHECK:STDOUT: %p.ref: const (const (const i32*)*) = name_ref p, %p
  28. // CHECK:STDOUT: %.loc9_11.1: ref const (const i32*) = deref %p.ref
  29. // CHECK:STDOUT: %.loc9_11.2: const (const i32*) = bind_value %.loc9_11.1
  30. // CHECK:STDOUT: %.loc9_10.1: ref const i32 = deref %.loc9_11.2
  31. // CHECK:STDOUT: %.loc9_10.2: const i32 = bind_value %.loc9_10.1
  32. // CHECK:STDOUT: return %.loc9_10.2
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: