From 853167931600777e7bf44a35e051628a1169bcfc Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 4 Sep 2013 08:54:21 +0300 Subject: WaE: unreachable code Noticed during inlining at link-time code generation phase: The called function always throws. So let's hardcode the throw for now then at the callsite instead. Not ideal, I know. Add comments describing what is going on. Change-Id: I60d14b25aa62846fc0314aad7e00b2990f4cff26 --- scaddins/source/analysis/analysishelper.cxx | 4 ++++ scaddins/source/analysis/financial.cxx | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx index 05b6bbfbd237..001223108dee 100644 --- a/scaddins/source/analysis/analysishelper.cxx +++ b/scaddins/source/analysis/analysishelper.cxx @@ -1068,6 +1068,8 @@ double GetOddfprice( sal_Int32 /*nNullDate*/, sal_Int32 /*nSettle*/, sal_Int32 / sal_Int32 /*nFirstCoup*/, double /*fRate*/, double /*fYield*/, double /*fRedemp*/, sal_Int32 /*nFreq*/, sal_Int32 /*nBase*/ ) throw( uno::RuntimeException, lang::IllegalArgumentException ) { + // If you ever change this to not unconditionally throw, adapt + // getOddfprice() (note lower-case 'g') in financial.cxx. throw uno::RuntimeException(); // #87380# } @@ -1151,6 +1153,8 @@ double GetOddfyield( sal_Int32 /*nNullDate*/, sal_Int32 /*nSettle*/, sal_Int32 / sal_Int32 /*nFirstCoup*/, double /*fRate*/, double /*fPrice*/, double /*fRedemp*/, sal_Int32 /*nFreq*/, sal_Int32 /*nBase*/ ) throw( uno::RuntimeException, lang::IllegalArgumentException ) { + // Ditto here, if you change this to not throw unconditionally, + // adapt getOddfyield() in financial.cxx. throw uno::RuntimeException(); // #87380# } diff --git a/scaddins/source/analysis/financial.cxx b/scaddins/source/analysis/financial.cxx index dd637c69f15f..a34591acf313 100644 --- a/scaddins/source/analysis/financial.cxx +++ b/scaddins/source/analysis/financial.cxx @@ -403,8 +403,20 @@ double SAL_CALL AnalysisAddIn::getOddfprice( const css::uno::Reference< css::bea if( fRate < 0.0 || fYield < 0.0 || CHK_Freq || nMat <= nFirstCoup || nFirstCoup <= nSettle || nSettle <= nIssue ) throw css::lang::IllegalArgumentException(); +#if !(defined(_MSC_VER) && defined(ENABLE_LTO)) double fRet = GetOddfprice( GetNullDate( xOpt ), nSettle, nMat, nIssue, nFirstCoup, fRate, fYield, fRedemp, nFreq, getDateMode( xOpt, rOB ) ); RETURN_FINITE( fRet ); +#else + // During link-time optimization the compiler inlines the above + // call to GetOddfprice() (note upper-case 'G') (from + // analysishelper.cxx), and notices that GetOddfprice() always + // throws, so the assignment and return are unreachable. Avoid + // that warning by throwing directly here. + (void) rOB; + (void) fRedemp; + (void) xOpt; + throw css::uno::RuntimeException(); +#endif } @@ -415,9 +427,17 @@ double SAL_CALL AnalysisAddIn::getOddfyield( const css::uno::Reference< css::bea if( fRate < 0.0 || fPrice <= 0.0 || CHK_Freq || nMat <= nFirstCoup || nFirstCoup <= nSettle || nSettle <= nIssue ) throw css::lang::IllegalArgumentException(); +#if !(defined(_MSC_VER) && defined(ENABLE_LTO)) double fRet = GetOddfyield( GetNullDate( xOpt ), nSettle, nMat, nIssue, nFirstCoup, fRate, fPrice, fRedemp, nFreq, getDateMode( xOpt, rOB ) ); RETURN_FINITE( fRet ); +#else + // Same story here, see comment in getOddfprice() + (void) rOB; + (void) fRedemp; + (void) xOpt; + throw css::uno::RuntimeException(); +#endif } -- cgit