xref: /llvm-project/flang/test/Semantics/resolve83.f90 (revision 43a263f570dbe88524ab3689bc994df60c531310)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2module m
3
4  ! For C1543
5  interface intFace
6    !WARNING: Attribute 'MODULE' cannot be used more than once
7    module pure module real function moduleFunc()
8    end function moduleFunc
9  end interface
10
11contains
12
13! C1543 A prefix shall contain at most one of each prefix-spec.
14!
15! R1535 subroutine-stmt is
16!   [prefix] SUBROUTINE subroutine-name [ ( [dummy-arg-list] )
17!   [proc-language-binding-spec] ]
18!
19! R1526  prefix is
20!   prefix-spec[prefix-spec]...
21!
22!   prefix-spec values are:
23!      declaration-type-spec, ELEMENTAL, IMPURE, MODULE, NON_RECURSIVE,
24!      PURE, RECURSIVE
25
26    !ERROR: FUNCTION prefix cannot specify the type more than once
27    real pure real function realFunc()
28    end function realFunc
29
30    !WARNING: Attribute 'ELEMENTAL' cannot be used more than once
31    elemental real elemental function elementalFunc(x)
32      real, value :: x
33      elementalFunc = x
34    end function elementalFunc
35
36    !WARNING: Attribute 'IMPURE' cannot be used more than once
37    impure real impure function impureFunc()
38    end function impureFunc
39
40    !WARNING: Attribute 'PURE' cannot be used more than once
41    pure real pure function pureFunc()
42    end function pureFunc
43
44    !ERROR: Attributes 'PURE' and 'IMPURE' conflict with each other
45    impure real pure function impurePureFunc()
46    end function impurePureFunc
47
48    !WARNING: Attribute 'RECURSIVE' cannot be used more than once
49    recursive real recursive function recursiveFunc()
50    end function recursiveFunc
51
52    !WARNING: Attribute 'NON_RECURSIVE' cannot be used more than once
53    non_recursive real non_recursive function non_recursiveFunc()
54    end function non_recursiveFunc
55
56    !ERROR: Attributes 'RECURSIVE' and 'NON_RECURSIVE' conflict with each other
57    non_recursive real recursive function non_recursiveRecursiveFunc()
58    end function non_recursiveRecursiveFunc
59end module m
60