fail_abstract.carbon 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. abstract class Class {
  7. var k: i32;
  8. }
  9. fn Make() -> Class {
  10. // CHECK:STDERR: fail_abstract.carbon:[[@LINE+3]]:17: ERROR: Cannot construct instance of abstract class. Consider using `partial Class` instead.
  11. // CHECK:STDERR: return {.k = 1};
  12. // CHECK:STDERR: ^
  13. return {.k = 1};
  14. }
  15. // CHECK:STDOUT: constants {
  16. // CHECK:STDOUT: %.loc9: type = struct_type {.k: i32}
  17. // CHECK:STDOUT: %.loc7: type = ptr_type {.k: i32}
  18. // CHECK:STDOUT: }
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: file "fail_abstract.carbon" {
  21. // CHECK:STDOUT: class_decl @Class, ()
  22. // CHECK:STDOUT: %Class: type = class_type @Class
  23. // CHECK:STDOUT: %Make: <function> = fn_decl @Make
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: class @Class {
  27. // CHECK:STDOUT: %.loc8_8.1: type = unbound_field_type Class, i32
  28. // CHECK:STDOUT: %.loc8_8.2: <unbound field of class Class> = field k, member0
  29. // CHECK:STDOUT: %k: <unbound field of class Class> = bind_name k, %.loc8_8.2
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: !members:
  32. // CHECK:STDOUT: .k = %k
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: fn @Make() -> %return: Class {
  36. // CHECK:STDOUT: !entry:
  37. // CHECK:STDOUT: %.loc15_16: i32 = int_literal 1
  38. // CHECK:STDOUT: %.loc15_17: {.k: i32} = struct_literal (%.loc15_16)
  39. // CHECK:STDOUT: return <error>
  40. // CHECK:STDOUT: }