mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-16 13:08:42 +00:00
[flang] Support *length character length specifiers
Original-commit: flang-compiler/f18@874b13b7d8 Reviewed-on: https://github.com/flang-compiler/f18/pull/553 Tree-same-pre-rewrite: false
This commit is contained in:
parent
7a6dabf974
commit
644b2aabd0
@ -3832,6 +3832,20 @@ void DeclarationVisitor::SetType(
|
||||
const parser::Name &name, const DeclTypeSpec &type) {
|
||||
CHECK(name.symbol);
|
||||
auto &symbol{*name.symbol};
|
||||
if (charInfo_.length.has_value()) { // Declaration has "*length" (R723)
|
||||
auto length{std::move(*charInfo_.length)};
|
||||
charInfo_.length.reset();
|
||||
if (type.category() == DeclTypeSpec::Character) {
|
||||
auto kind{type.characterTypeSpec().kind()};
|
||||
// Recurse with correct type.
|
||||
SetType(name,
|
||||
currScope().MakeCharacterType(std::move(length), std::move(kind)));
|
||||
return;
|
||||
} else {
|
||||
Say(name,
|
||||
"A length specifier cannot be used to declare the non-character entity '%s'"_err_en_US);
|
||||
}
|
||||
}
|
||||
auto *prevType{symbol.GetType()};
|
||||
if (!prevType) {
|
||||
symbol.SetType(type);
|
||||
|
@ -156,6 +156,7 @@ set(SYMBOL_TESTS
|
||||
symbol10.f90
|
||||
symbol11.f90
|
||||
symbol12.f90
|
||||
symbol13.f90
|
||||
kinds01.f90
|
||||
kinds03.f90
|
||||
procinterface01.f90
|
||||
|
36
flang/test/semantics/symbol13.f90
Normal file
36
flang/test/semantics/symbol13.f90
Normal file
@ -0,0 +1,36 @@
|
||||
! Copyright (c) 2019, 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.
|
||||
|
||||
! Old-style "*length" specifiers (R723)
|
||||
|
||||
!DEF: /f1 Subprogram CHARACTER(1_8,1)
|
||||
!DEF: /f1/x1 INTENT(IN) ObjectEntity CHARACTER(2_4,1)
|
||||
!DEF: /f1/x2 INTENT(IN) ObjectEntity CHARACTER(3_8,1)
|
||||
character*1 function f1(x1, x2)
|
||||
!DEF: /f1/n PARAMETER ObjectEntity INTEGER(4)
|
||||
integer, parameter :: n = 2
|
||||
!REF: /f1/n
|
||||
!REF: /f1/x1
|
||||
!REF: /f1/x2
|
||||
!DEF: /len EXTERNAL (implicit) ProcEntity INTEGER(4)
|
||||
character*(n), intent(in) :: x1, x2*(len(x1)+1)
|
||||
!DEF: /f1/t DerivedType
|
||||
type :: t
|
||||
!REF: /len
|
||||
!REF: /f1/x2
|
||||
!DEF: /f1/t/c1 ObjectEntity CHARACTER(4_8,1)
|
||||
!DEF: /f1/t/c2 ObjectEntity CHARACTER(6_8,1)
|
||||
character*(len(x2)+1) :: c1, c2*6
|
||||
end type t
|
||||
end function f1
|
Loading…
x
Reference in New Issue
Block a user