forked from OSchip/llvm-project
[flang] Fix bug for forward referenced type
A type name in an IMPLICIT declaration that was later used in a PARAMETER statement caused problems because the default symbol scope had not yet been initialized. I avoided dereferencing in the situation where the default scope was uninitialized and added a test that triggers the problem. Differential Revision: https://reviews.llvm.org/D87535
This commit is contained in:
parent
238ae4eee0
commit
398fcf224b
|
@ -541,13 +541,11 @@ const DerivedTypeSpec *Symbol::GetParentTypeSpec(const Scope *scope) const {
|
|||
|
||||
const Symbol *Symbol::GetParentComponent(const Scope *scope) const {
|
||||
if (const auto *dtDetails{detailsIf<DerivedTypeDetails>()}) {
|
||||
if (!scope) {
|
||||
scope = scope_;
|
||||
if (const Scope * localScope{scope ? scope : scope_}) {
|
||||
return dtDetails->GetParentComponent(DEREF(localScope));
|
||||
}
|
||||
return dtDetails->GetParentComponent(DEREF(scope));
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DerivedTypeDetails::add_component(const Symbol &symbol) {
|
||||
|
|
|
@ -70,3 +70,13 @@ subroutine s7(x)
|
|||
type, extends(undef) :: t
|
||||
end type
|
||||
end subroutine
|
||||
|
||||
subroutine s8
|
||||
!ERROR: Derived type 't2' was used but never defined
|
||||
!ERROR: The derived type 't2' was forward-referenced but not defined
|
||||
implicit type(t2)(x)
|
||||
parameter(y=t2(12.3))
|
||||
type t2
|
||||
real :: c
|
||||
end type
|
||||
end subroutine
|
||||
|
|
Loading…
Reference in New Issue