[flang] Fix arg specs for CMPLX intrinsic

Original-commit: flang-compiler/f18@3586b8a646
Reviewed-on: https://github.com/flang-compiler/f18/pull/477
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2019-06-04 10:50:34 -07:00
parent fb1fcbb9cd
commit 5774f0ab30
1 changed files with 9 additions and 6 deletions

View File

@ -289,8 +289,8 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
{"char", {{"i", AnyInt}, DefaultingKIND}, KINDChar}, {"char", {{"i", AnyInt}, DefaultingKIND}, KINDChar},
{"cmplx", {{"x", AnyComplex}, DefaultingKIND}, KINDComplex}, {"cmplx", {{"x", AnyComplex}, DefaultingKIND}, KINDComplex},
{"cmplx", {"cmplx",
{{"x", SameIntOrReal, Rank::elementalOrBOZ}, {{"x", AnyIntOrReal, Rank::elementalOrBOZ},
{"y", SameIntOrReal, Rank::elementalOrBOZ, Optionality::optional}, {"y", AnyIntOrReal, Rank::elementalOrBOZ, Optionality::optional},
DefaultingKIND}, DefaultingKIND},
KINDComplex}, KINDComplex},
{"command_argument_count", {}, DefaultInt, Rank::scalar}, {"command_argument_count", {}, DefaultInt, Rank::scalar},
@ -411,7 +411,7 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
KINDInt, Rank::vector}, KINDInt, Rank::vector},
{"leadz", {{"i", AnyInt}}, DefaultInt}, {"leadz", {{"i", AnyInt}}, DefaultInt},
{"len", {{"string", AnyChar, Rank::anyOrAssumedRank}, SubscriptDefaultKIND}, {"len", {{"string", AnyChar, Rank::anyOrAssumedRank}, SubscriptDefaultKIND},
KINDInt}, KINDInt, Rank::scalar},
{"len_trim", {{"string", AnyChar}, SubscriptDefaultKIND}, KINDInt}, {"len_trim", {{"string", AnyChar}, SubscriptDefaultKIND}, KINDInt},
{"lge", {{"string_a", SameChar}, {"string_b", SameChar}}, DefaultLogical}, {"lge", {{"string_a", SameChar}, {"string_b", SameChar}}, DefaultLogical},
{"lgt", {{"string_a", SameChar}, {"string_b", SameChar}}, DefaultLogical}, {"lgt", {{"string_a", SameChar}, {"string_b", SameChar}}, DefaultLogical},
@ -734,7 +734,8 @@ static const SpecificIntrinsicInterface specificIntrinsicFunction[]{
{{"index", {{"string", DefaultChar}, {"substring", DefaultChar}}, {{"index", {{"string", DefaultChar}, {"substring", DefaultChar}},
DefaultInt}}, DefaultInt}},
{{"isign", {{"a", DefaultInt}, {"b", DefaultInt}}, DefaultInt}, "sign"}, {{"isign", {{"a", DefaultInt}, {"b", DefaultInt}}, DefaultInt}, "sign"},
{{"len", {{"string", DefaultChar, Rank::anyOrAssumedRank}}, DefaultInt}}, {{"len", {{"string", DefaultChar, Rank::anyOrAssumedRank}}, DefaultInt,
Rank::scalar}},
{{"log", {{"x", DefaultReal}}, DefaultReal}}, {{"log", {{"x", DefaultReal}}, DefaultReal}},
{{"log10", {{"x", DefaultReal}}, DefaultReal}}, {{"log10", {{"x", DefaultReal}}, DefaultReal}},
{{"max0", {{"max0",
@ -966,7 +967,7 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
} }
if (!argOk) { if (!argOk) {
messages.Say( messages.Say(
"actual argument for '%s=' has bad type or kind '%s'"_err_en_US, "Actual argument for '%s=' has bad type or kind '%s'"_err_en_US,
d.keyword, type->AsFortran()); d.keyword, type->AsFortran());
return std::nullopt; return std::nullopt;
} }
@ -981,7 +982,7 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
const IntrinsicDummyArgument &d{dummy[std::min(j, dummyArgPatterns - 1)]}; const IntrinsicDummyArgument &d{dummy[std::min(j, dummyArgPatterns - 1)]};
if (const ActualArgument * arg{actualForDummy[j]}) { if (const ActualArgument * arg{actualForDummy[j]}) {
if (IsAssumedRank(*arg) && d.rank != Rank::anyOrAssumedRank) { if (IsAssumedRank(*arg) && d.rank != Rank::anyOrAssumedRank) {
messages.Say("assumed-rank array cannot be forwarded to " messages.Say("Assumed-rank array cannot be forwarded to "
"'%s=' argument"_err_en_US, "'%s=' argument"_err_en_US,
d.keyword); d.keyword);
return std::nullopt; return std::nullopt;
@ -1403,6 +1404,7 @@ std::optional<SpecificCall> IntrinsicProcTable::Implementation::Probe(
std::string name{call.name.ToString()}; std::string name{call.name.ToString()};
auto specificRange{specificFuncs_.equal_range(name)}; auto specificRange{specificFuncs_.equal_range(name)};
for (auto iter{specificRange.first}; iter != specificRange.second; ++iter) { for (auto iter{specificRange.first}; iter != specificRange.second; ++iter) {
CHECK(localBuffer.empty());
if (auto specificCall{ if (auto specificCall{
iter->second->Match(call, defaults_, arguments, localContext)}) { iter->second->Match(call, defaults_, arguments, localContext)}) {
if (const char *genericName{iter->second->generic}) { if (const char *genericName{iter->second->generic}) {
@ -1422,6 +1424,7 @@ std::optional<SpecificCall> IntrinsicProcTable::Implementation::Probe(
parser::Messages genericBuffer; parser::Messages genericBuffer;
auto genericRange{genericFuncs_.equal_range(name)}; auto genericRange{genericFuncs_.equal_range(name)};
for (auto iter{genericRange.first}; iter != genericRange.second; ++iter) { for (auto iter{genericRange.first}; iter != genericRange.second; ++iter) {
CHECK(localBuffer.empty());
if (auto specificCall{ if (auto specificCall{
iter->second->Match(call, defaults_, arguments, localContext)}) { iter->second->Match(call, defaults_, arguments, localContext)}) {
// Apply any semantic checks peculiar to the intrinsic // Apply any semantic checks peculiar to the intrinsic