// 2. INTEGER :: x(10)
// 3. ALLOCATABLE :: x(:)
// 4. DIMENSION :: x(10)
-// 5. TODO: COMMON x(10)
+// 5. COMMON x(10)
// 6. TODO: BasedPointerStmt
class ArraySpecVisitor : public virtual BaseVisitor {
public:
return true;
}
void DeclTypeSpecVisitor::Post(const parser::TypeGuardStmt &) {
- // TODO: TypeGuardStmt
EndDeclTypeSpec();
}
EraseSymbol(*genericSymbol_);
genericSymbol_ = &MakeSymbol(symbolName);
genericSymbol_->set_details(details);
+ // preserve access attributes
+ genericSymbol_->attrs() |=
+ details.derivedType()->attrs() & Attrs{Attr::PUBLIC, Attr::PRIVATE};
+ } else if (genericSymbol_->has<UnknownDetails>()) {
+ // okay
} else if (!genericSymbol_->IsSubprogram()) {
SayAlreadyDeclared(symbolName, *genericSymbol_);
EraseSymbol(*genericSymbol_);
}
}
}
- if (!genericSymbol_) {
+ if (!genericSymbol_ || genericSymbol_->has<UnknownDetails>()) {
genericSymbol_ = &MakeSymbol(symbolName);
genericSymbol_->set_details(GenericDetails{});
}
void DeclarationVisitor::Post(const parser::EntityDecl &x) {
// TODO: may be under StructureStmt
const auto &name{std::get<parser::ObjectName>(x.t)};
- // TODO: CoarraySpec, CharLength, Initialization
+ // TODO: CoarraySpec
Attrs attrs{attrs_ ? HandleSaveName(name.source, *attrs_) : Attrs{}};
Symbol &symbol{DeclareUnknownEntity(name, attrs)};
if (auto &init{std::get<std::optional<parser::Initialization>>(x.t)}) {
if (CheckUseError(name)) {
return nullptr;
}
- if (auto *details{symbol->detailsIf<UseDetails>()}) {
- symbol = &details->symbol();
- }
+ symbol = &symbol->GetUltimate();
if (auto *details{symbol->detailsIf<GenericDetails>()}) {
if (details->derivedType()) {
symbol = details->derivedType();
--- /dev/null
+! 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.
+
+! Test correct use-association of a derived type.
+module m1
+ implicit none
+ type :: t
+ end type
+end module
+module m2
+ use m1, only: t
+end module
+module m3
+ use m2
+ type(t) :: o
+end
+
+! Test access-stmt with generic interface and type of same name.
+module m4
+ private
+ public :: t1, t2
+ type :: t2
+ end type
+ interface t1
+ module procedure init1
+ end interface
+ interface t2
+ module procedure init2
+ end interface
+ type :: t1
+ end type
+contains
+ type(t1) function init1()
+ end function
+ type(t2) function init2()
+ end function
+end module