r354074 - [Sema] Fix-up a -Wfloat-conversion diagnostic

Shoaib Meenai via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 14 16:18:09 PST 2019


I don't think Hans ended up getting added to the recipients? (Unless Outlook is being silly or it was a BCC, in which case I apologize for the spam.)

On 2/14/19, 3:16 PM, "cfe-commits on behalf of Erik Pilkington via cfe-commits" <cfe-commits-bounces at lists.llvm.org on behalf of cfe-commits at lists.llvm.org> wrote:

    Hans, can you merge this diagnostic regression fix into LLVM 8?
    
    Thanks!
    
    > On Feb 14, 2019, at 2:48 PM, Erik Pilkington via cfe-commits <cfe-commits at lists.llvm.org> wrote:
    > 
    > Author: epilk
    > Date: Thu Feb 14 14:48:01 2019
    > New Revision: 354074
    > 
    > URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D354074-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=DO5cOhG2p0lJyoGW_0kLao-RuuAsjuXhKcexb8Du4S8&s=pHB5-cVv8xjeI6USEYPO7XIpvGQena6iXejLqlviUes&e=
    > Log:
    > [Sema] Fix-up a -Wfloat-conversion diagnostic
    > 
    > We were warning on valid ObjC property reference exprs, and passing
    > in the wrong arguments to DiagnoseFloatingImpCast (leading to a badly
    > worded diagnostic).
    > 
    > rdar://47644670
    > 
    > Differential revision: https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D58145&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=DO5cOhG2p0lJyoGW_0kLao-RuuAsjuXhKcexb8Du4S8&s=ohcFH9VMyZgBARLdvdnbJXaIkchLNxHzkt9R3y_Dy4E&e=
    > 
    > Modified:
    >    cfe/trunk/lib/Sema/SemaChecking.cpp
    >    cfe/trunk/test/SemaCXX/warn-float-conversion.cpp
    >    cfe/trunk/test/SemaObjC/conversion.m
    > 
    > Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
    > URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Sema_SemaChecking.cpp-3Frev-3D354074-26r1-3D354073-26r2-3D354074-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=DO5cOhG2p0lJyoGW_0kLao-RuuAsjuXhKcexb8Du4S8&s=noPXZAz2o1d7SWaLkeUQGcFR9mRffBwYz07dWx-vUsM&e=
    > ==============================================================================
    > --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
    > +++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Feb 14 14:48:01 2019
    > @@ -10624,16 +10624,16 @@ static void AnalyzeCompoundAssignment(Se
    >   // 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()))
    > +  // If source is floating point but target is an integer.
    > +  if (ResultBT->isInteger())
    > +    DiagnoseImpCast(S, E, E->getRHS()->getType(), E->getLHS()->getType(),
    > +                    E->getExprLoc(), diag::warn_impcast_float_integer);
    > +  // If both source and target are floating points. Builtin FP kinds are ordered
    > +  // by increasing FP rank. FIXME: except _Float16, we currently emit a bogus
    > +  // warning.
    > +  else if (ResultBT->isFloatingPoint() && 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);
    > 
    > Modified: cfe/trunk/test/SemaCXX/warn-float-conversion.cpp
    > URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_SemaCXX_warn-2Dfloat-2Dconversion.cpp-3Frev-3D354074-26r1-3D354073-26r2-3D354074-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=DO5cOhG2p0lJyoGW_0kLao-RuuAsjuXhKcexb8Du4S8&s=LPTdxv5StV8_bmyhdyjrJ6m4L5puzINH3F5R2azFXIc&e=
    > ==============================================================================
    > --- cfe/trunk/test/SemaCXX/warn-float-conversion.cpp (original)
    > +++ cfe/trunk/test/SemaCXX/warn-float-conversion.cpp Thu Feb 14 14:48:01 2019
    > @@ -44,17 +44,17 @@ void Convert(float f, double d, long dou
    > 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}}
    > +  x += 1.234; // expected-warning {{implicit conversion turns floating-point number into integer: 'double' to 'int'}}
    > +  x -= -0.0;  // expected-warning {{implicit conversion turns floating-point number into integer: 'double' to 'int'}}
    > +  x *= 1.1f;  // expected-warning {{implicit conversion turns floating-point number into integer: 'float' to 'int'}}
    > +  x /= -2.2f; // expected-warning {{implicit conversion turns floating-point number into integer: 'float' to 'int'}}
    > 
    > -  int y = x += 1.4f;  //expected-warning{{conversion}}
    > +  int y = x += 1.4f; // expected-warning {{implicit conversion turns floating-point number into integer: 'float' to 'int'}}
    > 
    >   float z = 1.1f;
    >   double w = -2.2;
    > 
    > -  y += z + w;  //expected-warning{{conversion}}
    > +  y += z + w; // expected-warning {{implicit conversion turns floating-point number into integer: 'double' to 'int'}}
    > }
    > 
    > # 1 "foo.h" 3
    > 
    > Modified: cfe/trunk/test/SemaObjC/conversion.m
    > URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_SemaObjC_conversion.m-3Frev-3D354074-26r1-3D354073-26r2-3D354074-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=DO5cOhG2p0lJyoGW_0kLao-RuuAsjuXhKcexb8Du4S8&s=3DXumLYaSN0m34iTlCwVsxC_TKFeESmSROy-tCwEIGw&e=
    > ==============================================================================
    > --- cfe/trunk/test/SemaObjC/conversion.m (original)
    > +++ cfe/trunk/test/SemaObjC/conversion.m Thu Feb 14 14:48:01 2019
    > @@ -14,4 +14,11 @@ void radar14415662(RDar14415662 *f, char
    >   x = y; // expected-warning {{implicit conversion loses integer precision: 'int' to 'char'}}
    > }
    > 
    > +__attribute__((objc_root_class)) @interface DoubleProp
    > + at property double d;
    > + at end
    > 
    > +void use_double_prop(DoubleProp *dp) {
    > +  double local = 42;
    > +  dp.d += local; // no warning
    > +}
    > 
    > 
    > _______________________________________________
    > cfe-commits mailing list
    > cfe-commits at lists.llvm.org
    > https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=DO5cOhG2p0lJyoGW_0kLao-RuuAsjuXhKcexb8Du4S8&s=jwZI8SrTwnb0bkyg3e0OrorEE3IADGCwV9qYcOsqyiY&e=
    
    _______________________________________________
    cfe-commits mailing list
    cfe-commits at lists.llvm.org
    https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=DO5cOhG2p0lJyoGW_0kLao-RuuAsjuXhKcexb8Du4S8&s=jwZI8SrTwnb0bkyg3e0OrorEE3IADGCwV9qYcOsqyiY&e=
    



More information about the cfe-commits mailing list