;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
;; RUN: wasm-opt %s --safe-heap -S -o - | filecheck %s

;; Test that safe-heap does not crash when the start function calls an imported
;; function. The findCalledFunctions helper transitively walks all called
;; functions from the start, and must skip imported functions which have no body.

(module
  ;; CHECK:      (import "env" "some_import" (func $import))
  (import "env" "some_import" (func $import))
  (memory 1 1)

  ;; CHECK:      (start $start)
  (start $start)

  ;; CHECK:      (func $start
  ;; CHECK-NEXT:  (call $import)
  ;; CHECK-NEXT: )
  (func $start
    ;; The start function calls an imported function. Previously this would
    ;; crash because findCalledFunctions would try to walk the null body of
    ;; the imported function.
    (call $import)
  )
)
