Skip to content

Commit b973c07

Browse files
Removed CdefinedInit warning and changed CDEFINED initialization to hard error
1 parent 0e8d40e commit b973c07

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

flang/include/flang/Support/Fortran-features.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ ENUM_CLASS(UsageWarning, Portability, PointerToUndefinable,
7373
ZeroDoStep, UnusedForallIndex, OpenMPUsage, DataLength, IgnoredDirective,
7474
HomonymousSpecific, HomonymousResult, IgnoredIntrinsicFunctionType,
7575
PreviousScalarUse, RedeclaredInaccessibleComponent, ImplicitShared,
76-
IndexVarRedefinition, IncompatibleImplicitInterfaces, CdefinedInit,
76+
IndexVarRedefinition, IncompatibleImplicitInterfaces,
7777
VectorSubscriptFinalization, UndefinedFunctionResult, UselessIomsg,
7878
MismatchingDummyProcedure, SubscriptedEmptyArray, UnsignedLiteralTruncation,
7979
CompatibleDeclarationsFromDistinctModules, ConstantIsContiguous,

flang/lib/Semantics/resolve-names.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9197,8 +9197,7 @@ bool DeclarationVisitor::CheckNonPointerInitialization(
91979197
} else if (details->isCDefined()) {
91989198
// CDEFINED variables cannot have initializer, because their storage
91999199
// may come outside of Fortran.
9200-
context().Warn(common::UsageWarning::CdefinedInit, name.source,
9201-
"CDEFINED variable cannot be initialized"_warn_en_US);
9200+
Say(name, "CDEFINED variable cannot be initialized"_err_en_US);
92029201
} else {
92039202
return true;
92049203
}

flang/test/Lower/cdefined.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
! RUN: bbc -emit-hlfir -o - %s | FileCheck %s
22
! Ensure that CDEFINED variable has external (default) linkage and that
3-
! it doesn't have an initializer
3+
! it doesn't have either zero or constant initializer.
44
module m
55
use iso_c_binding
6-
integer(c_int), bind(C, name='c_global', CDEFINED) :: c = 42
6+
integer(c_int), bind(C, name='c_global', CDEFINED) :: c
77
! CHECK: fir.global @c_global : i32
8-
! CHECK-NOT: fir.zero_bits
9-
! CHECK-NOT: arith.constant 42
8+
! CHECK-NOT: fir.zero_bits
9+
! CHECK-NOT: arith.constant
1010
end

flang/test/Semantics/cdefined.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic -Werror
1+
! RUN: %python %S/test_errors.py %s %flang_fc1
22
module m
33
use iso_c_binding
4-
!WARNING: CDEFINED variable cannot be initialized [-Wcdefined-init]
4+
!ERROR: CDEFINED variable cannot be initialized
55
integer(c_int), bind(C, name='c_global', CDEFINED) :: c = 42
66
end

0 commit comments

Comments
 (0)