Skip to content

Commit 3d810ef

Browse files
Move PushContext so mapper name is available in the outer context.
Fix mapper name creation to not "fail" with type missing by using ConstructName detail flag. Add tests for abstract and "not derived" type checks.
1 parent 66b0170 commit 3d810ef

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,14 +1616,18 @@ void OmpVisitor::Post(const parser::OpenMPBlockConstruct &x) {
16161616
bool OmpVisitor::Pre(const parser::OpenMPDeclareMapperConstruct &x) {
16171617
AddOmpSourceRange(x.source);
16181618
BeginDeclTypeSpec();
1619-
PushScope(Scope::Kind::OtherConstruct, nullptr);
16201619
const auto &spec{std::get<parser::OmpDeclareMapperSpecifier>(x.t)};
1620+
Symbol *mapperSym{nullptr};
16211621
if (const auto &mapperName{std::get<std::optional<parser::Name>>(spec.t)}) {
1622-
Symbol *mapperSym{&MakeSymbol(*mapperName, Attrs{})};
1622+
mapperSym =
1623+
&MakeSymbol(*mapperName, MiscDetails{MiscDetails::Kind::ConstructName});
16231624
mapperName->symbol = mapperSym;
1624-
} else if (0) {
1625-
Symbol *mapperSym{&MakeSymbol("default", Attrs{})};
1625+
} else {
1626+
mapperSym = &MakeSymbol(
1627+
"default", Attrs{}, MiscDetails{MiscDetails::Kind::ConstructName});
16261628
}
1629+
1630+
PushScope(Scope::Kind::OtherConstruct, nullptr);
16271631
Walk(std::get<parser::TypeSpec>(spec.t));
16281632
const auto &varName{std::get<parser::ObjectName>(spec.t)};
16291633
DeclareObjectEntity(varName);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=50
2+
! Test the source code starting with omp syntax
3+
4+
integer :: y
5+
6+
!ERROR: Type is not a derived type
7+
!$omp declare mapper(mm : integer::x) map(x, y)
8+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=50
2+
! Test the source code starting with omp syntax
3+
4+
type, abstract :: t1
5+
integer :: y
6+
end type t1
7+
8+
!ERROR: Type must not be abstract
9+
!$omp declare mapper(mm : t1::x) map(x, x%y)
10+
end

0 commit comments

Comments
 (0)