forked from OSchip/llvm-project
[flang] enable semantic analysis by default
back out -Mnolargearray default temporarily Fix C_F_POINTER(SHAPE=) argument check, it can be any kind of integer Revert default result kind of SIZE() & al. to standard by default Remove needless usage of -fdebug-semantics Original-commit: flang-compiler/f18@57058a5b16 Reviewed-on: https://github.com/flang-compiler/f18/pull/907
This commit is contained in:
parent
6099a1b17f
commit
01c3e4c9f0
|
@ -18,20 +18,11 @@ accepted if enabled by command-line options.
|
|||
|
||||
Intentional violations of the standard
|
||||
======================================
|
||||
* The default `INTEGER` type is required by the standard to occupy
|
||||
the same amount of storage as the default `REAL` type. Default
|
||||
`REAL` is of course 32-bit IEEE-754 floating-point today. This legacy
|
||||
rule imposes an artificially small constraint in some cases
|
||||
where Fortran mandates that something have the default `INTEGER`
|
||||
type: specifically, the results of references to the intrinsic functions
|
||||
`SIZE`, `LBOUND`, `UBOUND`, `SHAPE`, and the location reductions
|
||||
`FINDLOC`, `MAXLOC`, and `MINLOC`. We return `INTEGER(KIND=8)` by
|
||||
default in these cases.
|
||||
* Scalar `INTEGER` actual argument expressions (not variables!)
|
||||
are converted to the kinds of scalar `INTEGER` dummy arguments
|
||||
when the interface is explicit and the kinds differ.
|
||||
This conversion allows the results of the intrinsics like
|
||||
`SIZE` that (as mentioned above) no longer return default
|
||||
`SIZE` that (as mentioned below) may return non-default
|
||||
`INTEGER` results by default to be passed. A warning is
|
||||
emitted when truncation is possible.
|
||||
|
||||
|
@ -124,6 +115,15 @@ Extensions, deletions, and legacy features supported by default
|
|||
allowed. The values are normalized.
|
||||
* An effectively empty source file (no program unit) is accepted and
|
||||
produces an empty relocatable output file.
|
||||
* The default `INTEGER` type is required by the standard to occupy
|
||||
the same amount of storage as the default `REAL` type. Default
|
||||
`REAL` is of course 32-bit IEEE-754 floating-point today. This legacy
|
||||
rule imposes an artificially small constraint in some cases
|
||||
where Fortran mandates that something have the default `INTEGER`
|
||||
type: specifically, the results of references to the intrinsic functions
|
||||
`SIZE`, `LBOUND`, `UBOUND`, `SHAPE`, and the location reductions
|
||||
`FINDLOC`, `MAXLOC`, and `MINLOC`. We return `INTEGER(KIND=8)` by
|
||||
default in these cases when the `-flarge-sizes` option is enabled.
|
||||
|
||||
Extensions supported when enabled by options
|
||||
--------------------------------------------
|
||||
|
|
|
@ -29,6 +29,12 @@ IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_subscriptIntegerKind(
|
|||
return *this;
|
||||
}
|
||||
|
||||
IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_sizeIntegerKind(
|
||||
int k) {
|
||||
sizeIntegerKind_ = k;
|
||||
return *this;
|
||||
}
|
||||
|
||||
IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_defaultRealKind(
|
||||
int k) {
|
||||
defaultRealKind_ = k;
|
||||
|
|
|
@ -27,11 +27,13 @@ class IntrinsicTypeDefaultKinds {
|
|||
public:
|
||||
IntrinsicTypeDefaultKinds();
|
||||
int subscriptIntegerKind() const { return subscriptIntegerKind_; }
|
||||
int sizeIntegerKind() const { return sizeIntegerKind_; }
|
||||
int doublePrecisionKind() const { return doublePrecisionKind_; }
|
||||
int quadPrecisionKind() const { return quadPrecisionKind_; }
|
||||
|
||||
IntrinsicTypeDefaultKinds &set_defaultIntegerKind(int);
|
||||
IntrinsicTypeDefaultKinds &set_subscriptIntegerKind(int);
|
||||
IntrinsicTypeDefaultKinds &set_sizeIntegerKind(int);
|
||||
IntrinsicTypeDefaultKinds &set_defaultRealKind(int);
|
||||
IntrinsicTypeDefaultKinds &set_doublePrecisionKind(int);
|
||||
IntrinsicTypeDefaultKinds &set_quadPrecisionKind(int);
|
||||
|
@ -48,6 +50,7 @@ private:
|
|||
// comprise two default REAL components.
|
||||
int defaultIntegerKind_{4};
|
||||
int subscriptIntegerKind_{8};
|
||||
int sizeIntegerKind_{4}; // SIZE(), UBOUND(), &c. default KIND=
|
||||
int defaultRealKind_{defaultIntegerKind_};
|
||||
int doublePrecisionKind_{2 * defaultRealKind_};
|
||||
int quadPrecisionKind_{2 * doublePrecisionKind_};
|
||||
|
|
|
@ -79,6 +79,7 @@ ENUM_CLASS(KindCode, none, defaultIntegerKind,
|
|||
dimArg, // this argument is DIM=
|
||||
likeMultiply, // for DOT_PRODUCT and MATMUL
|
||||
subscript, // address-sized integer
|
||||
size, // default KIND= for SIZE(), UBOUND, &c.
|
||||
addressable, // for PRESENT(), &c.; anything (incl. procedure) but BOZ
|
||||
)
|
||||
|
||||
|
@ -181,7 +182,7 @@ ENUM_CLASS(Rank,
|
|||
ENUM_CLASS(Optionality, required, optional,
|
||||
defaultsToSameKind, // for MatchingDefaultKIND
|
||||
defaultsToDefaultForResult, // for DefaultingKIND
|
||||
defaultsToSubscriptKind, // for SubscriptDefaultKIND
|
||||
defaultsToSizeKind, // for SizeDefaultKIND
|
||||
repeats, // for MAX/MIN and their several variants
|
||||
)
|
||||
|
||||
|
@ -205,11 +206,13 @@ static constexpr IntrinsicDummyArgument DefaultingKIND{"kind",
|
|||
static constexpr IntrinsicDummyArgument MatchingDefaultKIND{"kind",
|
||||
{IntType, KindCode::kindArg}, Rank::scalar,
|
||||
Optionality::defaultsToSameKind};
|
||||
// SubscriptDefaultKind is a KIND= argument whose default value is
|
||||
// the kind of INTEGER used for address calculations.
|
||||
static constexpr IntrinsicDummyArgument SubscriptDefaultKIND{"kind",
|
||||
// SizeDefaultKind is a KIND= argument whose default value should be
|
||||
// the kind of INTEGER used for address calculations, and can be
|
||||
// set so with a compiler flag; but the standard mandates the
|
||||
// kind of default INTEGER.
|
||||
static constexpr IntrinsicDummyArgument SizeDefaultKIND{"kind",
|
||||
{IntType, KindCode::kindArg}, Rank::scalar,
|
||||
Optionality::defaultsToSubscriptKind};
|
||||
Optionality::defaultsToSizeKind};
|
||||
static constexpr IntrinsicDummyArgument RequiredDIM{
|
||||
"dim", {IntType, KindCode::dimArg}, Rank::scalar, Optionality::required};
|
||||
static constexpr IntrinsicDummyArgument OptionalDIM{
|
||||
|
@ -386,35 +389,33 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
|
|||
{"findloc",
|
||||
{{"array", AnyNumeric, Rank::array},
|
||||
{"value", AnyNumeric, Rank::scalar}, RequiredDIM, OptionalMASK,
|
||||
SubscriptDefaultKIND,
|
||||
SizeDefaultKIND,
|
||||
{"back", AnyLogical, Rank::scalar, Optionality::optional}},
|
||||
KINDInt, Rank::dimRemoved},
|
||||
{"findloc",
|
||||
{{"array", AnyNumeric, Rank::array},
|
||||
{"value", AnyNumeric, Rank::scalar}, OptionalMASK,
|
||||
SubscriptDefaultKIND,
|
||||
{"value", AnyNumeric, Rank::scalar}, OptionalMASK, SizeDefaultKIND,
|
||||
{"back", AnyLogical, Rank::scalar, Optionality::optional}},
|
||||
KINDInt, Rank::vector},
|
||||
{"findloc",
|
||||
{{"array", SameChar, Rank::array}, {"value", SameChar, Rank::scalar},
|
||||
RequiredDIM, OptionalMASK, SubscriptDefaultKIND,
|
||||
RequiredDIM, OptionalMASK, SizeDefaultKIND,
|
||||
{"back", AnyLogical, Rank::scalar, Optionality::optional}},
|
||||
KINDInt, Rank::dimRemoved},
|
||||
{"findloc",
|
||||
{{"array", SameChar, Rank::array}, {"value", SameChar, Rank::scalar},
|
||||
OptionalMASK, SubscriptDefaultKIND,
|
||||
OptionalMASK, SizeDefaultKIND,
|
||||
{"back", AnyLogical, Rank::scalar, Optionality::optional}},
|
||||
KINDInt, Rank::vector},
|
||||
{"findloc",
|
||||
{{"array", AnyLogical, Rank::array},
|
||||
{"value", AnyLogical, Rank::scalar}, RequiredDIM, OptionalMASK,
|
||||
SubscriptDefaultKIND,
|
||||
SizeDefaultKIND,
|
||||
{"back", AnyLogical, Rank::scalar, Optionality::optional}},
|
||||
KINDInt, Rank::dimRemoved},
|
||||
{"findloc",
|
||||
{{"array", AnyLogical, Rank::array},
|
||||
{"value", AnyLogical, Rank::scalar}, OptionalMASK,
|
||||
SubscriptDefaultKIND,
|
||||
{"value", AnyLogical, Rank::scalar}, OptionalMASK, SizeDefaultKIND,
|
||||
{"back", AnyLogical, Rank::scalar, Optionality::optional}},
|
||||
KINDInt, Rank::vector},
|
||||
{"floor", {{"a", AnyReal}, DefaultingKIND}, KINDInt},
|
||||
|
@ -461,10 +462,9 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
|
|||
{"kind", {{"x", AnyIntrinsic}}, DefaultInt},
|
||||
{"lbound",
|
||||
{{"array", AnyData, Rank::anyOrAssumedRank}, RequiredDIM,
|
||||
SubscriptDefaultKIND},
|
||||
SizeDefaultKIND},
|
||||
KINDInt, Rank::scalar},
|
||||
{"lbound",
|
||||
{{"array", AnyData, Rank::anyOrAssumedRank}, SubscriptDefaultKIND},
|
||||
{"lbound", {{"array", AnyData, Rank::anyOrAssumedRank}, SizeDefaultKIND},
|
||||
KINDInt, Rank::vector},
|
||||
{"leadz", {{"i", AnyInt}}, DefaultInt},
|
||||
{"len", {{"string", AnyChar, Rank::anyOrAssumedRank}, DefaultingKIND},
|
||||
|
@ -518,7 +518,7 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
|
|||
Rank::scalar},
|
||||
{"maxloc",
|
||||
{{"array", AnyRelatable, Rank::array}, OptionalDIM, OptionalMASK,
|
||||
SubscriptDefaultKIND,
|
||||
SizeDefaultKIND,
|
||||
{"back", AnyLogical, Rank::scalar, Optionality::optional}},
|
||||
KINDInt, Rank::dimReduced},
|
||||
{"maxval",
|
||||
|
@ -546,7 +546,7 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
|
|||
Rank::scalar},
|
||||
{"minloc",
|
||||
{{"array", AnyRelatable, Rank::array}, OptionalDIM, OptionalMASK,
|
||||
SubscriptDefaultKIND,
|
||||
SizeDefaultKIND,
|
||||
{"back", AnyLogical, Rank::scalar, Optionality::optional}},
|
||||
KINDInt, Rank::dimReduced},
|
||||
{"minval",
|
||||
|
@ -642,8 +642,7 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
|
|||
{"radix", AnyInt, Rank::scalar}},
|
||||
DefaultInt, Rank::scalar},
|
||||
{"set_exponent", {{"x", SameReal}, {"i", AnyInt}}, SameReal},
|
||||
{"shape",
|
||||
{{"source", AnyData, Rank::anyOrAssumedRank}, SubscriptDefaultKIND},
|
||||
{"shape", {{"source", AnyData, Rank::anyOrAssumedRank}, SizeDefaultKIND},
|
||||
KINDInt, Rank::vector},
|
||||
{"shifta", {{"i", SameInt}, {"shift", AnyInt}}, SameInt},
|
||||
{"shiftl", {{"i", SameInt}, {"shift", AnyInt}}, SameInt},
|
||||
|
@ -654,7 +653,7 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
|
|||
{"sinh", {{"x", SameFloating}}, SameFloating},
|
||||
{"size",
|
||||
{{"array", AnyData, Rank::anyOrAssumedRank}, OptionalDIM,
|
||||
SubscriptDefaultKIND},
|
||||
SizeDefaultKIND},
|
||||
KINDInt, Rank::scalar},
|
||||
{"spacing", {{"x", SameReal}}, SameReal},
|
||||
{"spread",
|
||||
|
@ -662,9 +661,8 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
|
|||
{"ncopies", AnyInt, Rank::scalar}},
|
||||
SameType, Rank::rankPlus1},
|
||||
{"sqrt", {{"x", SameFloating}}, SameFloating},
|
||||
{"storage_size",
|
||||
{{"a", AnyData, Rank::anyOrAssumedRank}, SubscriptDefaultKIND}, KINDInt,
|
||||
Rank::scalar},
|
||||
{"storage_size", {{"a", AnyData, Rank::anyOrAssumedRank}, SizeDefaultKIND},
|
||||
KINDInt, Rank::scalar},
|
||||
{"sum", {{"array", SameNumeric, Rank::array}, OptionalDIM, OptionalMASK},
|
||||
SameNumeric, Rank::dimReduced},
|
||||
{"tan", {{"x", SameFloating}}, SameFloating},
|
||||
|
@ -687,10 +685,9 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
|
|||
{"trim", {{"string", SameChar, Rank::scalar}}, SameChar, Rank::scalar},
|
||||
{"ubound",
|
||||
{{"array", AnyData, Rank::anyOrAssumedRank}, RequiredDIM,
|
||||
SubscriptDefaultKIND},
|
||||
SizeDefaultKIND},
|
||||
KINDInt, Rank::scalar},
|
||||
{"ubound",
|
||||
{{"array", AnyData, Rank::anyOrAssumedRank}, SubscriptDefaultKIND},
|
||||
{"ubound", {{"array", AnyData, Rank::anyOrAssumedRank}, SizeDefaultKIND},
|
||||
KINDInt, Rank::vector},
|
||||
{"unpack",
|
||||
{{"vector", SameType, Rank::vector}, {"mask", AnyLogical, Rank::array},
|
||||
|
@ -854,9 +851,9 @@ static const SpecificIntrinsicInterface specificIntrinsicFunction[]{
|
|||
{{"idnint", {{"a", DoublePrecision}}, DefaultInt}, "nint"},
|
||||
{{"ifix", {{"a", AnyReal}}, DefaultInt}, "int", true},
|
||||
{{"index", {{"string", DefaultChar}, {"substring", DefaultChar}},
|
||||
SubscriptInt}},
|
||||
DefaultInt}},
|
||||
{{"isign", {{"a", DefaultInt}, {"b", DefaultInt}}, DefaultInt}, "sign"},
|
||||
{{"len", {{"string", DefaultChar, Rank::anyOrAssumedRank}}, SubscriptInt,
|
||||
{{"len", {{"string", DefaultChar, Rank::anyOrAssumedRank}}, DefaultInt,
|
||||
Rank::scalar}},
|
||||
{{"lge", {{"string_a", DefaultChar}, {"string_b", DefaultChar}},
|
||||
DefaultLogical}},
|
||||
|
@ -1348,11 +1345,10 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
|
|||
} else if (kindDummyArg->optionality == Optionality::defaultsToSameKind) {
|
||||
CHECK(sameArg);
|
||||
resultType = *sameArg->GetType();
|
||||
} else if (kindDummyArg->optionality ==
|
||||
Optionality::defaultsToSubscriptKind) {
|
||||
} else if (kindDummyArg->optionality == Optionality::defaultsToSizeKind) {
|
||||
CHECK(*category == TypeCategory::Integer);
|
||||
resultType =
|
||||
DynamicType{TypeCategory::Integer, defaults.subscriptIntegerKind()};
|
||||
DynamicType{TypeCategory::Integer, defaults.sizeIntegerKind()};
|
||||
} else {
|
||||
CHECK(kindDummyArg->optionality ==
|
||||
Optionality::defaultsToDefaultForResult);
|
||||
|
@ -1372,6 +1368,12 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
|
|||
resultType =
|
||||
DynamicType{TypeCategory::Integer, defaults.subscriptIntegerKind()};
|
||||
break;
|
||||
case KindCode::size:
|
||||
CHECK(result.categorySet == IntType);
|
||||
CHECK(*category == TypeCategory::Integer);
|
||||
resultType =
|
||||
DynamicType{TypeCategory::Integer, defaults.sizeIntegerKind()};
|
||||
break;
|
||||
case KindCode::typeless:
|
||||
case KindCode::teamType:
|
||||
case KindCode::any:
|
||||
|
@ -1711,12 +1713,20 @@ IntrinsicProcTable::Implementation::HandleC_F_Pointer(
|
|||
context.messages().Say(
|
||||
"SHAPE= argument to C_F_POINTER() must appear when FPTR= is an array"_err_en_US);
|
||||
}
|
||||
characteristics::DummyDataObject shape{characteristics::TypeAndShape{
|
||||
DynamicType{TypeCategory::Integer, defaults_.subscriptIntegerKind()},
|
||||
1}};
|
||||
shape.intent = common::Intent::In;
|
||||
shape.attrs.set(characteristics::DummyDataObject::Attr::Optional);
|
||||
dummies.emplace_back("shape"s, std::move(shape));
|
||||
if (arguments[2]) {
|
||||
DynamicType shapeType{
|
||||
TypeCategory::Integer, defaults_.sizeIntegerKind()};
|
||||
if (auto type{arguments[2]->GetType()}) {
|
||||
if (type->category() == TypeCategory::Integer) {
|
||||
shapeType = *type;
|
||||
}
|
||||
}
|
||||
characteristics::DummyDataObject shape{
|
||||
characteristics::TypeAndShape{shapeType, 1}};
|
||||
shape.intent = common::Intent::In;
|
||||
shape.attrs.set(characteristics::DummyDataObject::Attr::Optional);
|
||||
dummies.emplace_back("shape"s, std::move(shape));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dummies.size() == 3) {
|
||||
|
|
|
@ -17,10 +17,10 @@ contains
|
|||
end module
|
||||
|
||||
! RUN: echo %t 1>&2;
|
||||
! RUN: ${F18} -fget-definition 7 17 18 -fparse-only -fdebug-semantics %s > %t;
|
||||
! RUN: ${F18} -fget-definition 8 20 23 -fparse-only -fdebug-semantics %s >> %t;
|
||||
! RUN: ${F18} -fget-definition 15 3 4 -fparse-only -fdebug-semantics %s >> %t;
|
||||
! RUN: ${F18} -fget-definition -fparse-only -fdebug-semantics %s >> %t 2>&1;
|
||||
! RUN: ${F18} -fget-definition 7 17 18 -fparse-only %s > %t;
|
||||
! RUN: ${F18} -fget-definition 8 20 23 -fparse-only %s >> %t;
|
||||
! RUN: ${F18} -fget-definition 15 3 4 -fparse-only %s >> %t;
|
||||
! RUN: ${F18} -fget-definition -fparse-only %s >> %t 2>&1;
|
||||
! RUN: cat %t | ${FileCheck} %s
|
||||
! CHECK:x:.*getdefinition01.f90, 6, 21-22
|
||||
! CHECK:yyy:.*getdefinition01.f90, 6, 24-27
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
end function
|
||||
end module
|
||||
|
||||
! RUN: ${F18} -fget-definition 8 9 10 -fparse-only -fdebug-semantics %s > %t;
|
||||
! RUN: ${F18} -fget-definition 9 26 29 -fparse-only -fdebug-semantics %s >> %t;
|
||||
! RUN: ${F18} -fget-definition 16 9 10 -fparse-only -fdebug-semantics %s >> %t;
|
||||
! RUN: ${F18} -fget-definition 8 9 10 -fparse-only %s > %t;
|
||||
! RUN: ${F18} -fget-definition 9 26 29 -fparse-only %s >> %t;
|
||||
! RUN: ${F18} -fget-definition 16 9 10 -fparse-only %s >> %t;
|
||||
! RUN: cat %t | ${FileCheck} %s
|
||||
! CHECK:x:.*getdefinition02.f, 6, 27-28
|
||||
! CHECK:yyy:.*getdefinition02.f, 6, 30-33
|
||||
|
|
|
@ -8,8 +8,8 @@ program main
|
|||
x = f
|
||||
end program
|
||||
|
||||
! RUN: ${F18} -fget-definition 8 6 7 -fparse-only -fdebug-semantics %s > %t;
|
||||
! RUN: ${F18} -fget-definition 8 2 3 -fparse-only -fdebug-semantics %s >> %t;
|
||||
! RUN: ${F18} -fget-definition 8 6 7 -fparse-only %s > %t;
|
||||
! RUN: ${F18} -fget-definition 8 2 3 -fparse-only %s >> %t;
|
||||
! RUN: cat %t | ${FileCheck} %s;
|
||||
! CHECK:f:.*getdefinition03-b.f90, 2, 12-13
|
||||
! CHECK:x:.*getdefinition03-a.f90, 7, 13-14
|
||||
|
|
|
@ -7,5 +7,5 @@ program main
|
|||
x = y
|
||||
end program
|
||||
|
||||
! RUN: ${F18} -fget-definition 7 3 4 -fparse-only -fdebug-semantics %s | ${FileCheck} %s
|
||||
! RUN: ${F18} -fget-definition 7 3 4 -fparse-only %s | ${FileCheck} %s
|
||||
! CHECK:x:.*getdefinition04.f90, 4, 14-15
|
||||
|
|
|
@ -13,9 +13,9 @@ program main
|
|||
end program
|
||||
|
||||
!! Inner x
|
||||
! RUN: ${F18} -fget-definition 10 5 6 -fparse-only -fdebug-semantics %s > %t;
|
||||
! RUN: ${F18} -fget-definition 10 5 6 -fparse-only %s > %t;
|
||||
! CHECK:x:.*getdefinition05.f90, 8, 16-17
|
||||
!! Outer y
|
||||
! RUN: ${F18} -fget-definition 12 7 8 -fparse-only -fdebug-semantics %s >> %t;
|
||||
! RUN: ${F18} -fget-definition 12 7 8 -fparse-only %s >> %t;
|
||||
! CHECK:y:.*getdefinition05.f90, 6, 14-15
|
||||
! RUN: cat %t | ${FileCheck} %s;
|
||||
|
|
|
@ -16,7 +16,7 @@ contains
|
|||
end function
|
||||
end module
|
||||
|
||||
! RUN: ${F18} -fget-symbols-sources -fparse-only -fdebug-semantics %s 2>&1 | ${FileCheck} %s
|
||||
! RUN: ${F18} -fget-symbols-sources -fparse-only %s 2>&1 | ${FileCheck} %s
|
||||
! CHECK-ONCE:mm1:.*getsymbols01.f90, 3, 8-11
|
||||
! CHECK-ONCE:f:.*getsymbols01.f90, 13, 26-27
|
||||
! CHECK-ONCE:s:.*getsymbols01.f90, 6, 18-19
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
! RUN: ${F18} -fparse-only -fdebug-semantics %s
|
||||
! RUN: ${F18} -fparse-only %s
|
||||
|
||||
module mm2a
|
||||
implicit none
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
! RUN: ${F18} -fparse-only -fdebug-semantics %s
|
||||
! RUN: ${F18} -fparse-only %s
|
||||
|
||||
module mm2b
|
||||
use mm2a
|
||||
|
|
|
@ -7,6 +7,6 @@ PROGRAM helloworld
|
|||
i = callget5()
|
||||
ENDPROGRAM
|
||||
|
||||
! RUN: ${F18} -fget-symbols-sources -fparse-only -fdebug-semantics %s 2>&1 | ${FileCheck} %s
|
||||
! RUN: ${F18} -fget-symbols-sources -fparse-only %s 2>&1 | ${FileCheck} %s
|
||||
! CHECK:callget5: mm2b
|
||||
! CHECK:get5: mm2a
|
||||
|
|
|
@ -8,7 +8,7 @@ program main
|
|||
x = f
|
||||
end program
|
||||
|
||||
! RUN: ${F18} -fget-symbols-sources -fparse-only -fdebug-semantics %s 2>&1 | ${FileCheck} %s
|
||||
! RUN: ${F18} -fget-symbols-sources -fparse-only %s 2>&1 | ${FileCheck} %s
|
||||
! CHECK:mm3:.*getsymbols03-b.f90, 1, 8-11
|
||||
! CHECK:f:.*getsymbols03-b.f90, 2, 12-13
|
||||
! CHECK:main:.*getsymbols03-a.f90, 5, 9-13
|
||||
|
|
|
@ -7,7 +7,7 @@ program main
|
|||
x = y
|
||||
end program
|
||||
|
||||
! RUN: ${F18} -fget-symbols-sources -fparse-only -fdebug-semantics %s 2>&1 | ${FileCheck} %s
|
||||
! RUN: ${F18} -fget-symbols-sources -fparse-only %s 2>&1 | ${FileCheck} %s
|
||||
! CHECK:x:.*getsymbols04.f90, 4, 14-15
|
||||
! CHECK:y:.*getsymbols04.f90, 5, 14-15
|
||||
! CHECK:x:.*getsymbols04.f90, 6, 11-12
|
||||
|
|
|
@ -10,7 +10,7 @@ program main
|
|||
x = y
|
||||
end program
|
||||
|
||||
! RUN: ${F18} -fget-symbols-sources -fparse-only -fdebug-semantics %s 2>&1 | ${FileCheck} %s
|
||||
! RUN: ${F18} -fget-symbols-sources -fparse-only %s 2>&1 | ${FileCheck} %s
|
||||
! CHECK:x:.*getsymbols05.f90, 4, 14-15
|
||||
! CHECK:y:.*getsymbols05.f90, 5, 14-15
|
||||
! CHECK:x:.*getsymbols05.f90, 7, 16-17
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
! 11.1.4 - 4 It is permissible to branch to and end-block-stmt only withinh its
|
||||
! Block Construct
|
||||
|
||||
! RUN: ${F18} -fdebug-semantics %s 2>&1 | ${FileCheck} %s
|
||||
! RUN: ${F18} %s 2>&1 | ${FileCheck} %s
|
||||
! CHECK: label '20' is not in scope
|
||||
|
||||
subroutine s1
|
||||
|
|
|
@ -18,11 +18,11 @@ end
|
|||
!contains
|
||||
! function f1(x) result(y)
|
||||
! integer(4)::x(:)
|
||||
! integer(4)::y(1_8:1_8*size(x,dim=1))
|
||||
! integer(4)::y(1_8:int(int(1_8*size(x,dim=1),kind=4),kind=8))
|
||||
! end
|
||||
! function f2(x)
|
||||
! integer(4)::x(:)
|
||||
! integer(4)::f2(1_8:1_8*size(x,dim=1))
|
||||
! integer(4)::f2(1_8:int(int(1_8*size(x,dim=1),kind=4),kind=8))
|
||||
! end
|
||||
!end
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ end
|
|||
! end
|
||||
! subroutine s3(x, y)
|
||||
! real(4) :: x(1_8:10_8, 1_8:10_8)
|
||||
! real(4) :: y(1_8:ubound(f_elem(x), 1_4))
|
||||
! real(4) :: y(1_8:int(ubound(f_elem(x),1_4),kind=8))
|
||||
! end
|
||||
!end
|
||||
|
||||
|
|
|
@ -564,7 +564,7 @@ end
|
|||
! real(4) :: x
|
||||
! real(4) :: y(1_8:4_8, 1_8:n)
|
||||
! real(4) :: z(1_8:2_8, 1_8:2_8, 1_8:2_8)
|
||||
! real(4) :: a(1_8:4_8*(n-1_8+1_8))
|
||||
! real(4) :: a(1_8:int(int(4_8*(n-1_8+1_8),kind=4),kind=8))
|
||||
! real(4) :: b(1_8:add(y, z))
|
||||
! end
|
||||
!end
|
||||
|
|
|
@ -54,7 +54,7 @@ foreach(filename ${MODULES})
|
|||
set(depends ${include}/__fortran_builtins.mod)
|
||||
endif()
|
||||
add_custom_command(OUTPUT ${include}/${filename}.mod
|
||||
COMMAND f18 -fparse-only -fdebug-semantics -I${include}
|
||||
COMMAND f18 -fparse-only -I${include}
|
||||
${PROJECT_SOURCE_DIR}/module/${filename}.f90
|
||||
WORKING_DIRECTORY ${include}
|
||||
DEPENDS f18 ${PROJECT_SOURCE_DIR}/module/${filename}.f90 ${depends}
|
||||
|
|
|
@ -94,7 +94,7 @@ struct DriverOptions {
|
|||
bool dumpParseTree{false};
|
||||
bool dumpSymbols{false};
|
||||
bool debugResolveNames{false};
|
||||
bool debugSemantics{false};
|
||||
bool debugNoSemantics{false};
|
||||
bool measureTree{false};
|
||||
bool unparseTypedExprsToPGF90{false};
|
||||
std::vector<std::string> pgf90Args;
|
||||
|
@ -241,10 +241,9 @@ std::string CompileFortran(std::string path, Fortran::parser::Options options,
|
|||
if (driver.measureTree) {
|
||||
MeasureParseTree(parseTree);
|
||||
}
|
||||
// TODO: Change this predicate to just "if (!driver.debugNoSemantics)"
|
||||
if (driver.debugSemantics || driver.debugResolveNames || driver.dumpSymbols ||
|
||||
driver.dumpUnparseWithSymbols || driver.getDefinition ||
|
||||
driver.getSymbolsSources) {
|
||||
if (!driver.debugNoSemantics || driver.debugResolveNames ||
|
||||
driver.dumpSymbols || driver.dumpUnparseWithSymbols ||
|
||||
driver.getDefinition || driver.getSymbolsSources) {
|
||||
Fortran::semantics::Semantics semantics{
|
||||
semanticsContext, parseTree, parsing.cooked()};
|
||||
semantics.Perform();
|
||||
|
@ -481,8 +480,8 @@ int main(int argc, char *const argv[]) {
|
|||
} else if (arg == "-fdebug-instrumented-parse") {
|
||||
options.instrumentedParse = true;
|
||||
} else if (arg == "-fdebug-semantics") {
|
||||
// TODO: Enable by default once basic tests pass
|
||||
driver.debugSemantics = true;
|
||||
} else if (arg == "-fdebug-no-semantics") {
|
||||
driver.debugNoSemantics = true;
|
||||
} else if (arg == "-funparse") {
|
||||
driver.dumpUnparse = true;
|
||||
} else if (arg == "-funparse-with-symbols") {
|
||||
|
@ -512,10 +511,13 @@ int main(int argc, char *const argv[]) {
|
|||
} else if (arg == "-i8" || arg == "-fdefault-integer-8") {
|
||||
defaultKinds.set_defaultIntegerKind(8);
|
||||
defaultKinds.set_subscriptIntegerKind(8);
|
||||
defaultKinds.set_sizeIntegerKind(8);
|
||||
} else if (arg == "-Mlargearray") {
|
||||
defaultKinds.set_subscriptIntegerKind(8);
|
||||
} else if (arg == "-Mnolargearray") {
|
||||
defaultKinds.set_subscriptIntegerKind(4);
|
||||
} else if (arg == "-flarge-sizes") {
|
||||
defaultKinds.set_sizeIntegerKind(8);
|
||||
} else if (arg == "-fno-large-sizes") {
|
||||
defaultKinds.set_sizeIntegerKind(4);
|
||||
} else if (arg == "-module") {
|
||||
driver.moduleDirectory = args.front();
|
||||
args.pop_front();
|
||||
|
@ -579,7 +581,7 @@ int main(int argc, char *const argv[]) {
|
|||
<< " -fdebug-dump-symbols\n"
|
||||
<< " -fdebug-resolve-names\n"
|
||||
<< " -fdebug-instrumented-parse\n"
|
||||
<< " -fdebug-semantics perform semantic checks\n"
|
||||
<< " -fdebug-no-semantics disable semantic checks\n"
|
||||
<< " -fget-definition\n"
|
||||
<< " -fget-symbols-sources\n"
|
||||
<< " -v -c -o -I -D -U have their usual meanings\n"
|
||||
|
|
|
@ -26,4 +26,4 @@ function abspath() {
|
|||
|
||||
wd=`abspath $(dirname "$0")/..`
|
||||
|
||||
${wd}/bin/f18 -fdebug-semantics -module-suffix .f18.mod -intrinsic-module-directory ${wd}/include $*
|
||||
${wd}/bin/f18 -module-suffix .f18.mod -intrinsic-module-directory ${wd}/include $*
|
||||
|
|
Loading…
Reference in New Issue