llvm-project/flang/test/Semantics/resolve47.f90

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
1.0 KiB
Fortran
Raw Normal View History

! RUN: %S/test_errors.sh %s %t %f18
[flang] Name resolution for defined operators Instead of tracking just genericName_ while in a generic interface block or generic statement, now we immediately create a symbol for it. A parser::Name isn't good enough because a defined-operator or defined-io-generic-spec doesn't have a name. Change the parse tree to add a source field to GenericSpec. Use these as names for symbols for defined-operator and defined-io-generic-spec (e.g. "operator(+)" or "read(formatted)"). Change the source for defined-op-name to include the dots so that they can be distinguished from normal symbols with the same name (e.g. you can have both ".foo." and "foo"). These symbols have names in the symbol table like ".foo.", not "operator(.foo.)", because references to them have that form. Add GenericKind enum to GenericDetails and GenericBindingDetails. This allows us to know a symbol is "assignment(=)", for example, without having to do a string comparison. Add GenericSpecInfo to handle analyzing the various kinds of generic-spec and generating symbol names and GenericKind for them. Add reference to LanguageFeatureControl to SemanticsContext so that they can be checked during semantics. For this change, if LogicalAbbreviations is enabled, report an error if the user tries to define an operator named ".T." or ".F.". Add resolve-name-utils.cc to hold utility functions and classes that don't have to be in the ResolveNamesVisitor class hierarchy. The goal is to reduce the size of resolve-names.cc where possible. Original-commit: flang-compiler/f18@3081f694e21dbcaef2554198a682c9af57f2e185 Reviewed-on: https://github.com/flang-compiler/f18/pull/338
2019-03-19 02:48:02 +08:00
module m1
!ERROR: Logical constant '.true.' may not be used as a defined operator
interface operator(.TRUE.)
end interface
!ERROR: Logical constant '.false.' may not be used as a defined operator
generic :: operator(.false.) => bar
end
module m2
interface operator(+)
module procedure foo
end interface
interface operator(.foo.)
module procedure foo
end interface
interface operator(.ge.)
module procedure bar
end interface
contains
integer function foo(x, y)
logical, intent(in) :: x, y
foo = 0
end
logical function bar(x, y)
complex, intent(in) :: x, y
bar = .false.
end
end
!ERROR: Intrinsic operator '.le.' may not be used as a defined operator
use m2, only: operator(.le.) => operator(.ge.)
!ERROR: Intrinsic operator '.not.' may not be used as a defined operator
use m2, only: operator(.not.) => operator(.foo.)
!ERROR: Logical constant '.true.' may not be used as a defined operator
use m2, only: operator(.true.) => operator(.foo.)
end