@@ -156,6 +156,9 @@ class BaseVisitor {
156
156
evaluate::FoldingContext &GetFoldingContext () const {
157
157
return context_->foldingContext ();
158
158
}
159
+ bool IsIntrinsic (const SourceName &name) const {
160
+ return context_->intrinsics ().IsIntrinsic (name.ToString ());
161
+ }
159
162
160
163
// Make a placeholder symbol for a Name that otherwise wouldn't have one.
161
164
// It is not in any scope and always has MiscDetails.
@@ -2046,14 +2049,14 @@ static bool NeedsType(const Symbol &symbol) {
2046
2049
},
2047
2050
symbol.details ());
2048
2051
}
2052
+
2049
2053
void ScopeHandler::ApplyImplicitRules (Symbol &symbol) {
2050
2054
if (NeedsType (symbol)) {
2051
2055
if (const DeclTypeSpec * type{GetImplicitType (symbol)}) {
2052
2056
symbol.set (Symbol::Flag::Implicit);
2053
2057
symbol.SetType (*type);
2054
2058
} else if (symbol.has <ProcEntityDetails>() &&
2055
- !symbol.attrs ().test (Attr::EXTERNAL) &&
2056
- context ().intrinsics ().IsIntrinsic (symbol.name ().ToString ())) {
2059
+ !symbol.attrs ().test (Attr::EXTERNAL) && IsIntrinsic (symbol.name ())) {
2057
2060
// type will be determined in expression semantics
2058
2061
symbol.attrs ().set (Attr::INTRINSIC);
2059
2062
} else if (!context ().HasError (symbol)) {
@@ -2062,6 +2065,7 @@ void ScopeHandler::ApplyImplicitRules(Symbol &symbol) {
2062
2065
}
2063
2066
}
2064
2067
}
2068
+
2065
2069
const DeclTypeSpec *ScopeHandler::GetImplicitType (Symbol &symbol) {
2066
2070
const DeclTypeSpec *type{implicitRules ().GetType (symbol.name ().begin ()[0 ])};
2067
2071
if (type) {
@@ -3284,8 +3288,7 @@ bool DeclarationVisitor::HandleAttributeStmt(
3284
3288
}
3285
3289
Symbol &DeclarationVisitor::HandleAttributeStmt (
3286
3290
Attr attr, const parser::Name &name) {
3287
- if (attr == Attr::INTRINSIC &&
3288
- !context ().intrinsics ().IsIntrinsic (name.source .ToString ())) {
3291
+ if (attr == Attr::INTRINSIC && !IsIntrinsic (name.source )) {
3289
3292
Say (name.source , " '%s' is not a known intrinsic procedure" _err_en_US);
3290
3293
}
3291
3294
auto *symbol{FindInScope (currScope (), name)};
@@ -5700,7 +5703,7 @@ void ResolveNamesVisitor::HandleProcedureName(
5700
5703
CHECK (flag == Symbol::Flag::Function || flag == Symbol::Flag::Subroutine);
5701
5704
auto *symbol{FindSymbol (NonDerivedTypeScope (), name)};
5702
5705
if (!symbol) {
5703
- if (context (). intrinsics (). IsIntrinsic (name.source . ToString () )) {
5706
+ if (IsIntrinsic (name.source )) {
5704
5707
symbol =
5705
5708
&MakeSymbol (InclusiveScope (), name.source , Attrs{Attr::INTRINSIC});
5706
5709
} else {
@@ -5729,7 +5732,11 @@ void ResolveNamesVisitor::HandleProcedureName(
5729
5732
// error was reported
5730
5733
} else {
5731
5734
symbol = &Resolve (name, symbol)->GetUltimate ();
5732
- ConvertToProcEntity (*symbol);
5735
+ if (ConvertToProcEntity (*symbol) && IsIntrinsic (symbol->name ())) {
5736
+ symbol->attrs ().set (Attr::INTRINSIC);
5737
+ // 8.2(3): ignore type from intrinsic in type-declaration-stmt
5738
+ symbol->get <ProcEntityDetails>().set_interface (ProcInterface{});
5739
+ }
5733
5740
if (!SetProcFlag (name, *symbol, flag)) {
5734
5741
return ; // reported error
5735
5742
}
0 commit comments