basic/CppunitTest_basic_macros.mk | 1 + basic/qa/cppunit/basictest.cxx | 3 +++ basic/qa/cppunit/basictest.hxx | 2 ++ basic/qa/cppunit/test_complier_checks.cxx | 27 +++++++++++++++++++++++++++ basic/source/comp/dim.cxx | 5 +++-- 5 files changed, 36 insertions(+), 2 deletions(-)
New commits: commit bcfe36586c6bd07cef3c2ba39abd38bc9b6ab097 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat Dec 7 15:27:08 2019 +0100 Commit: Xisco FaulĂ <xiscofa...@libreoffice.org> CommitDate: Mon Dec 9 12:04:46 2019 +0100 tdf#59327: DIM should fail in procedures when same-name argument is present Change-Id: I0a6828bd0b0c27018dc02c36ee207b8666f88ec0 Reviewed-on: https://gerrit.libreoffice.org/84682 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit 840c3a662012c77b5972c869587acd15ee5a3f03) Reviewed-on: https://gerrit.libreoffice.org/84732 Reviewed-by: Xisco FaulĂ <xiscofa...@libreoffice.org> diff --git a/basic/CppunitTest_basic_macros.mk b/basic/CppunitTest_basic_macros.mk index 0ca767e1ddba..2d9959c9b6c9 100644 --- a/basic/CppunitTest_basic_macros.mk +++ b/basic/CppunitTest_basic_macros.mk @@ -15,6 +15,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,basic_macros, \ basic/qa/cppunit/basictest \ basic/qa/cppunit/basic_coverage \ basic/qa/cppunit/test_append \ + basic/qa/cppunit/test_complier_checks \ basic/qa/cppunit/test_language_conditionals \ basic/qa/cppunit/test_nested_struct \ basic/qa/cppunit/test_vba \ diff --git a/basic/qa/cppunit/basictest.cxx b/basic/qa/cppunit/basictest.cxx index 9a414b7f5e1a..3a22c84e9007 100644 --- a/basic/qa/cppunit/basictest.cxx +++ b/basic/qa/cppunit/basictest.cxx @@ -108,12 +108,15 @@ bool MacroSnippet::Compile() bool MacroSnippet::HasError() const { return mbError; } +const ErrCode& MacroSnippet::getError() const { return maErrCode; } + IMPL_LINK( MacroSnippet, BasicErrorHdl, StarBASIC *, /*pBasic*/, bool) { fprintf(stderr,"(%d:%d)\n", StarBASIC::GetLine(), StarBASIC::GetCol1()); fprintf(stderr,"Basic error: %s\n", OUStringToOString( StarBASIC::GetErrorText(), RTL_TEXTENCODING_UTF8 ).getStr() ); mbError = true; + maErrCode = StarBASIC::GetErrorCode(); return false; } diff --git a/basic/qa/cppunit/basictest.hxx b/basic/qa/cppunit/basictest.hxx index 8b92acf93d69..c8d262ee6def 100644 --- a/basic/qa/cppunit/basictest.hxx +++ b/basic/qa/cppunit/basictest.hxx @@ -24,6 +24,7 @@ class MacroSnippet { private: bool mbError; + ErrCode maErrCode; BasicDLL maDll; // we need a dll instance for resource manager etc. SbModuleRef mpMod; StarBASICRef mpBasic; @@ -46,6 +47,7 @@ public: DECL_LINK( BasicErrorHdl, StarBASIC *, bool ); bool HasError() const; + const ErrCode& getError() const; }; #endif diff --git a/basic/qa/cppunit/test_complier_checks.cxx b/basic/qa/cppunit/test_complier_checks.cxx new file mode 100644 index 000000000000..aad058040c31 --- /dev/null +++ b/basic/qa/cppunit/test_complier_checks.cxx @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sal/config.h> +#include "basictest.hxx" +#include <basic/sberrors.hxx> +#include <unotest/bootstrapfixturebase.hxx> + +CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testRedefineArgument) +{ + MacroSnippet aMacro("Sub doUnitTest(argName)\n" + " If False Then\n" + " Dim argName\n" + " End If\n" + "End Sub\n"); + aMacro.Compile(); + CPPUNIT_ASSERT(aMacro.HasError()); + CPPUNIT_ASSERT_EQUAL(ERRCODE_BASIC_VAR_DEFINED, aMacro.getError().StripDynamic()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx index bfe8b3184b36..d6b2bff6ccc6 100644 --- a/basic/source/comp/dim.cxx +++ b/basic/source/comp/dim.cxx @@ -318,8 +318,9 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic ) } if( pOld && !(eOp == SbiOpcode::REDIM_ || eOp == SbiOpcode::REDIMP_) ) { - if( pDef->GetScope() == SbLOCAL && pOld->GetScope() != SbLOCAL ) - pOld = nullptr; + if( pDef->GetScope() == SbLOCAL ) + if (auto eOldScope = pOld->GetScope(); eOldScope != SbLOCAL && eOldScope != SbPARAM) + pOld = nullptr; } if( pOld ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits