basic/qa/cppunit/test_compiler_checks.cxx |   36 ++++++++++++++++++++++++++++++
 basic/source/comp/parser.cxx              |    1 
 2 files changed, 37 insertions(+)

New commits:
commit 7744d3134b0308ea2f2cb87177022269a55fff00
Author:     Razvan Degeratu <razvandegeratu...@gmail.com>
AuthorDate: Tue May 13 11:51:25 2025 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue May 13 12:45:58 2025 +0200

    tdf#162986 Restrict ending of Property Let and Set to only End Property
    
    Change-Id: I023dc6399f97dc5ff1ca6503dbbc0cc7a30eea95
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185249
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/basic/qa/cppunit/test_compiler_checks.cxx 
b/basic/qa/cppunit/test_compiler_checks.cxx
index 8562c11e6501..d17916caa3eb 100644
--- a/basic/qa/cppunit/test_compiler_checks.cxx
+++ b/basic/qa/cppunit/test_compiler_checks.cxx
@@ -222,4 +222,40 @@ CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, 
testTdf162983_function_end_property)
     CPPUNIT_ASSERT(aMacro.HasError());
 }
 
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testTdf162986_property_set_end_sub)
+{
+    MacroSnippet aMacro(u"Option VBASupport 1
"
+                        "Property Set doUnitTest
"
+                        "End Sub
"_ustr);
+    aMacro.Compile();
+    CPPUNIT_ASSERT(aMacro.HasError());
+}
+
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, 
testTdf162986_property_set_end_function)
+{
+    MacroSnippet aMacro(u"Option VBASupport 1
"
+                        "Property Set doUnitTest
"
+                        "End Function
"_ustr);
+    aMacro.Compile();
+    CPPUNIT_ASSERT(aMacro.HasError());
+}
+
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testTdf162986_property_let_end_sub)
+{
+    MacroSnippet aMacro(u"Option VBASupport 1
"
+                        "Property Let doUnitTest
"
+                        "End Sub
"_ustr);
+    aMacro.Compile();
+    CPPUNIT_ASSERT(aMacro.HasError());
+}
+
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, 
testTdf162986_property_let_end_function)
+{
+    MacroSnippet aMacro(u"Option VBASupport 1
"
+                        "Property Let doUnitTest
"
+                        "End Function
"_ustr);
+    aMacro.Compile();
+    CPPUNIT_ASSERT(aMacro.HasError());
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx
index df1fe3a15140..339d06a4f9c6 100644
--- a/basic/source/comp/parser.cxx
+++ b/basic/source/comp/parser.cxx
@@ -363,6 +363,7 @@ bool SbiParser::Parse()
     if( eCurTok == eEndTok ||
         ( bVBASupportOn &&      // #i109075
           eEndTok == ENDPROPERTY &&
+          (pProc && pProc->getPropertyMode() == PropertyMode::Get) &&
           ( eCurTok == ENDFUNC || eCurTok == ENDSUB) ) )
     {
         Next();

Reply via email to