new_and_delete_class.carbon 497 B

123456789101112131415161718192021
  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. // CHECK:STDOUT: result: 0
  7. package ExplorerTest api;
  8. class C {
  9. fn DoPrint() { Print("test"); }
  10. }
  11. fn Main() -> i32 {
  12. var p: auto = heap.New(C);
  13. var y: auto = *p;
  14. // The following line would fail with: "could not find `y: auto`"
  15. // y.DoPrint();
  16. heap.Delete(p);
  17. return 0;
  18. }