From 01c3e4c9f0c056d10f13d79384ccac492ed3fbc3 Mon Sep 17 00:00:00 2001 From: peter klausler Date: Fri, 3 Jan 2020 16:32:23 -0800 Subject: [PATCH] [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@57058a5b163eaa90c7e0f387ea4918f9efa8184c Reviewed-on: https://github.com/flang-compiler/f18/pull/907 --- flang/documentation/Extensions.md | 20 ++--- flang/lib/common/default-kinds.cc | 6 ++ flang/lib/common/default-kinds.h | 3 + flang/lib/evaluate/intrinsics.cc | 86 ++++++++++++---------- flang/test/semantics/getdefinition01.f90 | 8 +- flang/test/semantics/getdefinition02.f | 6 +- flang/test/semantics/getdefinition03-a.f90 | 4 +- flang/test/semantics/getdefinition04.f90 | 2 +- flang/test/semantics/getdefinition05.f90 | 4 +- flang/test/semantics/getsymbols01.f90 | 2 +- flang/test/semantics/getsymbols02-a.f90 | 2 +- flang/test/semantics/getsymbols02-b.f90 | 2 +- flang/test/semantics/getsymbols02-c.f90 | 2 +- flang/test/semantics/getsymbols03-a.f90 | 2 +- flang/test/semantics/getsymbols04.f90 | 2 +- flang/test/semantics/getsymbols05.f90 | 2 +- flang/test/semantics/label14.f90 | 2 +- flang/test/semantics/modfile30.f90 | 4 +- flang/test/semantics/modfile32.f90 | 2 +- flang/test/semantics/modfile33.f90 | 2 +- flang/tools/f18/CMakeLists.txt | 2 +- flang/tools/f18/f18.cc | 22 +++--- flang/tools/f18/flang.sh | 2 +- 23 files changed, 105 insertions(+), 84 deletions(-) diff --git a/flang/documentation/Extensions.md b/flang/documentation/Extensions.md index 142cf812298b..c2e41abbe14e 100644 --- a/flang/documentation/Extensions.md +++ b/flang/documentation/Extensions.md @@ -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 -------------------------------------------- diff --git a/flang/lib/common/default-kinds.cc b/flang/lib/common/default-kinds.cc index 87de0b6e1259..d6122982f013 100644 --- a/flang/lib/common/default-kinds.cc +++ b/flang/lib/common/default-kinds.cc @@ -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; diff --git a/flang/lib/common/default-kinds.h b/flang/lib/common/default-kinds.h index 4e4116eba7c9..7b2109640812 100644 --- a/flang/lib/common/default-kinds.h +++ b/flang/lib/common/default-kinds.h @@ -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_}; diff --git a/flang/lib/evaluate/intrinsics.cc b/flang/lib/evaluate/intrinsics.cc index 4be0ef9898f6..466d37ff0baa 100644 --- a/flang/lib/evaluate/intrinsics.cc +++ b/flang/lib/evaluate/intrinsics.cc @@ -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 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 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) { diff --git a/flang/test/semantics/getdefinition01.f90 b/flang/test/semantics/getdefinition01.f90 index c86036419e02..880e282bca9f 100644 --- a/flang/test/semantics/getdefinition01.f90 +++ b/flang/test/semantics/getdefinition01.f90 @@ -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 diff --git a/flang/test/semantics/getdefinition02.f b/flang/test/semantics/getdefinition02.f index a0d7f37ba47b..3f8ac46a1380 100644 --- a/flang/test/semantics/getdefinition02.f +++ b/flang/test/semantics/getdefinition02.f @@ -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 diff --git a/flang/test/semantics/getdefinition03-a.f90 b/flang/test/semantics/getdefinition03-a.f90 index 24effbb4f68e..5b287d28665c 100644 --- a/flang/test/semantics/getdefinition03-a.f90 +++ b/flang/test/semantics/getdefinition03-a.f90 @@ -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 diff --git a/flang/test/semantics/getdefinition04.f90 b/flang/test/semantics/getdefinition04.f90 index 372ac266cddf..80ace6544386 100644 --- a/flang/test/semantics/getdefinition04.f90 +++ b/flang/test/semantics/getdefinition04.f90 @@ -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 diff --git a/flang/test/semantics/getdefinition05.f90 b/flang/test/semantics/getdefinition05.f90 index 1c22c954b8d9..3ad69778ead0 100644 --- a/flang/test/semantics/getdefinition05.f90 +++ b/flang/test/semantics/getdefinition05.f90 @@ -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; diff --git a/flang/test/semantics/getsymbols01.f90 b/flang/test/semantics/getsymbols01.f90 index 379eb38dbd1d..9f754f9374d0 100644 --- a/flang/test/semantics/getsymbols01.f90 +++ b/flang/test/semantics/getsymbols01.f90 @@ -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 diff --git a/flang/test/semantics/getsymbols02-a.f90 b/flang/test/semantics/getsymbols02-a.f90 index d8928a8cc33f..b9d75fde50af 100644 --- a/flang/test/semantics/getsymbols02-a.f90 +++ b/flang/test/semantics/getsymbols02-a.f90 @@ -1,4 +1,4 @@ -! RUN: ${F18} -fparse-only -fdebug-semantics %s +! RUN: ${F18} -fparse-only %s module mm2a implicit none diff --git a/flang/test/semantics/getsymbols02-b.f90 b/flang/test/semantics/getsymbols02-b.f90 index 3a80721db530..7ed4cbe0d894 100644 --- a/flang/test/semantics/getsymbols02-b.f90 +++ b/flang/test/semantics/getsymbols02-b.f90 @@ -1,4 +1,4 @@ -! RUN: ${F18} -fparse-only -fdebug-semantics %s +! RUN: ${F18} -fparse-only %s module mm2b use mm2a diff --git a/flang/test/semantics/getsymbols02-c.f90 b/flang/test/semantics/getsymbols02-c.f90 index 160f9160514c..cb66680906bb 100644 --- a/flang/test/semantics/getsymbols02-c.f90 +++ b/flang/test/semantics/getsymbols02-c.f90 @@ -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 diff --git a/flang/test/semantics/getsymbols03-a.f90 b/flang/test/semantics/getsymbols03-a.f90 index 888ef7d98cdb..1d6d3b6aaba2 100644 --- a/flang/test/semantics/getsymbols03-a.f90 +++ b/flang/test/semantics/getsymbols03-a.f90 @@ -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 diff --git a/flang/test/semantics/getsymbols04.f90 b/flang/test/semantics/getsymbols04.f90 index 54995a167f69..d4a83aecb5d9 100644 --- a/flang/test/semantics/getsymbols04.f90 +++ b/flang/test/semantics/getsymbols04.f90 @@ -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 diff --git a/flang/test/semantics/getsymbols05.f90 b/flang/test/semantics/getsymbols05.f90 index a9c32f91fd6d..c65a2a6f5a99 100644 --- a/flang/test/semantics/getsymbols05.f90 +++ b/flang/test/semantics/getsymbols05.f90 @@ -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 diff --git a/flang/test/semantics/label14.f90 b/flang/test/semantics/label14.f90 index fe914048f616..10a91c755b96 100644 --- a/flang/test/semantics/label14.f90 +++ b/flang/test/semantics/label14.f90 @@ -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 diff --git a/flang/test/semantics/modfile30.f90 b/flang/test/semantics/modfile30.f90 index 17b9dcaf4e4e..427025b91635 100644 --- a/flang/test/semantics/modfile30.f90 +++ b/flang/test/semantics/modfile30.f90 @@ -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 diff --git a/flang/test/semantics/modfile32.f90 b/flang/test/semantics/modfile32.f90 index 2a406e96cfee..ce43140ddbb8 100644 --- a/flang/test/semantics/modfile32.f90 +++ b/flang/test/semantics/modfile32.f90 @@ -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 diff --git a/flang/test/semantics/modfile33.f90 b/flang/test/semantics/modfile33.f90 index beebce60488f..23a510bf4008 100644 --- a/flang/test/semantics/modfile33.f90 +++ b/flang/test/semantics/modfile33.f90 @@ -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 diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt index aadb29eb1370..ab2f9b64b1fe 100644 --- a/flang/tools/f18/CMakeLists.txt +++ b/flang/tools/f18/CMakeLists.txt @@ -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} diff --git a/flang/tools/f18/f18.cc b/flang/tools/f18/f18.cc index 085b98821d14..f62aa99dcfed 100644 --- a/flang/tools/f18/f18.cc +++ b/flang/tools/f18/f18.cc @@ -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 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" diff --git a/flang/tools/f18/flang.sh b/flang/tools/f18/flang.sh index 9b261f005ae6..ca2956d1007d 100644 --- a/flang/tools/f18/flang.sh +++ b/flang/tools/f18/flang.sh @@ -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 $*