Related: tdf#111675 Replace Pop() with PopError() where relevant

... to propagate the original (previous) error instead of
overriding it with a new error. Pop() may only be used if the
stack type is already known to be not svError, or to explicitly
ignore a current error.

Change-Id: I5a980c29f2d2679c0e2f2fc7e53c458dc147911f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131404
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
(cherry picked from commit 84720c09ef30e79c56936026c3992240b4ae010b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131362
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 131f76c..d40e936 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2828,7 +2828,7 @@ void ScInterpreter::ScFormula()
        }
        break;
        default:
            Pop();
            PopError();
            SetError( FormulaError::NotAvailable );
    }
    PushString( aFormula );
@@ -3727,7 +3727,7 @@ void ScInterpreter::ScMin( bool bTextAsZero )
            }
            break;
            default :
                Pop();
                PopError();
                SetError(FormulaError::IllegalParameter);
        }
    }
@@ -3885,7 +3885,7 @@ void ScInterpreter::ScMax( bool bTextAsZero )
            }
            break;
            default :
                Pop();
                PopError();
                SetError(FormulaError::IllegalParameter);
        }
    }
@@ -4096,7 +4096,7 @@ void ScInterpreter::GetStVarParams( bool bTextAsZero, double(*VarResult)( double
            }
            break;
            default :
                Pop();
                PopError();
                SetError(FormulaError::IllegalParameter);
        }
    }
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 9298448..bc99592 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -2701,7 +2701,7 @@ void ScInterpreter::ScExternal()
        else
        {
            while( nParamCount-- > 0)
                Pop();
                PopError();
            PushIllegalParameter();
        }
    }
@@ -3077,7 +3077,7 @@ void ScInterpreter::ScExternal()
    {
        while( nParamCount-- > 0)
        {
            Pop();
            PopError();
        }
        PushError( FormulaError::NoAddin );
    }
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index dbeab67..9dd4426 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -515,7 +515,7 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero )
                            else
                            {
                                while (nParamCount-- > 0)
                                    Pop();
                                    PopError();
                                SetError( FormulaError::NoValue );
                            }
                        }