brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · f9da150 Raw
74 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc1 -Werror2! Catch discrepancies between implicit result types and a global definition,3! allowing for derived types and type equivalence.4 5module m6  type t17    integer n8  end type9  type t210    real a11  end type12  type t313    sequence14    integer n15  end type16end17 18function xfunc1()19  use m20  type(t1) xfunc121  xfunc1%n = 12322end23 24function yfunc1()25  use m26  type(t1) yfunc127  yfunc1%n = 12328end29 30function zfunc1()31  type t332    sequence33    integer n34  end type35  type(t3) zfunc136  zfunc1%n = 12337end38 39program main40  use m41  implicit type(t1) (x)42  implicit type(t2) (y)43  implicit type(t3) (z)44  print *, xfunc1() ! ok45  print *, xfunc2() ! ok46!ERROR: Implicit declaration of function 'yfunc1' has a different result type than in previous declaration47  print *, yfunc1()48  print *, yfunc2()49  print *, zfunc1() ! ok50  print *, zfunc2() ! ok51end52 53function xfunc2()54  use m55  type(t1) xfunc256  xfunc2%n = 12357end58 59function yfunc2()60  use m61!ERROR: Function 'yfunc2' has a result type that differs from the implicit type it obtained in a previous reference62  type(t1) yfunc263  yfunc2%n = 12364end65 66function zfunc2()67  type t368    sequence69    integer n70  end type71  type(t3) zfunc272  zfunc2%n = 12373end74