fail_convert_to_invalid.carbon 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. class C {
  7. // CHECK:STDERR: fail_convert_to_invalid.carbon:[[@LINE+3]]:10: ERROR: Name `NoSuchType` not found.
  8. // CHECK:STDERR: var a: NoSuchType;
  9. // CHECK:STDERR: ^~~~~~~~~~
  10. var a: NoSuchType;
  11. }
  12. fn Make() -> C {
  13. return {.a = 123};
  14. }
  15. // CHECK:STDOUT: --- fail_convert_to_invalid.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %C: type = class_type @C [template]
  19. // CHECK:STDOUT: %.1: i32 = int_literal 123 [template]
  20. // CHECK:STDOUT: %.2: type = struct_type {.a: i32} [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: .C = %C.decl
  27. // CHECK:STDOUT: .Make = %Make
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  30. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  31. // CHECK:STDOUT: %Make: <function> = fn_decl @Make [template] {
  32. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  33. // CHECK:STDOUT: @Make.%return: ref C = var <return slot>
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: class @C {
  38. // CHECK:STDOUT: %NoSuchType.ref: <error> = name_ref NoSuchType, <error> [template = <error>]
  39. // CHECK:STDOUT: %.loc11: <error> = field_decl a, element0 [template]
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: !members:
  42. // CHECK:STDOUT: .Self = constants.%C
  43. // CHECK:STDOUT: .a = %.loc11
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: fn @Make() -> %return: C {
  47. // CHECK:STDOUT: !entry:
  48. // CHECK:STDOUT: %.loc15_16: i32 = int_literal 123 [template = constants.%.1]
  49. // CHECK:STDOUT: %.loc15_19: {.a: i32} = struct_literal (%.loc15_16)
  50. // CHECK:STDOUT: return <error>
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: