Skip to content

[flang] Fix spurious error messages due to INTRINSIC nested in BLOCK #115889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 50 additions & 3 deletions flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4787,10 +4787,13 @@ void DeclarationVisitor::Post(const parser::EntityDecl &x) {
} else if (attrs.test(Attr::PARAMETER)) { // C882, C883
Say(name, "Missing initialization for parameter '%s'"_err_en_US);
}
if (auto *scopeSymbol{currScope().symbol()})
if (auto *details{scopeSymbol->detailsIf<DerivedTypeDetails>()})
if (details->isDECStructure())
if (auto *scopeSymbol{currScope().symbol()}) {
if (auto *details{scopeSymbol->detailsIf<DerivedTypeDetails>()}) {
if (details->isDECStructure()) {
details->add_component(symbol);
}
}
}
}

void DeclarationVisitor::Post(const parser::PointerDecl &x) {
Expand Down Expand Up @@ -7660,10 +7663,54 @@ class ExecutionPartSkimmerBase {
--blockDepth_;
PopScope();
}
// Note declarations of local names in BLOCK constructs.
// Don't have to worry about INTENT(), VALUE, or OPTIONAL
// (pertinent only to dummy arguments), ASYNCHRONOUS/VOLATILE,
// or accessibility attributes,
bool Pre(const parser::EntityDecl &x) {
Hide(std::get<parser::ObjectName>(x.t));
return true;
}
bool Pre(const parser::ObjectDecl &x) {
Hide(std::get<parser::ObjectName>(x.t));
return true;
}
bool Pre(const parser::PointerDecl &x) {
Hide(std::get<parser::Name>(x.t));
return true;
}
bool Pre(const parser::BindEntity &x) {
Hide(std::get<parser::Name>(x.t));
return true;
}
bool Pre(const parser::ContiguousStmt &x) {
for (const parser::Name &name : x.v) {
Hide(name);
}
return true;
}
bool Pre(const parser::DimensionStmt::Declaration &x) {
Hide(std::get<parser::Name>(x.t));
return true;
}
bool Pre(const parser::ExternalStmt &x) {
for (const parser::Name &name : x.v) {
Hide(name);
}
return true;
}
bool Pre(const parser::IntrinsicStmt &x) {
for (const parser::Name &name : x.v) {
Hide(name);
}
return true;
}
bool Pre(const parser::CodimensionStmt &x) {
for (const parser::CodimensionDecl &decl : x.v) {
Hide(std::get<parser::Name>(decl.t));
}
return true;
}
void Post(const parser::ImportStmt &x) {
if (x.kind == common::ImportKind::None ||
x.kind == common::ImportKind::Only) {
Expand Down
9 changes: 9 additions & 0 deletions flang/test/Semantics/bug115674.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
!RUN: %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck --allow-empty %s
!CHECK-NOT: error:
program main
sin = 1
block
intrinsic sin
print *, sin(0.)
end block
end
Loading