2020-05-12 02:38:53 +08:00
|
|
|
! RUN: %S/test_errors.sh %s %t %f18
|
2018-04-25 08:05:58 +08:00
|
|
|
module m
|
|
|
|
public i
|
2018-04-26 01:46:39 +08:00
|
|
|
integer, private :: j
|
|
|
|
!ERROR: The accessibility of 'i' has already been specified as PUBLIC
|
2018-04-25 08:05:58 +08:00
|
|
|
private i
|
2018-04-26 01:46:39 +08:00
|
|
|
!The accessibility of 'j' has already been specified as PRIVATE
|
|
|
|
private j
|
2018-04-25 08:05:58 +08:00
|
|
|
end
|
2019-03-19 02:48:02 +08:00
|
|
|
|
|
|
|
module m2
|
|
|
|
interface operator(.foo.)
|
|
|
|
module procedure ifoo
|
|
|
|
end interface
|
|
|
|
public :: operator(.foo.)
|
|
|
|
!ERROR: The accessibility of operator '.foo.' has already been specified as PUBLIC
|
|
|
|
private :: operator(.foo.)
|
|
|
|
interface operator(+)
|
|
|
|
module procedure ifoo
|
|
|
|
end interface
|
|
|
|
public :: operator(+)
|
|
|
|
!ERROR: The accessibility of 'operator(+)' has already been specified as PUBLIC
|
2019-03-20 04:38:54 +08:00
|
|
|
private :: operator(+) , ifoo
|
2019-03-19 02:48:02 +08:00
|
|
|
contains
|
|
|
|
integer function ifoo(x, y)
|
2019-12-03 00:55:44 +08:00
|
|
|
logical, intent(in) :: x, y
|
2019-03-19 02:48:02 +08:00
|
|
|
end
|
|
|
|
end module
|
[flang] Handle alternative names for relational operators
10.1.6.2 says:
> The operators <, <=, >, >=, ==, and /= always have the same interpretations
> as the operators .LT., .LE., .GT., .GE., .EQ., and .NE., respectively.
That means we have to treat `operator(<)` like `operator(.lt.)`,
for example. `<>` is a third alias for `.NE.`.
We can't just choose always to use one form (e.g. replacing `operator(.lt.)`
with `operator(<)`). This is because all symbols names are `CharBlock`s
referring to the cooked character stream so that they have proper source
provenance. Also, if a user prefers one style and uses it consistently,
that's the form they should see in messages.
So the fix is to use whatever form is found in the source, but also to
look up symbols by the other names when necessary. To assist this, add
`GenericSpecInfo::GetAllNames()` to return all of the names of a generic
spec. Each place a generic spec can occur we have to use these to look
for the symbol.
Also reorganize the `AddUse()` overloads to work with this change.
Fixes flang-compiler/f18#746.
Original-commit: flang-compiler/f18@7f06f175d5033f0728f67b1be25ecd53df1f8de5
Reviewed-on: https://github.com/flang-compiler/f18/pull/752
2019-09-18 07:57:09 +08:00
|
|
|
|
|
|
|
module m3
|
|
|
|
type t
|
|
|
|
end type
|
|
|
|
private :: operator(.lt.)
|
|
|
|
interface operator(<)
|
|
|
|
logical function lt(x, y)
|
|
|
|
import t
|
2019-12-03 00:55:44 +08:00
|
|
|
type(t), intent(in) :: x, y
|
[flang] Handle alternative names for relational operators
10.1.6.2 says:
> The operators <, <=, >, >=, ==, and /= always have the same interpretations
> as the operators .LT., .LE., .GT., .GE., .EQ., and .NE., respectively.
That means we have to treat `operator(<)` like `operator(.lt.)`,
for example. `<>` is a third alias for `.NE.`.
We can't just choose always to use one form (e.g. replacing `operator(.lt.)`
with `operator(<)`). This is because all symbols names are `CharBlock`s
referring to the cooked character stream so that they have proper source
provenance. Also, if a user prefers one style and uses it consistently,
that's the form they should see in messages.
So the fix is to use whatever form is found in the source, but also to
look up symbols by the other names when necessary. To assist this, add
`GenericSpecInfo::GetAllNames()` to return all of the names of a generic
spec. Each place a generic spec can occur we have to use these to look
for the symbol.
Also reorganize the `AddUse()` overloads to work with this change.
Fixes flang-compiler/f18#746.
Original-commit: flang-compiler/f18@7f06f175d5033f0728f67b1be25ecd53df1f8de5
Reviewed-on: https://github.com/flang-compiler/f18/pull/752
2019-09-18 07:57:09 +08:00
|
|
|
end function
|
|
|
|
end interface
|
|
|
|
!ERROR: The accessibility of 'operator(<)' has already been specified as PRIVATE
|
|
|
|
public :: operator(<)
|
|
|
|
interface operator(.gt.)
|
|
|
|
logical function gt(x, y)
|
|
|
|
import t
|
2019-12-03 00:55:44 +08:00
|
|
|
type(t), intent(in) :: x, y
|
[flang] Handle alternative names for relational operators
10.1.6.2 says:
> The operators <, <=, >, >=, ==, and /= always have the same interpretations
> as the operators .LT., .LE., .GT., .GE., .EQ., and .NE., respectively.
That means we have to treat `operator(<)` like `operator(.lt.)`,
for example. `<>` is a third alias for `.NE.`.
We can't just choose always to use one form (e.g. replacing `operator(.lt.)`
with `operator(<)`). This is because all symbols names are `CharBlock`s
referring to the cooked character stream so that they have proper source
provenance. Also, if a user prefers one style and uses it consistently,
that's the form they should see in messages.
So the fix is to use whatever form is found in the source, but also to
look up symbols by the other names when necessary. To assist this, add
`GenericSpecInfo::GetAllNames()` to return all of the names of a generic
spec. Each place a generic spec can occur we have to use these to look
for the symbol.
Also reorganize the `AddUse()` overloads to work with this change.
Fixes flang-compiler/f18#746.
Original-commit: flang-compiler/f18@7f06f175d5033f0728f67b1be25ecd53df1f8de5
Reviewed-on: https://github.com/flang-compiler/f18/pull/752
2019-09-18 07:57:09 +08:00
|
|
|
end function
|
|
|
|
end interface
|
|
|
|
public :: operator(>)
|
|
|
|
!ERROR: The accessibility of 'operator(.gt.)' has already been specified as PUBLIC
|
|
|
|
private :: operator(.gt.)
|
|
|
|
end
|