diff options
Diffstat (limited to 'basic')
-rw-r--r-- | basic/CppunitTest_basic_macros.mk | 1 | ||||
-rw-r--r-- | basic/qa/cppunit/basictest.cxx | 3 | ||||
-rw-r--r-- | basic/qa/cppunit/basictest.hxx | 2 | ||||
-rw-r--r-- | basic/qa/cppunit/test_complier_checks.cxx | 27 | ||||
-rw-r--r-- | basic/source/comp/dim.cxx | 5 |
5 files changed, 36 insertions, 2 deletions
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 ) { |