From f30d61ab2d82aec0873bae7e14472eeb44646fb1 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 1 Mar 2024 16:04:49 -0500 Subject: [PATCH 01/25] Prototype of new warning --- Signed-off-by: Michael Ferguson --- compiler/include/resolution.h | 5 +-- compiler/resolution/functionResolution.cpp | 37 ++++++++++++++++++---- compiler/resolution/resolveFunction.cpp | 2 +- compiler/resolution/wrappers.cpp | 5 +-- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/compiler/include/resolution.h b/compiler/include/resolution.h index 6de99228d1d9..26d930d7b868 100644 --- a/compiler/include/resolution.h +++ b/compiler/include/resolution.h @@ -302,8 +302,9 @@ void resolveNormalCallCompilerWarningStuff(CallExpr* call, FnSymbol* resolvedFn) void checkMoveIntoClass(CallExpr* call, Type* lhs, Type* rhs); -void warnForIntUintConversion(BaseAST* context, Type* formalType, - Type* actualType, Symbol* actual); +// warn for some int -> uint and small int -> real +void warnForSomeNumericConversions(BaseAST* context, Type* formalType, + Type* actualType, Symbol* actual); void lvalueCheck(CallExpr* call); diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index 872f29ef945a..4f52a77e29ed 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -6081,6 +6081,13 @@ static void discardWorsePromoting(Vec& candidates, } } +/* +static void warnSurprisingImpConvReal(Vec& candidates, + const DisambiguationContext& DC, + std::vector& discarded) { +}*/ + + // Discard any candidate that has a worse argument mapping than another // candidate. static void discardWorseArgs(Vec& candidates, @@ -6092,6 +6099,10 @@ static void discardWorseArgs(Vec& candidates, // because it is a less good match than another candidate. std::vector notBest(candidates.n, false); + // warn in some cases, using notBest for temporary space, + // and clearing notBest at the end. + //warnSurprisingImpConvReal(candidates, DC, discarded); + for (int i = 0; i < candidates.n; ++i) { if (discarded[i]) { continue; @@ -8174,13 +8185,13 @@ void checkMoveIntoClass(CallExpr* call, Type* lhs, Type* rhs) { } -void warnForIntUintConversion(BaseAST* context, - Type* formalType, - Type* actualType, - Symbol* actual) { +void warnForSomeNumericConversions(BaseAST* context, + Type* formalType, + Type* actualType, + Symbol* actual) { + Type* formalVt = formalType->getValType(); + Type* actualVt = actualType->getValType(); if (fWarnIntUint || shouldWarnUnstableFor(context)) { - Type* formalVt = formalType->getValType(); - Type* actualVt = actualType->getValType(); if (is_uint_type(formalVt) && is_int_type(actualVt)) { if (get_width(formalVt) <= get_width(actualVt)) { bool isParam = false; @@ -8207,6 +8218,20 @@ void warnForIntUintConversion(BaseAST* context, } } } + + // also check for small int/uint -> real + if (is_real_type(formalVt) && + (is_uint_type(actualVt) || is_int_type(actualVt))) { + if (get_width(formalVt) != 64 && + get_width(actualVt) != get_width(formalVt)) { + USR_WARN(context, "potentially surprising implicit conversion from '%s' to '%s'", toString(actualVt), toString(formalVt)); + if (shouldWarnUnstableFor(context)) { + USR_WARN(context, "such an implicit conversion is unstable"); + } + USR_PRINT(context, "add a cast :%s to avoid this warning", + toString(formalVt)); + } + } } diff --git a/compiler/resolution/resolveFunction.cpp b/compiler/resolution/resolveFunction.cpp index ab83b1f1913f..534d7bbee575 100644 --- a/compiler/resolution/resolveFunction.cpp +++ b/compiler/resolution/resolveFunction.cpp @@ -2762,7 +2762,7 @@ static void insertInitConversion(Symbol* to, Symbol* toType, Symbol* from, INT_ASSERT(toValType == toType->type); // generate a warning in some cases for int->uint implicit conversion - warnForIntUintConversion(insertBefore, toValType, fromValType, from); + warnForSomeNumericConversions(insertBefore, toValType, fromValType, from); } // seemingly redundant toType->type->symbol is for lowered runtime type vars diff --git a/compiler/resolution/wrappers.cpp b/compiler/resolution/wrappers.cpp index 06585e8812ee..c5c485e4bc2c 100644 --- a/compiler/resolution/wrappers.cpp +++ b/compiler/resolution/wrappers.cpp @@ -1550,8 +1550,9 @@ static void addArgCoercion(FnSymbol* fn, SET_LINENO(actual); // generate a warning in some cases for int->uint implicit conversion - warnForIntUintConversion(call, formal->type, actual->symbol()->type, - actual->symbol()); + // generate a warning in some cases for small int -> real implicit conversion + warnForSomeNumericConversions(call, formal->type, actual->symbol()->type, + actual->symbol()); Symbol* prevActual = actual->symbol(); TypeSymbol* ats = prevActual->type->symbol; From 807011953e8477a09aaa72ddbe3be718429467b5 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 4 Mar 2024 11:16:33 -0500 Subject: [PATCH 02/25] Try warning for increasing floating point precision --- Signed-off-by: Michael Ferguson --- compiler/resolution/functionResolution.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index 4f52a77e29ed..86672e9fdf38 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -8220,14 +8220,19 @@ void warnForSomeNumericConversions(BaseAST* context, } // also check for small int/uint -> real - if (is_real_type(formalVt) && - (is_uint_type(actualVt) || is_int_type(actualVt))) { - if (get_width(formalVt) != 64 && - get_width(actualVt) != get_width(formalVt)) { + bool formalFloatingPoint = is_real_type(formalVt) || + is_imag_type(formalVt) || + is_complex_type(formalVt); + bool actualFloatingPoint = is_real_type(actualVt) || + is_imag_type(actualVt) || + is_complex_type(actualVt); + + if (formalFloatingPoint && actualFloatingPoint) { + if (get_width(actualVt) < get_width(formalVt)) { USR_WARN(context, "potentially surprising implicit conversion from '%s' to '%s'", toString(actualVt), toString(formalVt)); - if (shouldWarnUnstableFor(context)) { - USR_WARN(context, "such an implicit conversion is unstable"); - } + //if (shouldWarnUnstableFor(context)) { + // USR_WARN(context, "such an implicit conversion is unstable"); + //} USR_PRINT(context, "add a cast :%s to avoid this warning", toString(formalVt)); } From 169826eceabe5507a3ef0a7b5cde7047f6a0e912 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 10:22:06 -0500 Subject: [PATCH 03/25] Revert "Try warning for increasing floating point precision" This reverts commit 807011953e8477a09aaa72ddbe3be718429467b5. --- Signed-off-by: Michael Ferguson --- compiler/resolution/functionResolution.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index 86672e9fdf38..4f52a77e29ed 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -8220,19 +8220,14 @@ void warnForSomeNumericConversions(BaseAST* context, } // also check for small int/uint -> real - bool formalFloatingPoint = is_real_type(formalVt) || - is_imag_type(formalVt) || - is_complex_type(formalVt); - bool actualFloatingPoint = is_real_type(actualVt) || - is_imag_type(actualVt) || - is_complex_type(actualVt); - - if (formalFloatingPoint && actualFloatingPoint) { - if (get_width(actualVt) < get_width(formalVt)) { + if (is_real_type(formalVt) && + (is_uint_type(actualVt) || is_int_type(actualVt))) { + if (get_width(formalVt) != 64 && + get_width(actualVt) != get_width(formalVt)) { USR_WARN(context, "potentially surprising implicit conversion from '%s' to '%s'", toString(actualVt), toString(formalVt)); - //if (shouldWarnUnstableFor(context)) { - // USR_WARN(context, "such an implicit conversion is unstable"); - //} + if (shouldWarnUnstableFor(context)) { + USR_WARN(context, "such an implicit conversion is unstable"); + } USR_PRINT(context, "add a cast :%s to avoid this warning", toString(formalVt)); } From 8f63739dc962c0afeb14dc09c111e0c042ad7d3e Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 10:27:49 -0500 Subject: [PATCH 04/25] Adjust warning warn for int(32)->real(32) --- Signed-off-by: Michael Ferguson --- compiler/resolution/functionResolution.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index 4f52a77e29ed..22b6ee06ec91 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -8223,7 +8223,7 @@ void warnForSomeNumericConversions(BaseAST* context, if (is_real_type(formalVt) && (is_uint_type(actualVt) || is_int_type(actualVt))) { if (get_width(formalVt) != 64 && - get_width(actualVt) != get_width(formalVt)) { + get_width(actualVt) < 64) { USR_WARN(context, "potentially surprising implicit conversion from '%s' to '%s'", toString(actualVt), toString(formalVt)); if (shouldWarnUnstableFor(context)) { USR_WARN(context, "such an implicit conversion is unstable"); From 51732cd180ce54c0731fc59e50b60906dfb70a01 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 12:03:15 -0500 Subject: [PATCH 05/25] Add several warnings for numeric implicit conversions --- Signed-off-by: Michael Ferguson --- compiler/AST/type.cpp | 7 ++ compiler/include/driver.h | 10 +- compiler/include/type.h | 5 + compiler/main/driver.cpp | 34 +++++- compiler/resolution/functionResolution.cpp | 136 ++++++++++++++++----- 5 files changed, 158 insertions(+), 34 deletions(-) diff --git a/compiler/AST/type.cpp b/compiler/AST/type.cpp index 38293afec46a..2465ce689a18 100644 --- a/compiler/AST/type.cpp +++ b/compiler/AST/type.cpp @@ -1502,6 +1502,13 @@ int get_width(Type *t) { return 0; } +int get_component_width(Type *t) { + if (is_complex_type(t)) { + return get_width(t) / 2; + } + return get_width(t); +} + // numbers between -2**width .. 2**width // will fit exactly in a floating-point representation. int get_mantissa_width(Type *t) { diff --git a/compiler/include/driver.h b/compiler/include/driver.h index ebb2b4160833..c561ceccb678 100644 --- a/compiler/include/driver.h +++ b/compiler/include/driver.h @@ -237,8 +237,16 @@ extern bool ignore_errors; extern bool ignore_user_errors; extern bool ignore_errors_for_pass; extern int squelch_header_errors; -extern bool fWarnConstLoops; + extern bool fWarnIntUint; +extern bool fWarnSmallIntegralReal; +extern bool fWarnIntegralReal; +extern bool fWarnRealReal; +extern bool fWarnIntegralIntegral; +extern bool fWarnImplicitNumericConversions; +extern bool fWarnParamImplicitNumericConversions; + +extern bool fWarnConstLoops; extern bool fWarnUnstable; extern bool fWarnUnstableStandard; extern bool fWarnUnstableInternal; diff --git a/compiler/include/type.h b/compiler/include/type.h index 5a24c310b4ae..88ef4982495d 100644 --- a/compiler/include/type.h +++ b/compiler/include/type.h @@ -589,7 +589,12 @@ bool is_imag_type(Type*); bool is_complex_type(Type*); bool is_enum_type(Type*); bool isLegalParamType(Type*); +// returns the width in bytes of a numeric type int get_width(Type*); +// returns the component width in bytes of a numeric type +// like get_width but for complex types, returns get_width/2 +// since that is the width of the real or imaginary component. +int get_component_width(Type*); int get_mantissa_width(Type*); int get_exponent_width(Type*); bool isClass(Type* t); // includes ref, ddata, classes; not unmanaged diff --git a/compiler/main/driver.cpp b/compiler/main/driver.cpp index d8935e498a8b..df1e0cac87e7 100644 --- a/compiler/main/driver.cpp +++ b/compiler/main/driver.cpp @@ -219,9 +219,18 @@ FILE* printPassesFile = NULL; // flag for llvmWideOpt bool fLLVMWideOpt = false; +// warnings for various implicit numeric conversions +bool fWarnIntUint = false; +bool fWarnSmallIntegralReal = true; +bool fWarnIntegralReal = false; +bool fWarnRealReal = false; +bool fWarnIntegralIntegral = false; +bool fWarnImplicitNumericConversions = false; +bool fWarnParamImplicitNumericConversions = false; + +// other warnings bool fWarnArrayOfRange = true; bool fWarnConstLoops = true; -bool fWarnIntUint = false; bool fWarnUnstable = false; bool fWarnUnstableStandard = false; bool fWarnUnstableInternal = false; @@ -745,6 +754,17 @@ static void addUsingAttributeToolname(const ArgumentDescription* desc, usingAttributeToolNames.push_back(name); } +/* called for --warn-implicit-numeric-conversions to enable the warnings */ +static void setNumericWarnings(const ArgumentDescription* desc, + const char* arg) { + bool shouldWarn = fWarnImplicitNumericConversions; + fWarnIntUint = shouldWarn; + fWarnSmallIntegralReal = shouldWarn; + fWarnIntegralReal = shouldWarn; + fWarnRealReal = shouldWarn; + fWarnIntegralIntegral = shouldWarn; +} + // In order to handle accumulating ccflags arguments, the argument // processing calls this function. This function appends the flags // to the ccflags variable, so that multiple --ccflags arguments @@ -1294,12 +1314,19 @@ static ArgumentDescription arg_desc[] = { {"print-search-dirs", ' ', NULL, "[Don't] print module search path", "N", &printSearchDirs, "CHPL_PRINT_SEARCH_DIRS", NULL}, {"", ' ', NULL, "Warning and Language Control Options", NULL, NULL, NULL, NULL}, - {"permit-unhandled-module-errors", ' ', NULL, "Permit unhandled errors in explicit modules; such errors halt at runtime", "N", &fPermitUnhandledModuleErrors, "CHPL_PERMIT_UNHANDLED_MODULE_ERRORS", NULL}, + {"permit-unhandled-module-errors", ' ', NULL, "Permit unhandled thrown errors; such errors halt at runtime", "N", &fPermitUnhandledModuleErrors, "CHPL_PERMIT_UNHANDLED_MODULE_ERRORS", NULL}, {"warn-unstable", ' ', NULL, "Enable [disable] warnings for uses of language features that are in flux", "N", &fWarnUnstable, "CHPL_WARN_UNSTABLE", NULL}, {"warnings", ' ', NULL, "Enable [disable] output of warnings", "n", &ignore_warnings, "CHPL_WARNINGS", NULL}, {"warn-unknown-attribute-toolname", ' ', NULL, "Enable [disable] warnings when an unknown tool name is found in an attribute", "N", &fWarnUnknownAttributeToolname, "CHPL_WARN_UNKNOWN_ATTRIBUTE_TOOLNAME", NULL}, {"using-attribute-toolname", ' ', "", "Specify additional tool names for attributes that are expected in the source", "S", NULL, "CHPL_ATTRIBUTE_TOOLNAMES", addUsingAttributeToolname}, -{"warn-potential-races", ' ', NULL, "Enable [disable] output of warnings for potential race conditions", "N", &fWarnPotentialRaces, "CHPL_WARN_POTENTIAL_RACES", NULL}, + {"warn-potential-races", ' ', NULL, "Enable [disable] output of warnings for potential race conditions", "N", &fWarnPotentialRaces, "CHPL_WARN_POTENTIAL_RACES", NULL}, + {"warn-int-uint", ' ', NULL, "Enable [disable] warnings for potentially negative 'int' values implicitly converted to 'uint'", "N", &fWarnIntUint, "CHPL_WARN_INT_UINT", NULL}, + {"warn-small-integral-real", ' ', NULL, "Enable [disable] warnings for implicitly converting a small int/uint to a small real/complex", "N", &fWarnSmallIntegralReal, "CHPL_WARN_SMALL_INTEGRAL_REAL", NULL}, + {"warn-integral-real", ' ', NULL, "Enable [disable] warnings for implicitly converting an int/uint to a real/complex", "N", &fWarnIntegralReal, "CHPL_WARN_INTEGRAL_REAL", NULL}, + {"warn-real-real", ' ', NULL, "Enable [disable] warnings for implicitly converting a real/imag/complex to a real/imag/complex with different precision", "N", &fWarnRealReal, "CHPL_WARN_REAL_REAL", NULL}, + {"warn-integral-integral", ' ', NULL, "Enable [disable] warnings for implicitly converting an int/uint to an int/uint with different size", "N", &fWarnIntegralIntegral, "CHPL_WARN_INTEGRAL_INTEGRAL", NULL}, + {"warn-implicit-numeric-conversions", ' ', NULL, "Enable [disable] warnings for implicitly converting a value of numeric type to a different numeric type", "N", &fWarnImplicitNumericConversions, "CHPL_WARN_IMPLICIT_NUMERIC_CONVERSIONS", setNumericWarnings}, + {"warn-param-implicit-numeric-conversions", ' ', NULL, "Enable [disable] int-uint, real-real, and integral-integral implicit conversion warnings to apply to 'param' values", "F", &fWarnParamImplicitNumericConversions, "CHPL_WARN_PARAM_IMPLICIT_NUMERIC_CONVERSIONS", NULL}, {"", ' ', NULL, "Parallelism Control Options", NULL, NULL, NULL, NULL}, {"local", ' ', NULL, "Target one [many] locale[s]", "N", &fLocal, "CHPL_LOCAL", setLocal}, @@ -1548,7 +1575,6 @@ static ArgumentDescription arg_desc[] = { {"warn-array-of-range", ' ', NULL, "Enable [disable] warnings about arrays of range literals", "N", &fWarnArrayOfRange, "CHPL_WARN_ARRAY_OF_RANGE", NULL}, {"warn-const-loops", ' ', NULL, "Enable [disable] warnings for some 'while' loops with constant conditions", "N", &fWarnConstLoops, "CHPL_WARN_CONST_LOOPS", NULL}, {"warn-domain-literal", ' ', NULL, "Enable [disable] old domain literal syntax warnings", "n", &fNoWarnDomainLiteral, "CHPL_WARN_DOMAIN_LITERAL", setWarnDomainLiteral}, - {"warn-int-uint", ' ', NULL, "Enable [disable] warnings for potentially negative 'int' values implicitly converted to 'uint'", "N", &fWarnIntUint, "CHPL_WARN_INT_UINT", NULL}, {"warn-tuple-iteration", ' ', NULL, "Enable [disable] warnings for tuple iteration", "n", &fNoWarnTupleIteration, "CHPL_WARN_TUPLE_ITERATION", setWarnTupleIteration}, {"warn-special", ' ', NULL, "Enable [disable] special warnings", "n", &fNoWarnSpecial, "CHPL_WARN_SPECIAL", setWarnSpecial}, {"warn-unstable-internal", ' ', NULL, "Enable [disable] unstable warnings in internal modules", "N", &fWarnUnstableInternal, NULL, NULL}, diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index 22b6ee06ec91..9b4f3c359379 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -8189,47 +8189,125 @@ void warnForSomeNumericConversions(BaseAST* context, Type* formalType, Type* actualType, Symbol* actual) { + Type* formalVt = formalType->getValType(); Type* actualVt = actualType->getValType(); - if (fWarnIntUint || shouldWarnUnstableFor(context)) { - if (is_uint_type(formalVt) && is_int_type(actualVt)) { - if (get_width(formalVt) <= get_width(actualVt)) { - bool isParam = false; - bool isNegParam = false; - - if (VarSymbol* var = toVarSymbol(actual)) { - if (Immediate* imm = var->immediate) { - isParam = true; - isNegParam = is_negative(imm); - } + bool formalFloatingPoint = is_real_type(formalVt) || + is_imag_type(formalVt) || + is_complex_type(formalVt); + bool actualFloatingPoint = is_real_type(actualVt) || + is_imag_type(actualVt) || + is_complex_type(actualVt); + bool formalIntUint = is_int_type(formalVt) || is_uint_type(formalVt); + bool actualIntUint = is_int_type(actualVt) || is_uint_type(actualVt); + + // nothing to do if the formal is not numeric + if (!formalFloatingPoint && !formalIntUint) return; + // nothing to do if the actual is not numeric + if (!actualFloatingPoint && !actualIntUint) return; + + int formalWidth = get_component_width(formalVt); + int actualWidth = get_component_width(actualVt); + + bool actualIsParam = false; + if (VarSymbol* var = toVarSymbol(actual)) { + if (var->immediate != nullptr) { + actualIsParam = true; + } + } + + bool userModule = false; + if (DefExpr* def = actual->defPoint) { + if (ModuleSymbol* mod = def->getModule()) { + userModule = mod->modTag == MOD_USER; + } + } + + // consider warning for int -> uint implicit conversion + if (formalIntUint && actualIntUint && + is_int_type(actualVt) && is_uint_type(formalVt)) { + // note: used to check formalWidth <= actualWidth + // but that doesn't make sense to me; if the concern is + // it could a be negative int, the widths don't matter + + if (fWarnIntUint || shouldWarnUnstableFor(context)) { + bool isParam = actualIsParam; + bool isNegParam = false; + + if (VarSymbol* var = toVarSymbol(actual)) { + if (Immediate* imm = var->immediate) { + isNegParam = is_negative(imm); } + } - // If it's a param, warn only if it is negative. - // Otherwise, warn. - if (isNegParam || !isParam) { - if (fWarnIntUint) { - USR_WARN(context, "potentially surprising int->uint implicit conversion"); - } else { - USR_WARN(context, "int->uint implicit conversion is unstable"); - } - USR_PRINT(context, "add a cast :%s to avoid this warning", - toString(formalVt)); + // If it's a param, warn only if it is negative. + // Otherwise, warn. + if (isNegParam || !isParam || fWarnParamImplicitNumericConversions) { + if (fWarnIntUint) { + USR_WARN(context, "potentially surprising implicit conversion " + "from '%s' to '%s'", + toString(actualVt), toString(formalVt)); + } else { + USR_WARN(context, "int->uint implicit conversion is unstable"); } + USR_PRINT(context, "add a cast :%s to avoid this warning", + toString(formalVt)); + return; } } } - // also check for small int/uint -> real - if (is_real_type(formalVt) && - (is_uint_type(actualVt) || is_int_type(actualVt))) { - if (get_width(formalVt) != 64 && - get_width(actualVt) < 64) { - USR_WARN(context, "potentially surprising implicit conversion from '%s' to '%s'", toString(actualVt), toString(formalVt)); - if (shouldWarnUnstableFor(context)) { - USR_WARN(context, "such an implicit conversion is unstable"); + // consider warning for small int -> small real implicit conversion + if (actualIntUint && formalFloatingPoint && + actualWidth < 64 && formalWidth != 64) { + if (fWarnSmallIntegralReal || shouldWarnUnstableFor(context)) { + if (fWarnSmallIntegralReal) { + USR_WARN(context, "potentially surprising implicit conversion " + "from '%s' to '%s'", + toString(actualVt), toString(formalVt)); + } else { + USR_WARN(context, "implicit conversion from non-default-sized integral " + "types to non-default sized floating point " + "types is unstable"); } USR_PRINT(context, "add a cast :%s to avoid this warning", toString(formalVt)); + return; + } + } + + // consider warning for any int -> real implicit conversion + if (fWarnIntegralReal && actualIntUint && formalFloatingPoint && userModule) { + if (!actualIsParam || fWarnParamImplicitNumericConversions) { + USR_WARN(context, "implicit conversion from '%s' to '%s'", + toString(actualVt), toString(formalVt)); + USR_PRINT(context, "add a cast :%s to avoid this warning", + toString(formalVt)); + return; + } + } + + // consider warning for real(t) -> real(u) implicit conversion + if (fWarnRealReal && actualFloatingPoint && formalFloatingPoint && + actualWidth != formalWidth && userModule) { + if (!actualIsParam || fWarnParamImplicitNumericConversions) { + USR_WARN(context, "implicit conversion from '%s' to '%s'", + toString(actualVt), toString(formalVt)); + USR_PRINT(context, "add a cast :%s to avoid this warning", + toString(formalVt)); + return; + } + } + + // consider warning for int/uint -> int/uint implicit conversion + if (fWarnIntegralIntegral && actualIntUint && formalIntUint && + actualWidth != formalWidth && userModule) { + if (!actualIsParam || fWarnParamImplicitNumericConversions) { + USR_WARN(context, "implicit conversion from '%s' to '%s'", + toString(actualVt), toString(formalVt)); + USR_PRINT(context, "add a cast :%s to avoid this warning", + toString(formalVt)); + return; } } } From 7e8d82c26f46acdbba05859fe4c620a4b209c63a Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 12:34:15 -0500 Subject: [PATCH 06/25] Update testing for new warning --- Signed-off-by: Michael Ferguson --- test/functions/ferguson/coercions.compopts | 2 +- test/library/standard/AutoMath/absparams.chpl | 4 ++-- test/library/standard/AutoMath/sqrtparams.compopts | 1 + test/release/examples/primers/records.chpl | 2 +- test/studies/ml/lib/MNIST.chpl | 2 +- test/studies/parboil/histo/histoSerial.chpl | 2 +- test/types/coerce/COMPOPTS | 1 + test/types/scalar/vass/int8toReal32.good | 8 ++++++++ 8 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 test/library/standard/AutoMath/sqrtparams.compopts create mode 100644 test/types/coerce/COMPOPTS diff --git a/test/functions/ferguson/coercions.compopts b/test/functions/ferguson/coercions.compopts index 34ed5685466b..91b1162f5061 100644 --- a/test/functions/ferguson/coercions.compopts +++ b/test/functions/ferguson/coercions.compopts @@ -1 +1 @@ ---no-overload-sets-checks +--no-overload-sets-checks --no-warn-implicit-numeric-conversions diff --git a/test/library/standard/AutoMath/absparams.chpl b/test/library/standard/AutoMath/absparams.chpl index 92737c57fdd7..302565170f61 100644 --- a/test/library/standard/AutoMath/absparams.chpl +++ b/test/library/standard/AutoMath/absparams.chpl @@ -20,8 +20,8 @@ param m64negOne:imag(64) = -1.0i; testabs(m64negOne); proc testabs(param x) { param p = abs(x); - assert(p == 1.0); + assert(p:real == 1.0); // also check non-param version, just for good measure var v = x; - assert(abs(v) == 1.0); + assert(abs(v):real == 1.0); } diff --git a/test/library/standard/AutoMath/sqrtparams.compopts b/test/library/standard/AutoMath/sqrtparams.compopts new file mode 100644 index 000000000000..7a57e0c86fbb --- /dev/null +++ b/test/library/standard/AutoMath/sqrtparams.compopts @@ -0,0 +1 @@ +--no-warn-implicit-numeric-conversions diff --git a/test/release/examples/primers/records.chpl b/test/release/examples/primers/records.chpl index dd75bdf16831..e744916c53ef 100644 --- a/test/release/examples/primers/records.chpl +++ b/test/release/examples/primers/records.chpl @@ -47,7 +47,7 @@ writeln(myColor); // output: (red = 0, green = 0, blue = 0) // Note that inside of a method, the fields may be accessed // by name. Additionally `this` refers to the entire record. proc Color.luminance() { - return 0.2126*red + 0.7152*green + 0.0722*blue; + return 0.2126*red:real + 0.7152*green:real + 0.0722*blue:real; } writeln(taupe.luminance()); diff --git a/test/studies/ml/lib/MNIST.chpl b/test/studies/ml/lib/MNIST.chpl index f6cd064edb11..a80f4b826564 100644 --- a/test/studies/ml/lib/MNIST.chpl +++ b/test/studies/ml/lib/MNIST.chpl @@ -27,7 +27,7 @@ proc loadImages(num: int, fileName: string = "week2/emnist/data/train-images-idx raw[i,j] = fr.read(uint(8)); } } - var image: [imageDomain] real = raw / 255.0; + var image: [imageDomain] real = raw:real / 255.0; return image; } const imageBatchDomain = {0..#num}; diff --git a/test/studies/parboil/histo/histoSerial.chpl b/test/studies/parboil/histo/histoSerial.chpl index 19ecbda936ac..b4ae005d4e7b 100644 --- a/test/studies/parboil/histo/histoSerial.chpl +++ b/test/studies/parboil/histo/histoSerial.chpl @@ -102,7 +102,7 @@ proc dumpHisto(histo: [] uint(8), height: uint(32), width: uint(32), outFilename if value == 0 then (pixMap[pos].R, pixMap[pos].G, pixMap[pos].B) = (0:uint(8),0:uint(8),0:uint(8)); else - pixMap[pos] = HSVtoRGB(0.0, 1.0, cbrt(1+63.0*value/max(uint(8)))/4); + pixMap[pos] = HSVtoRGB(0.0, 1.0, cbrt(1+63.0*value:real/max(uint(8)))/4); } } createBMP(pixMap, height, width, outFilename); diff --git a/test/types/coerce/COMPOPTS b/test/types/coerce/COMPOPTS new file mode 100644 index 000000000000..7a57e0c86fbb --- /dev/null +++ b/test/types/coerce/COMPOPTS @@ -0,0 +1 @@ +--no-warn-implicit-numeric-conversions diff --git a/test/types/scalar/vass/int8toReal32.good b/test/types/scalar/vass/int8toReal32.good index 9b34342c7fdb..edf10ed04933 100644 --- a/test/types/scalar/vass/int8toReal32.good +++ b/test/types/scalar/vass/int8toReal32.good @@ -1,2 +1,10 @@ +int8toReal32.chpl:22: warning: potentially surprising implicit conversion from 'int(8)' to 'real(32)' +int8toReal32.chpl:22: note: add a cast :real(32) to avoid this warning +int8toReal32.chpl:23: warning: potentially surprising implicit conversion from 'uint(8)' to 'real(32)' +int8toReal32.chpl:23: note: add a cast :real(32) to avoid this warning +int8toReal32.chpl:24: warning: potentially surprising implicit conversion from 'int(16)' to 'real(32)' +int8toReal32.chpl:24: note: add a cast :real(32) to avoid this warning +int8toReal32.chpl:25: warning: potentially surprising implicit conversion from 'uint(16)' to 'real(32)' +int8toReal32.chpl:25: note: add a cast :real(32) to avoid this warning (55.0, 66.0, 77.0, 88.0) (11.0, 22.0, 33.0, 44.0) From 1745799e2f6cf6613ff0b087760a42bc92261802 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 13:11:25 -0500 Subject: [PATCH 07/25] enable --no-warn-param-implicit-numeric-conversions --- Signed-off-by: Michael Ferguson --- compiler/main/driver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/main/driver.cpp b/compiler/main/driver.cpp index df1e0cac87e7..52cf4d6437a4 100644 --- a/compiler/main/driver.cpp +++ b/compiler/main/driver.cpp @@ -1326,7 +1326,7 @@ static ArgumentDescription arg_desc[] = { {"warn-real-real", ' ', NULL, "Enable [disable] warnings for implicitly converting a real/imag/complex to a real/imag/complex with different precision", "N", &fWarnRealReal, "CHPL_WARN_REAL_REAL", NULL}, {"warn-integral-integral", ' ', NULL, "Enable [disable] warnings for implicitly converting an int/uint to an int/uint with different size", "N", &fWarnIntegralIntegral, "CHPL_WARN_INTEGRAL_INTEGRAL", NULL}, {"warn-implicit-numeric-conversions", ' ', NULL, "Enable [disable] warnings for implicitly converting a value of numeric type to a different numeric type", "N", &fWarnImplicitNumericConversions, "CHPL_WARN_IMPLICIT_NUMERIC_CONVERSIONS", setNumericWarnings}, - {"warn-param-implicit-numeric-conversions", ' ', NULL, "Enable [disable] int-uint, real-real, and integral-integral implicit conversion warnings to apply to 'param' values", "F", &fWarnParamImplicitNumericConversions, "CHPL_WARN_PARAM_IMPLICIT_NUMERIC_CONVERSIONS", NULL}, + {"warn-param-implicit-numeric-conversions", ' ', NULL, "Enable [disable] int-uint, real-real, and integral-integral implicit conversion warnings to apply to 'param' values", "N", &fWarnParamImplicitNumericConversions, "CHPL_WARN_PARAM_IMPLICIT_NUMERIC_CONVERSIONS", NULL}, {"", ' ', NULL, "Parallelism Control Options", NULL, NULL, NULL, NULL}, {"local", ' ', NULL, "Target one [many] locale[s]", "N", &fLocal, "CHPL_LOCAL", setLocal}, From fb2c19a60680182ac142affd538e89668493a018 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 13:11:50 -0500 Subject: [PATCH 08/25] Update man page with new flags --- Signed-off-by: Michael Ferguson --- man/chpl.rst | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/man/chpl.rst b/man/chpl.rst index 0023e2b174cb..9d5652fbd801 100644 --- a/man/chpl.rst +++ b/man/chpl.rst @@ -143,6 +143,51 @@ OPTIONS operation may be race condition and will warn with this flag. Defaults to not printing race condition warnings. +**\--[no-]warn-int-uint** + + Enable [disable] compilation warnings for when implicitly converting + from a value of ``int`` type of any width to a ``uint`` value. + +**\--[no-]warn-small-integral-real** + + Enable [disable] compilation warnings for when implicitly converting + from a value of small integral type to a small floating-point value. + More specifically, it will warn when implicitly converting something + of type ``int(t)`` or ``uint(t)`` where ``t<64``, to something of + type ``real(u)`` or ``complex(2*u)`` where ``u<64``. + +**\--[no-]warn-integral-real** + + Enable [disable] compilation warnings for when implicitly converting + from a value of ``int`` or ``uint`` type of any width to a ``real`` + or ``complex`` type of any width. + +**\--[no-]warn-real-real** + + Enable [disable] compilation warnings for when implicitly converting + from a floating-point type of one precision to another. That includes + implicitly converting from ``real(32)`` to ``real(64)`` as well as + similar cases with ``imag`` and ``complex`` types. + +**\--[no-]warn-integral-integral** + + Enable [disable] compilation warnings for when implicitly converting + from a value of integral type to another integral type of different width. + (An integral type is an ``int`` or ``uint`` type). + +**\--[no-]warn-implicit-numeric-conversions** + + Enable [disable] the above compilation warnings for implicitly + converting between numeric types. + +**\--[no-]warn-param-implicit-numeric-conversions** + + When used in conjunction with ``warn-int-uint``, + ``--warn-real-real``, or ``--warn-integral-integral``, this flag + enables [or disables] these compilation warnings about implicitly + converting between numeric types to also apply when the converted + value is a ``param``. + *Parallelism Control Options* **\--[no-]local** From 21bd0d93379d7492bc9f619755b47b40c849ea04 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 13:14:20 -0500 Subject: [PATCH 09/25] Update for warning wording adjustment --- Signed-off-by: Michael Ferguson --- test/compflags/ferguson/warn-int-uint.good | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/compflags/ferguson/warn-int-uint.good b/test/compflags/ferguson/warn-int-uint.good index 0f84e49c9d09..5d1eba27dea2 100644 --- a/test/compflags/ferguson/warn-int-uint.good +++ b/test/compflags/ferguson/warn-int-uint.good @@ -1,24 +1,24 @@ warn-int-uint.chpl:13: In function 'ret_v': -warn-int-uint.chpl:15: warning: potentially surprising int->uint implicit conversion +warn-int-uint.chpl:15: warning: potentially surprising implicit conversion from 'int(64)' to 'uint(64)' warn-int-uint.chpl:15: note: add a cast :uint(64) to avoid this warning warn-int-uint.chpl:17: In function 'ret_negone': -warn-int-uint.chpl:19: warning: potentially surprising int->uint implicit conversion +warn-int-uint.chpl:19: warning: potentially surprising implicit conversion from 'int(64)' to 'uint(64)' warn-int-uint.chpl:19: note: add a cast :uint(64) to avoid this warning -warn-int-uint.chpl:39: warning: potentially surprising int->uint implicit conversion +warn-int-uint.chpl:39: warning: potentially surprising implicit conversion from 'int(64)' to 'uint(64)' warn-int-uint.chpl:39: note: add a cast :uint(64) to avoid this warning -warn-int-uint.chpl:41: warning: potentially surprising int->uint implicit conversion +warn-int-uint.chpl:41: warning: potentially surprising implicit conversion from 'int(64)' to 'uint(64)' warn-int-uint.chpl:41: note: add a cast :uint(64) to avoid this warning -warn-int-uint.chpl:46: warning: potentially surprising int->uint implicit conversion +warn-int-uint.chpl:46: warning: potentially surprising implicit conversion from 'int(64)' to 'uint(64)' warn-int-uint.chpl:46: note: add a cast :uint(64) to avoid this warning -warn-int-uint.chpl:48: warning: potentially surprising int->uint implicit conversion +warn-int-uint.chpl:48: warning: potentially surprising implicit conversion from 'int(64)' to 'uint(64)' warn-int-uint.chpl:48: note: add a cast :uint(64) to avoid this warning -warn-int-uint.chpl:53: warning: potentially surprising int->uint implicit conversion +warn-int-uint.chpl:53: warning: potentially surprising implicit conversion from 'int(64)' to 'uint(64)' warn-int-uint.chpl:53: note: add a cast :uint(64) to avoid this warning -warn-int-uint.chpl:55: warning: potentially surprising int->uint implicit conversion +warn-int-uint.chpl:55: warning: potentially surprising implicit conversion from 'int(64)' to 'uint(64)' warn-int-uint.chpl:55: note: add a cast :uint(64) to avoid this warning -warn-int-uint.chpl:40: warning: potentially surprising int->uint implicit conversion +warn-int-uint.chpl:40: warning: potentially surprising implicit conversion from 'int(64)' to 'uint(64)' warn-int-uint.chpl:40: note: add a cast :uint(64) to avoid this warning -warn-int-uint.chpl:47: warning: potentially surprising int->uint implicit conversion +warn-int-uint.chpl:47: warning: potentially surprising implicit conversion from 'int(64)' to 'uint(64)' warn-int-uint.chpl:47: note: add a cast :uint(64) to avoid this warning -warn-int-uint.chpl:54: warning: potentially surprising int->uint implicit conversion +warn-int-uint.chpl:54: warning: potentially surprising implicit conversion from 'int(64)' to 'uint(64)' warn-int-uint.chpl:54: note: add a cast :uint(64) to avoid this warning From 9314906d79afd34765dd2efb5039fb3b342ca2cf Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 13:28:16 -0500 Subject: [PATCH 10/25] Update userhelp.good --- Signed-off-by: Michael Ferguson --- test/compflags/bradc/help/userhelp.good | 28 +++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/test/compflags/bradc/help/userhelp.good b/test/compflags/bradc/help/userhelp.good index f53e2b24709b..ec16f427c004 100644 --- a/test/compflags/bradc/help/userhelp.good +++ b/test/compflags/bradc/help/userhelp.good @@ -10,8 +10,8 @@ Module Processing Options: Warning and Language Control Options: --[no-]permit-unhandled-module-errors - Permit unhandled errors in explicit - modules; such errors halt at runtime + Permit unhandled thrown errors; such + errors halt at runtime --[no-]warn-unstable Enable [disable] warnings for uses of language features that are in flux --[no-]warnings Enable [disable] output of warnings @@ -25,6 +25,30 @@ Warning and Language Control Options: source --[no-]warn-potential-races Enable [disable] output of warnings for potential race conditions + --[no-]warn-int-uint Enable [disable] warnings for + potentially negative 'int' values + implicitly converted to 'uint' + --[no-]warn-small-integral-real Enable [disable] warnings for implicitly + converting a small int/uint to a small + real/complex + --[no-]warn-integral-real Enable [disable] warnings for implicitly + converting an int/uint to a real/complex + --[no-]warn-real-real Enable [disable] warnings for implicitly + converting a real/imag/complex to a + real/imag/complex with different + precision + --[no-]warn-integral-integral Enable [disable] warnings for implicitly + converting an int/uint to an int/uint + with different size + --[no-]warn-implicit-numeric-conversions + Enable [disable] warnings for implicitly + converting a value of numeric type to a + different numeric type + --[no-]warn-param-implicit-numeric-conversions + Enable [disable] int-uint, real-real, + and integral-integral implicit + conversion warnings to apply to 'param' + values Parallelism Control Options: --[no-]local Target one [many] locale[s] From 2c916929b90cf4596c249d5697a8c0150137cbe4 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 13:31:22 -0500 Subject: [PATCH 11/25] Rebuild chpl-completion.bash --- Signed-off-by: Michael Ferguson --- util/chpl-completion.bash | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/util/chpl-completion.bash b/util/chpl-completion.bash index f370c5344d05..aca721256d8a 100644 --- a/util/chpl-completion.bash +++ b/util/chpl-completion.bash @@ -290,8 +290,14 @@ _chpl () --no-warn-array-of-range \ --no-warn-const-loops \ --no-warn-domain-literal \ +--no-warn-implicit-numeric-conversions \ --no-warn-int-uint \ +--no-warn-integral-integral \ +--no-warn-integral-real \ +--no-warn-param-implicit-numeric-conversions \ --no-warn-potential-races \ +--no-warn-real-real \ +--no-warn-small-integral-real \ --no-warn-special \ --no-warn-tuple-iteration \ --no-warn-unknown-attribute-toolname \ @@ -388,8 +394,14 @@ _chpl () --warn-array-of-range \ --warn-const-loops \ --warn-domain-literal \ +--warn-implicit-numeric-conversions \ --warn-int-uint \ +--warn-integral-integral \ +--warn-integral-real \ +--warn-param-implicit-numeric-conversions \ --warn-potential-races \ +--warn-real-real \ +--warn-small-integral-real \ --warn-special \ --warn-tuple-iteration \ --warn-unknown-attribute-toolname \ @@ -534,7 +546,14 @@ _chpl () --no-task-tracking \ --no-tuple-copy-opt \ --no-vectorize \ +--no-warn-implicit-numeric-conversions \ +--no-warn-int-uint \ +--no-warn-integral-integral \ +--no-warn-integral-real \ +--no-warn-param-implicit-numeric-conversions \ --no-warn-potential-races \ +--no-warn-real-real \ +--no-warn-small-integral-real \ --no-warn-unknown-attribute-toolname \ --no-warn-unstable \ --no-warnings \ @@ -581,7 +600,14 @@ _chpl () --using-attribute-toolname \ --vectorize \ --version \ +--warn-implicit-numeric-conversions \ +--warn-int-uint \ +--warn-integral-integral \ +--warn-integral-real \ +--warn-param-implicit-numeric-conversions \ --warn-potential-races \ +--warn-real-real \ +--warn-small-integral-real \ --warn-unknown-attribute-toolname \ --warn-unstable \ --warnings \ From ef03ef2a53707885a51dc5a5c364f73293d3a5b6 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 15:09:56 -0500 Subject: [PATCH 12/25] Also warn for implicit conversions for param-returning functions for e.g. sqrt(2:int(16)) --- Signed-off-by: Michael Ferguson --- compiler/resolution/postFold.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compiler/resolution/postFold.cpp b/compiler/resolution/postFold.cpp index 571e67069afa..0d9e0cdadaf5 100644 --- a/compiler/resolution/postFold.cpp +++ b/compiler/resolution/postFold.cpp @@ -173,6 +173,17 @@ static Expr* postFoldNormal(CallExpr* call) { VarSymbol* ret = toVarSymbol(fn->getReturnSymbol()); if (ret != NULL && ret->immediate != NULL) { + + // warn for certain numeric implicit conversions before we forget + // everything about the call + for_formals_actuals(formal, actual, call) { + if (SymExpr* actualSe = toSymExpr(actual)) { + warnForSomeNumericConversions(call, + formal->typeInfo(), actual->typeInfo(), + actualSe->symbol()); + } + } + retval = new SymExpr(ret); call->replace(retval); From b1da29d8872c56f4b02514a11fea452c702c7420 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 15:19:00 -0500 Subject: [PATCH 13/25] Introduce directory for implicit numeric conv warnings --- Signed-off-by: Michael Ferguson --- .../{ => implicit-conversion-warnings}/warn-int-uint.chpl | 0 .../{ => implicit-conversion-warnings}/warn-int-uint.compopts | 0 .../{ => implicit-conversion-warnings}/warn-int-uint.good | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename test/compflags/ferguson/{ => implicit-conversion-warnings}/warn-int-uint.chpl (100%) rename test/compflags/ferguson/{ => implicit-conversion-warnings}/warn-int-uint.compopts (100%) rename test/compflags/ferguson/{ => implicit-conversion-warnings}/warn-int-uint.good (100%) diff --git a/test/compflags/ferguson/warn-int-uint.chpl b/test/compflags/ferguson/implicit-conversion-warnings/warn-int-uint.chpl similarity index 100% rename from test/compflags/ferguson/warn-int-uint.chpl rename to test/compflags/ferguson/implicit-conversion-warnings/warn-int-uint.chpl diff --git a/test/compflags/ferguson/warn-int-uint.compopts b/test/compflags/ferguson/implicit-conversion-warnings/warn-int-uint.compopts similarity index 100% rename from test/compflags/ferguson/warn-int-uint.compopts rename to test/compflags/ferguson/implicit-conversion-warnings/warn-int-uint.compopts diff --git a/test/compflags/ferguson/warn-int-uint.good b/test/compflags/ferguson/implicit-conversion-warnings/warn-int-uint.good similarity index 100% rename from test/compflags/ferguson/warn-int-uint.good rename to test/compflags/ferguson/implicit-conversion-warnings/warn-int-uint.good From 0e6d10e6b33462bf32c16ca9b4ac6710a38f14fb Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 15:33:42 -0500 Subject: [PATCH 14/25] Turn off warning for test of sqrt behavior --- Signed-off-by: Michael Ferguson --- test/expressions/figueroa/sqrt_with_int_arg.compopts | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/expressions/figueroa/sqrt_with_int_arg.compopts diff --git a/test/expressions/figueroa/sqrt_with_int_arg.compopts b/test/expressions/figueroa/sqrt_with_int_arg.compopts new file mode 100644 index 000000000000..911cb0b51e1a --- /dev/null +++ b/test/expressions/figueroa/sqrt_with_int_arg.compopts @@ -0,0 +1 @@ +--no-warn-small-integral-real From 0515f8f77657b4d54201150fcb667ec20e5e3a5c Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 15:36:04 -0500 Subject: [PATCH 15/25] Add more testing of implicit conversion warnings --- Signed-off-by: Michael Ferguson --- .../warn-int-uint.compopts | 1 + .../warn-integral-integral.chpl | 7 +++ .../warn-integral-integral.compopts | 2 + .../warn-integral-integral.good | 3 ++ .../warn-integral-real.chpl | 15 ++++++ .../warn-integral-real.compopts | 2 + .../warn-integral-real.good | 6 +++ .../warn-real-real.chpl | 7 +++ .../warn-real-real.compopts | 2 + .../warn-real-real.good | 3 ++ .../warn-small-integral-real.chpl | 51 +++++++++++++++++++ .../warn-small-integral-real.good | 27 ++++++++++ 12 files changed, 126 insertions(+) create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.chpl create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.compopts create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.good create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.chpl create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.compopts create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.good create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.chpl create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.compopts create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.good create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.chpl create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.good diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-int-uint.compopts b/test/compflags/ferguson/implicit-conversion-warnings/warn-int-uint.compopts index eb1e1f8ce66b..739f2dd6b58f 100644 --- a/test/compflags/ferguson/implicit-conversion-warnings/warn-int-uint.compopts +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-int-uint.compopts @@ -1 +1,2 @@ --warn-int-uint +--warn-implicit-numeric-conversions diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.chpl b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.chpl new file mode 100644 index 000000000000..da0e12818711 --- /dev/null +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.chpl @@ -0,0 +1,7 @@ +proc test1fn(arg: int) { } + +proc test1() { + var myInt32: int(32) = 2; + test1fn(myInt32); +} +test1(); diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.compopts b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.compopts new file mode 100644 index 000000000000..bba69d06a5ed --- /dev/null +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.compopts @@ -0,0 +1,2 @@ +--warn-integral-integral +--warn-implicit-numeric-conversions diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.good b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.good new file mode 100644 index 000000000000..3c30261188a2 --- /dev/null +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.good @@ -0,0 +1,3 @@ +warn-integral-integral.chpl:3: In function 'test1': +warn-integral-integral.chpl:5: warning: implicit conversion from 'int(32)' to 'int(64)' +warn-integral-integral.chpl:5: note: add a cast :int(64) to avoid this warning diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.chpl b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.chpl new file mode 100644 index 000000000000..71e1898be5ba --- /dev/null +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.chpl @@ -0,0 +1,15 @@ +proc test1fn(arg: real(32)) { } + +proc test1() { + var myInt: int = 22; + test1fn(myInt); +} +test1(); + +proc test2fn(arg: real(64)) { } + +proc test2() { + var myUint16: uint(16) = 22; + test2fn(myUint16); +} +test2(); diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.compopts b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.compopts new file mode 100644 index 000000000000..f4a9c8b1d6cf --- /dev/null +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.compopts @@ -0,0 +1,2 @@ +--warn-integral-real +--warn-implicit-numeric-conversions diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.good b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.good new file mode 100644 index 000000000000..88afcb398c27 --- /dev/null +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.good @@ -0,0 +1,6 @@ +warn-integral-real.chpl:3: In function 'test1': +warn-integral-real.chpl:5: warning: implicit conversion from 'int(64)' to 'real(32)' +warn-integral-real.chpl:5: note: add a cast :real(32) to avoid this warning +warn-integral-real.chpl:11: In function 'test2': +warn-integral-real.chpl:13: warning: implicit conversion from 'uint(16)' to 'real(64)' +warn-integral-real.chpl:13: note: add a cast :real(64) to avoid this warning diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.chpl b/test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.chpl new file mode 100644 index 000000000000..ce07d56075c7 --- /dev/null +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.chpl @@ -0,0 +1,7 @@ +proc test1fn(arg: real) { } + +proc test1() { + var myReal32: real(32) = 2.0; + test1fn(myReal32); +} +test1(); diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.compopts b/test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.compopts new file mode 100644 index 000000000000..984d50066074 --- /dev/null +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.compopts @@ -0,0 +1,2 @@ +--warn-real-real +--warn-implicit-numeric-conversions diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.good b/test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.good new file mode 100644 index 000000000000..ac7c6605f365 --- /dev/null +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.good @@ -0,0 +1,3 @@ +warn-real-real.chpl:3: In function 'test1': +warn-real-real.chpl:5: warning: implicit conversion from 'real(32)' to 'real(64)' +warn-real-real.chpl:5: note: add a cast :real(64) to avoid this warning diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.chpl b/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.chpl new file mode 100644 index 000000000000..92b44adf51e2 --- /dev/null +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.chpl @@ -0,0 +1,51 @@ +use Math; + +proc test1fn() { + var red: uint(8) = 1; + var green: uint(8) = 2; + var blue: uint(8) = 3; + return 0.2126*red + 0.7152*green + 0.0722*blue; +} + +proc test1() { + var x = test1fn(); + writeln("test1fn() = ", x, " : ", x.type:string); +} +test1(); + +proc test2() { + var myInt16: int(16) = 1; + var result = sin(myInt16); + writeln("sin(myInt16) = ", result, " : ", result.type:string); +} +test2(); + +proc test3() { + var x: int(16) = 1; + var y = 2.0; + var z = sqrt(x) + sin(y); + writeln("z = ", z, " : ", z.type:string); +} +test3(); + +proc test4() { + param two: uint(16) = 2; + var x = sqrt(two); + writeln("sqrt(2:uint(16)) = ", x, " : ", x.type:string); +} +test4(); + +proc test5fn(arg: real(32)) { } + +proc test5() { + test5fn(1:int(16)); +} +test5(); + +proc test6fn(arg: real(32)) param { return 1.0:real(32); } + +proc test6() { + var x = test6fn(1:int(16)); + writeln("test6 ", x, " : ", x.type:string); +} +test6(); diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.good b/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.good new file mode 100644 index 000000000000..6e1110200a27 --- /dev/null +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.good @@ -0,0 +1,27 @@ +warn-small-integral-real.chpl:3: In function 'test1fn': +warn-small-integral-real.chpl:7: warning: potentially surprising implicit conversion from 'uint(8)' to 'real(32)' +warn-small-integral-real.chpl:7: note: add a cast :real(32) to avoid this warning +warn-small-integral-real.chpl:7: warning: potentially surprising implicit conversion from 'uint(8)' to 'real(32)' +warn-small-integral-real.chpl:7: note: add a cast :real(32) to avoid this warning +warn-small-integral-real.chpl:7: warning: potentially surprising implicit conversion from 'uint(8)' to 'real(32)' +warn-small-integral-real.chpl:7: note: add a cast :real(32) to avoid this warning +warn-small-integral-real.chpl:16: In function 'test2': +warn-small-integral-real.chpl:18: warning: potentially surprising implicit conversion from 'int(16)' to 'real(32)' +warn-small-integral-real.chpl:18: note: add a cast :real(32) to avoid this warning +warn-small-integral-real.chpl:23: In function 'test3': +warn-small-integral-real.chpl:26: warning: potentially surprising implicit conversion from 'int(16)' to 'real(32)' +warn-small-integral-real.chpl:26: note: add a cast :real(32) to avoid this warning +warn-small-integral-real.chpl:31: In function 'test4': +warn-small-integral-real.chpl:33: warning: potentially surprising implicit conversion from 'uint(16)' to 'real(32)' +warn-small-integral-real.chpl:33: note: add a cast :real(32) to avoid this warning +warn-small-integral-real.chpl:40: In function 'test5': +warn-small-integral-real.chpl:41: warning: potentially surprising implicit conversion from 'int(16)' to 'real(32)' +warn-small-integral-real.chpl:41: note: add a cast :real(32) to avoid this warning +warn-small-integral-real.chpl:47: In function 'test6': +warn-small-integral-real.chpl:48: warning: potentially surprising implicit conversion from 'int(16)' to 'real(32)' +warn-small-integral-real.chpl:48: note: add a cast :real(32) to avoid this warning +test1fn() = 1.8596 : real(32) +sin(myInt16) = 0.841471 : real(32) +z = 1.9093 : real(64) +sqrt(2:uint(16)) = 1.41421 : real(32) +test6 1.0 : real(32) From 3d701e82ec2a85073ab5fbee5a89a584763ef3fd Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 15:54:55 -0500 Subject: [PATCH 16/25] Adjust user module handling, user-module only for some --- Signed-off-by: Michael Ferguson --- compiler/resolution/functionResolution.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index 9b4f3c359379..496ebd144345 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -8217,10 +8217,8 @@ void warnForSomeNumericConversions(BaseAST* context, } bool userModule = false; - if (DefExpr* def = actual->defPoint) { - if (ModuleSymbol* mod = def->getModule()) { - userModule = mod->modTag == MOD_USER; - } + if (ModuleSymbol* mod = context->getModule()) { + userModule = mod->modTag == MOD_USER; } // consider warning for int -> uint implicit conversion @@ -8242,7 +8240,8 @@ void warnForSomeNumericConversions(BaseAST* context, // If it's a param, warn only if it is negative. // Otherwise, warn. - if (isNegParam || !isParam || fWarnParamImplicitNumericConversions) { + if (isNegParam || !isParam || + (fWarnParamImplicitNumericConversions && userModule)) { if (fWarnIntUint) { USR_WARN(context, "potentially surprising implicit conversion " "from '%s' to '%s'", From 72168b094ea7a157db85ff651dbfdaa51f2ebbc8 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 15:57:31 -0500 Subject: [PATCH 17/25] Add testing for --warn-param-implicit-numeric-conversions --- Signed-off-by: Michael Ferguson --- .../warn-param.chpl | 26 +++++++++++++++++++ .../warn-param.compopts | 2 ++ .../warn-param.empty.good | 0 .../warn-param.good | 12 +++++++++ 4 files changed, 40 insertions(+) create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-param.chpl create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-param.compopts create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-param.empty.good create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-param.good diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-param.chpl b/test/compflags/ferguson/implicit-conversion-warnings/warn-param.chpl new file mode 100644 index 000000000000..ca1d449dd406 --- /dev/null +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-param.chpl @@ -0,0 +1,26 @@ +proc acceptsUint(arg: uint) { } +proc checkPositiveIntUint() { + param p = 11; + acceptsUint(p); +} +checkPositiveIntUint(); + +proc acceptsReal(arg: real) { } +proc checkRealReal() { + param p = 2.25:real(32); + acceptsReal(p); +} +checkRealReal(); + +proc acceptsInt(arg: int) { } +proc checkIntInt() { + param p = 33: int(16); + acceptsInt(p); +} +checkIntInt(); + +proc checkUintUint() { + param p = 44: uint(16); + acceptsUint(p); +} +checkUintUint(); diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-param.compopts b/test/compflags/ferguson/implicit-conversion-warnings/warn-param.compopts new file mode 100644 index 000000000000..c288a370269a --- /dev/null +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-param.compopts @@ -0,0 +1,2 @@ +--warn-implicit-numeric-conversions # warn-param.empty.good +--warn-implicit-numeric-conversions --warn-param-implicit-numeric-conversions diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-param.empty.good b/test/compflags/ferguson/implicit-conversion-warnings/warn-param.empty.good new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-param.good b/test/compflags/ferguson/implicit-conversion-warnings/warn-param.good new file mode 100644 index 000000000000..e8e6a39b8657 --- /dev/null +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-param.good @@ -0,0 +1,12 @@ +warn-param.chpl:2: In function 'checkPositiveIntUint': +warn-param.chpl:4: warning: potentially surprising implicit conversion from 'int(64)' to 'uint(64)' +warn-param.chpl:4: note: add a cast :uint(64) to avoid this warning +warn-param.chpl:9: In function 'checkRealReal': +warn-param.chpl:11: warning: implicit conversion from 'real(32)' to 'real(64)' +warn-param.chpl:11: note: add a cast :real(64) to avoid this warning +warn-param.chpl:16: In function 'checkIntInt': +warn-param.chpl:18: warning: implicit conversion from 'int(16)' to 'int(64)' +warn-param.chpl:18: note: add a cast :int(64) to avoid this warning +warn-param.chpl:22: In function 'checkUintUint': +warn-param.chpl:24: warning: implicit conversion from 'uint(16)' to 'uint(64)' +warn-param.chpl:24: note: add a cast :uint(64) to avoid this warning From 5758e68853a62fed4b7d16709f9f8d894338c1e0 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 5 Mar 2024 17:26:47 -0500 Subject: [PATCH 18/25] Fix symbolic link to moved file --- Signed-off-by: Michael Ferguson --- test/unstable/warn-int-uint.chpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unstable/warn-int-uint.chpl b/test/unstable/warn-int-uint.chpl index cbd5e0ef07ce..ae1f1bdc94af 120000 --- a/test/unstable/warn-int-uint.chpl +++ b/test/unstable/warn-int-uint.chpl @@ -1 +1 @@ -../compflags/ferguson/warn-int-uint.chpl \ No newline at end of file +../compflags/ferguson/implicit-conversion-warnings/warn-int-uint.chpl \ No newline at end of file From dc899e4b2bcb28f55b12e3b5b15eda33108d274f Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 6 Mar 2024 15:40:21 -0500 Subject: [PATCH 19/25] Turn the new warning off-by-default --- Signed-off-by: Michael Ferguson --- compiler/main/driver.cpp | 2 +- .../warn-small-integral-real.compopts | 1 + test/expressions/figueroa/sqrt_with_int_arg.compopts | 1 - test/library/standard/AutoMath/absparams.chpl | 4 ++-- test/library/standard/AutoMath/sqrtparams.compopts | 1 - test/release/examples/primers/records.chpl | 2 +- test/studies/ml/lib/MNIST.chpl | 3 ++- test/types/scalar/vass/int8toReal32.good | 8 -------- 8 files changed, 7 insertions(+), 15 deletions(-) create mode 100644 test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.compopts delete mode 100644 test/expressions/figueroa/sqrt_with_int_arg.compopts delete mode 100644 test/library/standard/AutoMath/sqrtparams.compopts diff --git a/compiler/main/driver.cpp b/compiler/main/driver.cpp index 52cf4d6437a4..76ec60be71a8 100644 --- a/compiler/main/driver.cpp +++ b/compiler/main/driver.cpp @@ -221,7 +221,7 @@ bool fLLVMWideOpt = false; // warnings for various implicit numeric conversions bool fWarnIntUint = false; -bool fWarnSmallIntegralReal = true; +bool fWarnSmallIntegralReal = false; bool fWarnIntegralReal = false; bool fWarnRealReal = false; bool fWarnIntegralIntegral = false; diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.compopts b/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.compopts new file mode 100644 index 000000000000..a0da74fd42a7 --- /dev/null +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.compopts @@ -0,0 +1 @@ +--warn-small-integral-real diff --git a/test/expressions/figueroa/sqrt_with_int_arg.compopts b/test/expressions/figueroa/sqrt_with_int_arg.compopts deleted file mode 100644 index 911cb0b51e1a..000000000000 --- a/test/expressions/figueroa/sqrt_with_int_arg.compopts +++ /dev/null @@ -1 +0,0 @@ ---no-warn-small-integral-real diff --git a/test/library/standard/AutoMath/absparams.chpl b/test/library/standard/AutoMath/absparams.chpl index 302565170f61..92737c57fdd7 100644 --- a/test/library/standard/AutoMath/absparams.chpl +++ b/test/library/standard/AutoMath/absparams.chpl @@ -20,8 +20,8 @@ param m64negOne:imag(64) = -1.0i; testabs(m64negOne); proc testabs(param x) { param p = abs(x); - assert(p:real == 1.0); + assert(p == 1.0); // also check non-param version, just for good measure var v = x; - assert(abs(v):real == 1.0); + assert(abs(v) == 1.0); } diff --git a/test/library/standard/AutoMath/sqrtparams.compopts b/test/library/standard/AutoMath/sqrtparams.compopts deleted file mode 100644 index 7a57e0c86fbb..000000000000 --- a/test/library/standard/AutoMath/sqrtparams.compopts +++ /dev/null @@ -1 +0,0 @@ ---no-warn-implicit-numeric-conversions diff --git a/test/release/examples/primers/records.chpl b/test/release/examples/primers/records.chpl index e744916c53ef..dd75bdf16831 100644 --- a/test/release/examples/primers/records.chpl +++ b/test/release/examples/primers/records.chpl @@ -47,7 +47,7 @@ writeln(myColor); // output: (red = 0, green = 0, blue = 0) // Note that inside of a method, the fields may be accessed // by name. Additionally `this` refers to the entire record. proc Color.luminance() { - return 0.2126*red:real + 0.7152*green:real + 0.0722*blue:real; + return 0.2126*red + 0.7152*green + 0.0722*blue; } writeln(taupe.luminance()); diff --git a/test/studies/ml/lib/MNIST.chpl b/test/studies/ml/lib/MNIST.chpl index a80f4b826564..603adeb0838b 100644 --- a/test/studies/ml/lib/MNIST.chpl +++ b/test/studies/ml/lib/MNIST.chpl @@ -27,7 +27,8 @@ proc loadImages(num: int, fileName: string = "week2/emnist/data/train-images-idx raw[i,j] = fr.read(uint(8)); } } - var image: [imageDomain] real = raw:real / 255.0; + // note: this is a 32-bit divide today + var image: [imageDomain] real = raw / 255.0; return image; } const imageBatchDomain = {0..#num}; diff --git a/test/types/scalar/vass/int8toReal32.good b/test/types/scalar/vass/int8toReal32.good index edf10ed04933..9b34342c7fdb 100644 --- a/test/types/scalar/vass/int8toReal32.good +++ b/test/types/scalar/vass/int8toReal32.good @@ -1,10 +1,2 @@ -int8toReal32.chpl:22: warning: potentially surprising implicit conversion from 'int(8)' to 'real(32)' -int8toReal32.chpl:22: note: add a cast :real(32) to avoid this warning -int8toReal32.chpl:23: warning: potentially surprising implicit conversion from 'uint(8)' to 'real(32)' -int8toReal32.chpl:23: note: add a cast :real(32) to avoid this warning -int8toReal32.chpl:24: warning: potentially surprising implicit conversion from 'int(16)' to 'real(32)' -int8toReal32.chpl:24: note: add a cast :real(32) to avoid this warning -int8toReal32.chpl:25: warning: potentially surprising implicit conversion from 'uint(16)' to 'real(32)' -int8toReal32.chpl:25: note: add a cast :real(32) to avoid this warning (55.0, 66.0, 77.0, 88.0) (11.0, 22.0, 33.0, 44.0) From a619336af8e6fc030a70e89564c5938478ddf5cd Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 6 Mar 2024 15:40:32 -0500 Subject: [PATCH 20/25] Remove commented-out code --- Signed-off-by: Michael Ferguson --- compiler/resolution/functionResolution.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index 496ebd144345..e134fcaf776e 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -6081,13 +6081,6 @@ static void discardWorsePromoting(Vec& candidates, } } -/* -static void warnSurprisingImpConvReal(Vec& candidates, - const DisambiguationContext& DC, - std::vector& discarded) { -}*/ - - // Discard any candidate that has a worse argument mapping than another // candidate. static void discardWorseArgs(Vec& candidates, @@ -6099,10 +6092,6 @@ static void discardWorseArgs(Vec& candidates, // because it is a less good match than another candidate. std::vector notBest(candidates.n, false); - // warn in some cases, using notBest for temporary space, - // and clearing notBest at the end. - //warnSurprisingImpConvReal(candidates, DC, discarded); - for (int i = 0; i < candidates.n; ++i) { if (discarded[i]) { continue; From 433828245ed8f2bb4621d626978af43b413d37fc Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 6 Mar 2024 15:45:13 -0500 Subject: [PATCH 21/25] Adjust unstable warning to focus on 8 and 16 bit --- Signed-off-by: Michael Ferguson --- compiler/resolution/functionResolution.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index e134fcaf776e..9d0aa5fe67ae 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -8253,14 +8253,17 @@ void warnForSomeNumericConversions(BaseAST* context, USR_WARN(context, "potentially surprising implicit conversion " "from '%s' to '%s'", toString(actualVt), toString(formalVt)); - } else { - USR_WARN(context, "implicit conversion from non-default-sized integral " - "types to non-default sized floating point " - "types is unstable"); + USR_PRINT(context, "add a cast :%s to avoid this warning", + toString(formalVt)); + return; + } else if (actualWidth < 32) { + // unstable warning focuses on 8 and 16 bit int/uint + USR_WARN(context, "implicit conversion from 8- and 16- bit integral " + "types to 'real(32)' is unstable"); + USR_PRINT(context, "add a cast :%s to avoid this warning", + toString(formalVt)); + return; } - USR_PRINT(context, "add a cast :%s to avoid this warning", - toString(formalVt)); - return; } } From 28b8679e84904194af74f1180f86ba2532611939 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 6 Mar 2024 15:48:49 -0500 Subject: [PATCH 22/25] Add testing for new --warn-unstable behavior --- Signed-off-by: Michael Ferguson --- .../warn-small-integral-real.chpl | 8 ++++++ .../warn-small-integral-real.good | 3 +++ test/unstable/warn-small-integral-real.chpl | 1 + test/unstable/warn-small-integral-real.good | 27 +++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 120000 test/unstable/warn-small-integral-real.chpl create mode 100644 test/unstable/warn-small-integral-real.good diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.chpl b/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.chpl index 92b44adf51e2..452f9e14907f 100644 --- a/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.chpl +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.chpl @@ -49,3 +49,11 @@ proc test6() { writeln("test6 ", x, " : ", x.type:string); } test6(); + +proc test7fn(arg: real(32)) { } + +proc test7() { + var myInt32: int(32); + test7fn(myInt32); +} +test7(); diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.good b/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.good index 6e1110200a27..95cc71c1508f 100644 --- a/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.good +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.good @@ -20,6 +20,9 @@ warn-small-integral-real.chpl:41: note: add a cast :real(32) to avoid this warni warn-small-integral-real.chpl:47: In function 'test6': warn-small-integral-real.chpl:48: warning: potentially surprising implicit conversion from 'int(16)' to 'real(32)' warn-small-integral-real.chpl:48: note: add a cast :real(32) to avoid this warning +warn-small-integral-real.chpl:55: In function 'test7': +warn-small-integral-real.chpl:57: warning: potentially surprising implicit conversion from 'int(32)' to 'real(32)' +warn-small-integral-real.chpl:57: note: add a cast :real(32) to avoid this warning test1fn() = 1.8596 : real(32) sin(myInt16) = 0.841471 : real(32) z = 1.9093 : real(64) diff --git a/test/unstable/warn-small-integral-real.chpl b/test/unstable/warn-small-integral-real.chpl new file mode 120000 index 000000000000..8e93e5bcef9f --- /dev/null +++ b/test/unstable/warn-small-integral-real.chpl @@ -0,0 +1 @@ +../compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.chpl \ No newline at end of file diff --git a/test/unstable/warn-small-integral-real.good b/test/unstable/warn-small-integral-real.good new file mode 100644 index 000000000000..601be6d1f934 --- /dev/null +++ b/test/unstable/warn-small-integral-real.good @@ -0,0 +1,27 @@ +warn-small-integral-real.chpl:3: In function 'test1fn': +warn-small-integral-real.chpl:7: warning: implicit conversion from 8- and 16- bit integral types to 'real(32)' is unstable +warn-small-integral-real.chpl:7: note: add a cast :real(32) to avoid this warning +warn-small-integral-real.chpl:7: warning: implicit conversion from 8- and 16- bit integral types to 'real(32)' is unstable +warn-small-integral-real.chpl:7: note: add a cast :real(32) to avoid this warning +warn-small-integral-real.chpl:7: warning: implicit conversion from 8- and 16- bit integral types to 'real(32)' is unstable +warn-small-integral-real.chpl:7: note: add a cast :real(32) to avoid this warning +warn-small-integral-real.chpl:16: In function 'test2': +warn-small-integral-real.chpl:18: warning: implicit conversion from 8- and 16- bit integral types to 'real(32)' is unstable +warn-small-integral-real.chpl:18: note: add a cast :real(32) to avoid this warning +warn-small-integral-real.chpl:23: In function 'test3': +warn-small-integral-real.chpl:26: warning: implicit conversion from 8- and 16- bit integral types to 'real(32)' is unstable +warn-small-integral-real.chpl:26: note: add a cast :real(32) to avoid this warning +warn-small-integral-real.chpl:31: In function 'test4': +warn-small-integral-real.chpl:33: warning: implicit conversion from 8- and 16- bit integral types to 'real(32)' is unstable +warn-small-integral-real.chpl:33: note: add a cast :real(32) to avoid this warning +warn-small-integral-real.chpl:40: In function 'test5': +warn-small-integral-real.chpl:41: warning: implicit conversion from 8- and 16- bit integral types to 'real(32)' is unstable +warn-small-integral-real.chpl:41: note: add a cast :real(32) to avoid this warning +warn-small-integral-real.chpl:47: In function 'test6': +warn-small-integral-real.chpl:48: warning: implicit conversion from 8- and 16- bit integral types to 'real(32)' is unstable +warn-small-integral-real.chpl:48: note: add a cast :real(32) to avoid this warning +test1fn() = 1.8596 : real(32) +sin(myInt16) = 0.841471 : real(32) +z = 1.9093 : real(64) +sqrt(2:uint(16)) = 1.41421 : real(32) +test6 1.0 : real(32) From af62535115a02b3ff96645802d71661582fb1e24 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 6 Mar 2024 16:27:02 -0500 Subject: [PATCH 23/25] Adjust flag names --- Signed-off-by: Michael Ferguson --- compiler/include/driver.h | 6 ++--- compiler/main/driver.cpp | 24 +++++++++---------- compiler/resolution/functionResolution.cpp | 9 +++---- man/chpl.rst | 10 ++++---- test/compflags/bradc/help/userhelp.good | 21 +++++++++------- .../warn-int-uint.compopts | 2 +- .../warn-integral-integral.compopts | 2 +- .../warn-integral-real.compopts | 2 +- .../warn-real-real.compopts | 2 +- .../warn-small-integral-real.chpl | 2 +- .../warn-small-integral-real.compopts | 2 +- 11 files changed, 43 insertions(+), 39 deletions(-) diff --git a/compiler/include/driver.h b/compiler/include/driver.h index c561ceccb678..963be9341acc 100644 --- a/compiler/include/driver.h +++ b/compiler/include/driver.h @@ -239,9 +239,9 @@ extern bool ignore_errors_for_pass; extern int squelch_header_errors; extern bool fWarnIntUint; -extern bool fWarnSmallIntegralReal; -extern bool fWarnIntegralReal; -extern bool fWarnRealReal; +extern bool fWarnSmallIntegralFloat; +extern bool fWarnIntegralFloat; +extern bool fWarnFloatFloat; extern bool fWarnIntegralIntegral; extern bool fWarnImplicitNumericConversions; extern bool fWarnParamImplicitNumericConversions; diff --git a/compiler/main/driver.cpp b/compiler/main/driver.cpp index 76ec60be71a8..6a73fd376ddb 100644 --- a/compiler/main/driver.cpp +++ b/compiler/main/driver.cpp @@ -221,9 +221,9 @@ bool fLLVMWideOpt = false; // warnings for various implicit numeric conversions bool fWarnIntUint = false; -bool fWarnSmallIntegralReal = false; -bool fWarnIntegralReal = false; -bool fWarnRealReal = false; +bool fWarnSmallIntegralFloat = false; +bool fWarnIntegralFloat = false; +bool fWarnFloatFloat = false; bool fWarnIntegralIntegral = false; bool fWarnImplicitNumericConversions = false; bool fWarnParamImplicitNumericConversions = false; @@ -759,9 +759,9 @@ static void setNumericWarnings(const ArgumentDescription* desc, const char* arg) { bool shouldWarn = fWarnImplicitNumericConversions; fWarnIntUint = shouldWarn; - fWarnSmallIntegralReal = shouldWarn; - fWarnIntegralReal = shouldWarn; - fWarnRealReal = shouldWarn; + fWarnSmallIntegralFloat = shouldWarn; + fWarnIntegralFloat = shouldWarn; + fWarnFloatFloat = shouldWarn; fWarnIntegralIntegral = shouldWarn; } @@ -1320,13 +1320,13 @@ static ArgumentDescription arg_desc[] = { {"warn-unknown-attribute-toolname", ' ', NULL, "Enable [disable] warnings when an unknown tool name is found in an attribute", "N", &fWarnUnknownAttributeToolname, "CHPL_WARN_UNKNOWN_ATTRIBUTE_TOOLNAME", NULL}, {"using-attribute-toolname", ' ', "", "Specify additional tool names for attributes that are expected in the source", "S", NULL, "CHPL_ATTRIBUTE_TOOLNAMES", addUsingAttributeToolname}, {"warn-potential-races", ' ', NULL, "Enable [disable] output of warnings for potential race conditions", "N", &fWarnPotentialRaces, "CHPL_WARN_POTENTIAL_RACES", NULL}, - {"warn-int-uint", ' ', NULL, "Enable [disable] warnings for potentially negative 'int' values implicitly converted to 'uint'", "N", &fWarnIntUint, "CHPL_WARN_INT_UINT", NULL}, - {"warn-small-integral-real", ' ', NULL, "Enable [disable] warnings for implicitly converting a small int/uint to a small real/complex", "N", &fWarnSmallIntegralReal, "CHPL_WARN_SMALL_INTEGRAL_REAL", NULL}, - {"warn-integral-real", ' ', NULL, "Enable [disable] warnings for implicitly converting an int/uint to a real/complex", "N", &fWarnIntegralReal, "CHPL_WARN_INTEGRAL_REAL", NULL}, - {"warn-real-real", ' ', NULL, "Enable [disable] warnings for implicitly converting a real/imag/complex to a real/imag/complex with different precision", "N", &fWarnRealReal, "CHPL_WARN_REAL_REAL", NULL}, - {"warn-integral-integral", ' ', NULL, "Enable [disable] warnings for implicitly converting an int/uint to an int/uint with different size", "N", &fWarnIntegralIntegral, "CHPL_WARN_INTEGRAL_INTEGRAL", NULL}, + {"warn-int-to-uint", ' ', NULL, "Enable [disable] warnings for potentially negative 'int' values implicitly converted to 'uint'", "N", &fWarnIntUint, "CHPL_WARN_INT_TO_UINT", NULL}, + {"warn-small-integral-to-float", ' ', NULL, "Enable [disable] warnings for implicitly converting a small int/uint to a small real/complex", "N", &fWarnSmallIntegralFloat, "CHPL_WARN_SMALL_INTEGRAL_TO_FLOAT", NULL}, + {"warn-integral-to-float", ' ', NULL, "Enable [disable] warnings for implicitly converting an int/uint to a real/complex of any width", "N", &fWarnIntegralFloat, "CHPL_WARN_INTEGRAL_TO_FLOAT", NULL}, + {"warn-float-to-float", ' ', NULL, "Enable [disable] warnings for implicitly converting a real/imag/complex to a real/imag/complex with different precision", "N", &fWarnFloatFloat, "CHPL_WARN_REAL_REAL", NULL}, + {"warn-integral-to-integral", ' ', NULL, "Enable [disable] warnings for implicitly converting an int/uint to an int/uint with different size", "N", &fWarnIntegralIntegral, "CHPL_WARN_INTEGRAL_TO_INTEGRAL", NULL}, {"warn-implicit-numeric-conversions", ' ', NULL, "Enable [disable] warnings for implicitly converting a value of numeric type to a different numeric type", "N", &fWarnImplicitNumericConversions, "CHPL_WARN_IMPLICIT_NUMERIC_CONVERSIONS", setNumericWarnings}, - {"warn-param-implicit-numeric-conversions", ' ', NULL, "Enable [disable] int-uint, real-real, and integral-integral implicit conversion warnings to apply to 'param' values", "N", &fWarnParamImplicitNumericConversions, "CHPL_WARN_PARAM_IMPLICIT_NUMERIC_CONVERSIONS", NULL}, + {"warn-param-implicit-numeric-conversions", ' ', NULL, "Enable [disable] int-to-uint, real-to-real, and integral-to-integral implicit conversion warnings to apply to 'param' values", "N", &fWarnParamImplicitNumericConversions, "CHPL_WARN_PARAM_IMPLICIT_NUMERIC_CONVERSIONS", NULL}, {"", ' ', NULL, "Parallelism Control Options", NULL, NULL, NULL, NULL}, {"local", ' ', NULL, "Target one [many] locale[s]", "N", &fLocal, "CHPL_LOCAL", setLocal}, diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index 9d0aa5fe67ae..f3a24578cf44 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -8248,8 +8248,8 @@ void warnForSomeNumericConversions(BaseAST* context, // consider warning for small int -> small real implicit conversion if (actualIntUint && formalFloatingPoint && actualWidth < 64 && formalWidth != 64) { - if (fWarnSmallIntegralReal || shouldWarnUnstableFor(context)) { - if (fWarnSmallIntegralReal) { + if (fWarnSmallIntegralFloat || shouldWarnUnstableFor(context)) { + if (fWarnSmallIntegralFloat) { USR_WARN(context, "potentially surprising implicit conversion " "from '%s' to '%s'", toString(actualVt), toString(formalVt)); @@ -8268,7 +8268,8 @@ void warnForSomeNumericConversions(BaseAST* context, } // consider warning for any int -> real implicit conversion - if (fWarnIntegralReal && actualIntUint && formalFloatingPoint && userModule) { + if (fWarnIntegralFloat && userModule && + actualIntUint && formalFloatingPoint) { if (!actualIsParam || fWarnParamImplicitNumericConversions) { USR_WARN(context, "implicit conversion from '%s' to '%s'", toString(actualVt), toString(formalVt)); @@ -8279,7 +8280,7 @@ void warnForSomeNumericConversions(BaseAST* context, } // consider warning for real(t) -> real(u) implicit conversion - if (fWarnRealReal && actualFloatingPoint && formalFloatingPoint && + if (fWarnFloatFloat && actualFloatingPoint && formalFloatingPoint && actualWidth != formalWidth && userModule) { if (!actualIsParam || fWarnParamImplicitNumericConversions) { USR_WARN(context, "implicit conversion from '%s' to '%s'", diff --git a/man/chpl.rst b/man/chpl.rst index 9d5652fbd801..fdde05172547 100644 --- a/man/chpl.rst +++ b/man/chpl.rst @@ -143,12 +143,12 @@ OPTIONS operation may be race condition and will warn with this flag. Defaults to not printing race condition warnings. -**\--[no-]warn-int-uint** +**\--[no-]warn-int-to-uint** Enable [disable] compilation warnings for when implicitly converting from a value of ``int`` type of any width to a ``uint`` value. -**\--[no-]warn-small-integral-real** +**\--[no-]warn-small-integral-to-float** Enable [disable] compilation warnings for when implicitly converting from a value of small integral type to a small floating-point value. @@ -156,20 +156,20 @@ OPTIONS of type ``int(t)`` or ``uint(t)`` where ``t<64``, to something of type ``real(u)`` or ``complex(2*u)`` where ``u<64``. -**\--[no-]warn-integral-real** +**\--[no-]warn-integral-to-float** Enable [disable] compilation warnings for when implicitly converting from a value of ``int`` or ``uint`` type of any width to a ``real`` or ``complex`` type of any width. -**\--[no-]warn-real-real** +**\--[no-]warn-float-to-float** Enable [disable] compilation warnings for when implicitly converting from a floating-point type of one precision to another. That includes implicitly converting from ``real(32)`` to ``real(64)`` as well as similar cases with ``imag`` and ``complex`` types. -**\--[no-]warn-integral-integral** +**\--[no-]warn-integral-to-integral** Enable [disable] compilation warnings for when implicitly converting from a value of integral type to another integral type of different width. diff --git a/test/compflags/bradc/help/userhelp.good b/test/compflags/bradc/help/userhelp.good index ec16f427c004..0369137eaf11 100644 --- a/test/compflags/bradc/help/userhelp.good +++ b/test/compflags/bradc/help/userhelp.good @@ -25,19 +25,22 @@ Warning and Language Control Options: source --[no-]warn-potential-races Enable [disable] output of warnings for potential race conditions - --[no-]warn-int-uint Enable [disable] warnings for + --[no-]warn-int-to-uint Enable [disable] warnings for potentially negative 'int' values implicitly converted to 'uint' - --[no-]warn-small-integral-real Enable [disable] warnings for implicitly + --[no-]warn-small-integral-to-float + Enable [disable] warnings for implicitly converting a small int/uint to a small real/complex - --[no-]warn-integral-real Enable [disable] warnings for implicitly + --[no-]warn-integral-to-float Enable [disable] warnings for implicitly converting an int/uint to a real/complex - --[no-]warn-real-real Enable [disable] warnings for implicitly + of any width + --[no-]warn-float-to-float Enable [disable] warnings for implicitly converting a real/imag/complex to a real/imag/complex with different precision - --[no-]warn-integral-integral Enable [disable] warnings for implicitly + --[no-]warn-integral-to-integral + Enable [disable] warnings for implicitly converting an int/uint to an int/uint with different size --[no-]warn-implicit-numeric-conversions @@ -45,10 +48,10 @@ Warning and Language Control Options: converting a value of numeric type to a different numeric type --[no-]warn-param-implicit-numeric-conversions - Enable [disable] int-uint, real-real, - and integral-integral implicit - conversion warnings to apply to 'param' - values + Enable [disable] int-to-uint, + real-to-real, and integral-to-integral + implicit conversion warnings to apply to + 'param' values Parallelism Control Options: --[no-]local Target one [many] locale[s] diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-int-uint.compopts b/test/compflags/ferguson/implicit-conversion-warnings/warn-int-uint.compopts index 739f2dd6b58f..0f617a4cef36 100644 --- a/test/compflags/ferguson/implicit-conversion-warnings/warn-int-uint.compopts +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-int-uint.compopts @@ -1,2 +1,2 @@ ---warn-int-uint +--warn-int-to-uint --warn-implicit-numeric-conversions diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.compopts b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.compopts index bba69d06a5ed..bb86fea44761 100644 --- a/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.compopts +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-integral.compopts @@ -1,2 +1,2 @@ ---warn-integral-integral +--warn-integral-to-integral --warn-implicit-numeric-conversions diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.compopts b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.compopts index f4a9c8b1d6cf..42d85d038ae9 100644 --- a/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.compopts +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-integral-real.compopts @@ -1,2 +1,2 @@ ---warn-integral-real +--warn-integral-to-float --warn-implicit-numeric-conversions diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.compopts b/test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.compopts index 984d50066074..5d72cc065e27 100644 --- a/test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.compopts +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-real-real.compopts @@ -1,2 +1,2 @@ ---warn-real-real +--warn-float-to-float --warn-implicit-numeric-conversions diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.chpl b/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.chpl index 452f9e14907f..644b746fc184 100644 --- a/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.chpl +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.chpl @@ -1,5 +1,5 @@ use Math; - +// test warnings from --warn-small-integral-to-float / --warn-unstable proc test1fn() { var red: uint(8) = 1; var green: uint(8) = 2; diff --git a/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.compopts b/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.compopts index a0da74fd42a7..6b51a6d6ee3b 100644 --- a/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.compopts +++ b/test/compflags/ferguson/implicit-conversion-warnings/warn-small-integral-real.compopts @@ -1 +1 @@ ---warn-small-integral-real +--warn-small-integral-to-float From e415f36c94aeab3734dcae24a2d2b06477ea33d9 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 6 Mar 2024 17:18:09 -0500 Subject: [PATCH 24/25] Mention any width in help for --warn-int-to-uint --- Signed-off-by: Michael Ferguson --- compiler/main/driver.cpp | 2 +- test/compflags/bradc/help/userhelp.good | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/main/driver.cpp b/compiler/main/driver.cpp index 6a73fd376ddb..db7f4f64f21c 100644 --- a/compiler/main/driver.cpp +++ b/compiler/main/driver.cpp @@ -1320,7 +1320,7 @@ static ArgumentDescription arg_desc[] = { {"warn-unknown-attribute-toolname", ' ', NULL, "Enable [disable] warnings when an unknown tool name is found in an attribute", "N", &fWarnUnknownAttributeToolname, "CHPL_WARN_UNKNOWN_ATTRIBUTE_TOOLNAME", NULL}, {"using-attribute-toolname", ' ', "", "Specify additional tool names for attributes that are expected in the source", "S", NULL, "CHPL_ATTRIBUTE_TOOLNAMES", addUsingAttributeToolname}, {"warn-potential-races", ' ', NULL, "Enable [disable] output of warnings for potential race conditions", "N", &fWarnPotentialRaces, "CHPL_WARN_POTENTIAL_RACES", NULL}, - {"warn-int-to-uint", ' ', NULL, "Enable [disable] warnings for potentially negative 'int' values implicitly converted to 'uint'", "N", &fWarnIntUint, "CHPL_WARN_INT_TO_UINT", NULL}, + {"warn-int-to-uint", ' ', NULL, "Enable [disable] warnings for implicitly converting a potentially negative int value of any width to a uint", "N", &fWarnIntUint, "CHPL_WARN_INT_TO_UINT", NULL}, {"warn-small-integral-to-float", ' ', NULL, "Enable [disable] warnings for implicitly converting a small int/uint to a small real/complex", "N", &fWarnSmallIntegralFloat, "CHPL_WARN_SMALL_INTEGRAL_TO_FLOAT", NULL}, {"warn-integral-to-float", ' ', NULL, "Enable [disable] warnings for implicitly converting an int/uint to a real/complex of any width", "N", &fWarnIntegralFloat, "CHPL_WARN_INTEGRAL_TO_FLOAT", NULL}, {"warn-float-to-float", ' ', NULL, "Enable [disable] warnings for implicitly converting a real/imag/complex to a real/imag/complex with different precision", "N", &fWarnFloatFloat, "CHPL_WARN_REAL_REAL", NULL}, diff --git a/test/compflags/bradc/help/userhelp.good b/test/compflags/bradc/help/userhelp.good index 0369137eaf11..02e7233984a3 100644 --- a/test/compflags/bradc/help/userhelp.good +++ b/test/compflags/bradc/help/userhelp.good @@ -25,9 +25,9 @@ Warning and Language Control Options: source --[no-]warn-potential-races Enable [disable] output of warnings for potential race conditions - --[no-]warn-int-to-uint Enable [disable] warnings for - potentially negative 'int' values - implicitly converted to 'uint' + --[no-]warn-int-to-uint Enable [disable] warnings for implicitly + converting a potentially negative int + value of any width to a uint --[no-]warn-small-integral-to-float Enable [disable] warnings for implicitly converting a small int/uint to a small From bebf9f0a6ea8d59da3e9a943e7152769393cfe2c Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 6 Mar 2024 17:18:51 -0500 Subject: [PATCH 25/25] Regenerate chpl-completion.bash --- Signed-off-by: Michael Ferguson --- util/chpl-completion.bash | 40 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/util/chpl-completion.bash b/util/chpl-completion.bash index aca721256d8a..0c905fb5cd5e 100644 --- a/util/chpl-completion.bash +++ b/util/chpl-completion.bash @@ -290,14 +290,14 @@ _chpl () --no-warn-array-of-range \ --no-warn-const-loops \ --no-warn-domain-literal \ +--no-warn-float-to-float \ --no-warn-implicit-numeric-conversions \ ---no-warn-int-uint \ ---no-warn-integral-integral \ ---no-warn-integral-real \ +--no-warn-int-to-uint \ +--no-warn-integral-to-float \ +--no-warn-integral-to-integral \ --no-warn-param-implicit-numeric-conversions \ --no-warn-potential-races \ ---no-warn-real-real \ ---no-warn-small-integral-real \ +--no-warn-small-integral-to-float \ --no-warn-special \ --no-warn-tuple-iteration \ --no-warn-unknown-attribute-toolname \ @@ -394,14 +394,14 @@ _chpl () --warn-array-of-range \ --warn-const-loops \ --warn-domain-literal \ +--warn-float-to-float \ --warn-implicit-numeric-conversions \ ---warn-int-uint \ ---warn-integral-integral \ ---warn-integral-real \ +--warn-int-to-uint \ +--warn-integral-to-float \ +--warn-integral-to-integral \ --warn-param-implicit-numeric-conversions \ --warn-potential-races \ ---warn-real-real \ ---warn-small-integral-real \ +--warn-small-integral-to-float \ --warn-special \ --warn-tuple-iteration \ --warn-unknown-attribute-toolname \ @@ -546,14 +546,14 @@ _chpl () --no-task-tracking \ --no-tuple-copy-opt \ --no-vectorize \ +--no-warn-float-to-float \ --no-warn-implicit-numeric-conversions \ ---no-warn-int-uint \ ---no-warn-integral-integral \ ---no-warn-integral-real \ +--no-warn-int-to-uint \ +--no-warn-integral-to-float \ +--no-warn-integral-to-integral \ --no-warn-param-implicit-numeric-conversions \ --no-warn-potential-races \ ---no-warn-real-real \ ---no-warn-small-integral-real \ +--no-warn-small-integral-to-float \ --no-warn-unknown-attribute-toolname \ --no-warn-unstable \ --no-warnings \ @@ -600,14 +600,14 @@ _chpl () --using-attribute-toolname \ --vectorize \ --version \ +--warn-float-to-float \ --warn-implicit-numeric-conversions \ ---warn-int-uint \ ---warn-integral-integral \ ---warn-integral-real \ +--warn-int-to-uint \ +--warn-integral-to-float \ +--warn-integral-to-integral \ --warn-param-implicit-numeric-conversions \ --warn-potential-races \ ---warn-real-real \ ---warn-small-integral-real \ +--warn-small-integral-to-float \ --warn-unknown-attribute-toolname \ --warn-unstable \ --warnings \