Skip to content

Commit f0fd658

Browse files
committed
initial commit
1 parent a8644b3 commit f0fd658

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

flang/lib/Semantics/check-declarations.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,17 @@ void CheckHelper::CheckObjectEntity(
963963
"'%s' is a data object and may not be EXTERNAL"_err_en_US,
964964
symbol.name());
965965
}
966-
966+
if (symbol.test(Symbol::Flag::CrayPointee)) {
967+
// NB, IsSaved was too smart here.
968+
if (details.init()) {
969+
messages_.Say(
970+
"Cray pointee '%s' may not be initialized"_err_en_US, symbol.name());
971+
} else if (symbol.attrs().test(Attr::SAVE) ||
972+
symbol.implicitAttrs().test(Attr::SAVE)) {
973+
messages_.Say(
974+
"Cray pointee '%s' may not be SAVE"_err_en_US, symbol.name());
975+
}
976+
}
967977
if (derived) {
968978
bool isUnsavedLocal{
969979
isLocalVariable && !IsAllocatable(symbol) && !IsSaved(symbol)};

flang/lib/Semantics/resolve-names.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6650,7 +6650,7 @@ bool DeclarationVisitor::Pre(const parser::BasedPointer &) {
66506650

66516651
void DeclarationVisitor::Post(const parser::BasedPointer &bp) {
66526652
const parser::ObjectName &pointerName{std::get<0>(bp.t)};
6653-
auto *pointer{FindSymbol(pointerName)};
6653+
auto *pointer{FindInScope(pointerName)};
66546654
if (!pointer) {
66556655
pointer = &MakeSymbol(pointerName, ObjectEntityDetails{});
66566656
} else if (!ConvertToObjectEntity(*pointer)) {

flang/lib/Semantics/semantics.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,7 @@ void DoDumpSymbols(llvm::raw_ostream &os, const Scope &scope, int indent) {
731731
for (const auto &[pointee, pointer] : scope.crayPointers()) {
732732
os << " (" << pointer->name() << ',' << pointee << ')';
733733
}
734+
os << '\n';
734735
}
735736
for (const auto &pair : scope.commonBlocks()) {
736737
const auto &symbol{*pair.second};

flang/test/Lower/OpenMP/cray-pointers01.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ subroutine set_cray_pointer
3333
end module
3434

3535
program test_cray_pointers_01
36-
real*8, save :: var(*)
36+
real*8 :: var(*)
3737
! CHECK: %[[BOX_ALLOCA:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?xf64>>>
3838
! CHECK: %[[IVAR_ALLOCA:.*]] = fir.alloca i64 {bindc_name = "ivar", uniq_name = "_QFEivar"}
3939
! CHECK: %[[IVAR_DECL_01:.*]]:2 = hlfir.declare %[[IVAR_ALLOCA]] {uniq_name = "_QFEivar"} : (!fir.ref<i64>) -> (!fir.ref<i64>, !fir.ref<i64>)

flang/test/Semantics/declarations08.f90

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,10 @@
55
!ERROR: Cray pointee 'x' may not be a member of a COMMON block
66
common x
77
equivalence(y,z)
8+
!ERROR: Cray pointee 'v' may not be initialized
9+
real :: v = 42.0
10+
pointer(p,v)
11+
!ERROR: Cray pointee 'u' may not be SAVE
12+
save u
13+
pointer(p, u)
814
end

0 commit comments

Comments
 (0)