// Test hlfir.parent_comp operation parse, verify (no errors), and unparse. // RUN: fir-opt %s | fir-opt | FileCheck %s func.func @test_scalar(%arg0: !fir.ref>) { %1 = hlfir.parent_comp %arg0 : (!fir.ref>) -> !fir.ref> return } // CHECK-LABEL: func.func @test_scalar( // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref>) { // CHECK: hlfir.parent_comp %[[VAL_0]] : (!fir.ref>) -> !fir.ref> func.func @test_scalar_polymorphic(%arg0: !fir.class>) { %1 = hlfir.parent_comp %arg0 : (!fir.class>) -> !fir.ref> return } // CHECK-LABEL: func.func @test_scalar_polymorphic( // CHECK-SAME: %[[VAL_0:.*]]: !fir.class>) { // CHECK: hlfir.parent_comp %[[VAL_0]] : (!fir.class>) -> !fir.ref> func.func @test_array(%arg0: !fir.ref>>) { %c10 = arith.constant 10 : index %1 = fir.shape %c10 : (index) -> !fir.shape<1> %2 = hlfir.parent_comp %arg0 shape %1 : (!fir.ref>>, !fir.shape<1>) -> !fir.box>> return } // CHECK-LABEL: func.func @test_array( // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref>>) { // CHECK: %[[VAL_1:.*]] = arith.constant 10 : index // CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1> // CHECK: hlfir.parent_comp %[[VAL_0]] shape %[[VAL_2]] : (!fir.ref>>, !fir.shape<1>) -> !fir.box>> func.func @test_array_polymorphic(%arg0: !fir.class>>) { %c10 = arith.constant 10 : index %1 = fir.shape %c10 : (index) -> !fir.shape<1> %2 = hlfir.parent_comp %arg0 shape %1 : (!fir.class>>, !fir.shape<1>) -> !fir.box>> return } // CHECK-LABEL: func.func @test_array_polymorphic( // CHECK-SAME: %[[VAL_0:.*]]: !fir.class>>) { // CHECK: %[[VAL_1:.*]] = arith.constant 10 : index // CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1> // CHECK: hlfir.parent_comp %[[VAL_0]] shape %[[VAL_2]] : (!fir.class>>, !fir.shape<1>) -> !fir.box>>