https://reviews.llvm.org/D50647 On Mon, Aug 13, 2018 at 12:50 PM Vitaly Buka <vitalyb...@google.com> wrote: > > Looks like this patch: > > http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/13867/steps/ninja%20check%201/logs/stdio > > > FAIL: Clang :: Sema/conversion.c (12530 of 44133) > ******************** TEST 'Clang :: Sema/conversion.c' FAILED > ******************** > Script: > -- > : 'RUN: at line 1'; > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/clang > -cc1 -internal-isystem > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/lib/clang/8.0.0/include > -nostdsysteminc -fsyntax-only -verify -Wconversion -nostdsysteminc > -nobuiltininc -isystem > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/tools/clang/test/Sema/Inputs > -triple x86_64-apple-darwin > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/tools/clang/test/Sema/conversion.c > -Wno-unreachable-code > -- > Exit Code: 1 > > Command Output (stderr): > -- > error: 'warning' diagnostics seen but not expected: > File > /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/tools/clang/test/Sema/conversion.c > Line 362: implicit conversion turns floating-point number into integer: > 'char' to 'float' > 1 error generated. > > -- > > > On Mon, Aug 13, 2018 at 9:46 AM Nick Desaulniers via cfe-commits > <cfe-commits@lists.llvm.org> wrote: >> >> Author: nickdesaulniers >> Date: Mon Aug 13 09:38:07 2018 >> New Revision: 339581 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=339581&view=rev >> Log: >> [SEMA] add more -Wfloat-conversion to compound assigment analysis >> >> Summary: Fixes Bug: https://bugs.llvm.org/show_bug.cgi?id=27061 >> >> Reviewers: aaron.ballman, acoomans >> >> Reviewed By: aaron.ballman, acoomans >> >> Subscribers: acoomans, cfe-commits, srhines, pirama >> >> Differential Revision: https://reviews.llvm.org/D50467 >> >> Modified: >> cfe/trunk/lib/Sema/SemaChecking.cpp >> cfe/trunk/test/SemaCXX/warn-float-conversion.cpp >> >> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=339581&r1=339580&r2=339581&view=diff >> ============================================================================== >> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) >> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Aug 13 09:38:07 2018 >> @@ -10282,33 +10282,6 @@ static void DiagnoseImpCast(Sema &S, Exp >> DiagnoseImpCast(S, E, E->getType(), T, CContext, diag, pruneControlFlow); >> } >> >> -/// Analyze the given compound assignment for the possible losing of >> -/// floating-point precision. >> -static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) { >> - assert(isa<CompoundAssignOperator>(E) && >> - "Must be compound assignment operation"); >> - // Recurse on the LHS and RHS in here >> - AnalyzeImplicitConversions(S, E->getLHS(), E->getOperatorLoc()); >> - AnalyzeImplicitConversions(S, E->getRHS(), E->getOperatorLoc()); >> - >> - // Now check the outermost expression >> - const auto *ResultBT = E->getLHS()->getType()->getAs<BuiltinType>(); >> - const auto *RBT = cast<CompoundAssignOperator>(E) >> - ->getComputationResultType() >> - ->getAs<BuiltinType>(); >> - >> - // If both source and target are floating points. >> - if (ResultBT && ResultBT->isFloatingPoint() && RBT && >> RBT->isFloatingPoint()) >> - // Builtin FP kinds are ordered by increasing FP rank. >> - if (ResultBT->getKind() < RBT->getKind()) >> - // We don't want to warn for system macro. >> - if (!S.SourceMgr.isInSystemMacro(E->getOperatorLoc())) >> - // warn about dropping FP rank. >> - DiagnoseImpCast(S, E->getRHS(), E->getLHS()->getType(), >> - E->getOperatorLoc(), >> - diag::warn_impcast_float_result_precision); >> -} >> - >> /// Diagnose an implicit cast from a floating point value to an integer >> value. >> static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, >> SourceLocation CContext) { >> @@ -10411,6 +10384,39 @@ static void DiagnoseFloatingImpCast(Sema >> } >> } >> >> +/// Analyze the given compound assignment for the possible losing of >> +/// floating-point precision. >> +static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) { >> + assert(isa<CompoundAssignOperator>(E) && >> + "Must be compound assignment operation"); >> + // Recurse on the LHS and RHS in here >> + AnalyzeImplicitConversions(S, E->getLHS(), E->getOperatorLoc()); >> + AnalyzeImplicitConversions(S, E->getRHS(), E->getOperatorLoc()); >> + >> + // Now check the outermost expression >> + const auto *ResultBT = E->getLHS()->getType()->getAs<BuiltinType>(); >> + const auto *RBT = cast<CompoundAssignOperator>(E) >> + ->getComputationResultType() >> + ->getAs<BuiltinType>(); >> + >> + // The below checks assume source is floating point. >> + if (!ResultBT || !RBT || !RBT->isFloatingPoint()) return; >> + >> + // If source is floating point but target is not. >> + if (!ResultBT->isFloatingPoint()) >> + return DiagnoseFloatingImpCast(S, E, E->getRHS()->getType(), >> + E->getExprLoc()); >> + >> + // If both source and target are floating points. >> + // Builtin FP kinds are ordered by increasing FP rank. >> + if (ResultBT->getKind() < RBT->getKind() && >> + // We don't want to warn for system macro. >> + !S.SourceMgr.isInSystemMacro(E->getOperatorLoc())) >> + // warn about dropping FP rank. >> + DiagnoseImpCast(S, E->getRHS(), E->getLHS()->getType(), >> E->getOperatorLoc(), >> + diag::warn_impcast_float_result_precision); >> +} >> + >> static std::string PrettyPrintInRange(const llvm::APSInt &Value, >> IntRange Range) { >> if (!Range.Width) return "0"; >> >> Modified: cfe/trunk/test/SemaCXX/warn-float-conversion.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-float-conversion.cpp?rev=339581&r1=339580&r2=339581&view=diff >> ============================================================================== >> --- cfe/trunk/test/SemaCXX/warn-float-conversion.cpp (original) >> +++ cfe/trunk/test/SemaCXX/warn-float-conversion.cpp Mon Aug 13 09:38:07 2018 >> @@ -41,6 +41,32 @@ void Convert(float f, double d, long dou >> l = ld; //expected-warning{{conversion}} >> } >> >> +void CompoundAssignment() { >> + int x = 3; >> + >> + x += 1.234; //expected-warning{{conversion}} >> + x -= -0.0; //expected-warning{{conversion}} >> + x *= 1.1f; //expected-warning{{conversion}} >> + x /= -2.2f; //expected-warning{{conversion}} >> + >> + int y = x += 1.4f; //expected-warning{{conversion}} >> + >> + float z = 1.1f; >> + double w = -2.2; >> + >> + y += z + w; //expected-warning{{conversion}} >> +} >> + >> +# 1 "foo.h" 3 >> +// ^ the following text comes from a system header file. >> +#define SYSTEM_MACRO_FLOAT(x) do { (x) += 1.1; } while(0) >> +# 1 "warn-float-conversion.cpp" 1 >> +// ^ start of a new file. >> +void SystemMacro() { >> + float x = 0.0f; >> + SYSTEM_MACRO_FLOAT(x); >> +} >> + >> void Test() { >> int a1 = 10.0/2.0; //expected-warning{{conversion}} >> int a2 = 1.0/2.0; //expected-warning{{conversion}} >> >> >> _______________________________________________ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
-- Thanks, ~Nick Desaulniers _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits