collapse.carbon 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. // OK, `const (const i32)` is the same type as `const i32`.
  7. // CHECK:STDERR: collapse.carbon:[[@LINE+3]]:25: `const` applied repeatedly to the same type has no additional effect.
  8. // CHECK:STDERR: fn F(p: const i32**) -> const (const i32)** {
  9. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  10. fn F(p: const i32**) -> const (const i32)** {
  11. return p;
  12. }
  13. // CHECK:STDOUT: --- collapse.carbon
  14. // CHECK:STDOUT:
  15. // CHECK:STDOUT: constants {
  16. // CHECK:STDOUT: %.1: type = const_type i32 [template]
  17. // CHECK:STDOUT: %.2: type = ptr_type const i32 [template]
  18. // CHECK:STDOUT: %.3: type = ptr_type const i32* [template]
  19. // CHECK:STDOUT: }
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: file {
  22. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  23. // CHECK:STDOUT: .F = %F
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT: %F: <function> = fn_decl @F [template] {
  26. // CHECK:STDOUT: %.loc11_9: type = const_type i32 [template = constants.%.1]
  27. // CHECK:STDOUT: %.loc11_18: type = ptr_type const i32 [template = constants.%.2]
  28. // CHECK:STDOUT: %.loc11_19: type = ptr_type const i32* [template = constants.%.3]
  29. // CHECK:STDOUT: %p.loc11_6.1: const i32** = param p
  30. // CHECK:STDOUT: @F.%p: const i32** = bind_name p, %p.loc11_6.1
  31. // CHECK:STDOUT: %.loc11_32: type = const_type i32 [template = constants.%.1]
  32. // CHECK:STDOUT: %.loc11_25: type = const_type const i32 [template = constants.%.1]
  33. // CHECK:STDOUT: %.loc11_42: type = ptr_type const i32 [template = constants.%.2]
  34. // CHECK:STDOUT: %.loc11_43: type = ptr_type const i32* [template = constants.%.3]
  35. // CHECK:STDOUT: %return.var: ref const i32** = var <return slot>
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: fn @F(%p: const i32**) -> const i32** {
  40. // CHECK:STDOUT: !entry:
  41. // CHECK:STDOUT: %p.ref: const i32** = name_ref p, %p
  42. // CHECK:STDOUT: return %p.ref
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: