new_and_delete_class.carbon 498 B

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