llvm/flang/test/semantics/resolve33.f90
Tim Keith ee908da853 [flang] Preserve order of type parameters
Type parameters were sorted by the order of the type-param-def-stmts.
But we need to preserve the order of the type-param-name-list.
The is the order of positional parameters in a derived-type-spec.

So add `paramNames` to `DerivedTypeDetails` to preserve the original
order. Using this allows us to write module files with both the
type-param-name-list and type-param-def-stmts in the original order.

Also fix a bug where a duplicate type-param-def caused a spurious
extra error. If `MakeTypeSymbol()` reports an error we should not
call `SetType()` because it will just report another error.

Original-commit: flang-compiler/f18@3ca55b6333
Reviewed-on: https://github.com/flang-compiler/f18/pull/239
2018-12-06 17:52:43 -08:00

44 lines
1.3 KiB
Fortran

! Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
! Derived type parameters
module m
!ERROR: Duplicate type parameter name: 'a'
type t1(a, b, a)
integer, kind :: a
integer(8), len :: b
end type
!ERROR: No definition found for type parameter 'b'
type t2(a, b, c)
integer, kind :: a
integer, len :: c
end type
!ERROR: 'b' is not defined as a type parameter
type t3(a, b)
integer, kind :: a
integer :: b
end type
type t4(a)
integer, kind :: a
!ERROR: 'd' is not a type parameter of this derived type
integer(8), len :: d
end type
type t5(a, b)
integer, len :: a
integer, len :: b
!ERROR: Type parameter, component, or procedure binding 'a' already defined in this type
integer, len :: a
end type
end module