diff --git a/changelog.txt b/changelog.txt index af2cd927ff..d2478f5945 100644 --- a/changelog.txt +++ b/changelog.txt @@ -160,7 +160,7 @@ Version 0.91.0: - #582: Wrong code generated for bitfield self-BOPs or SWAPs sometimes under -exx or if the bitfield expression contained function calls (side-effects) - When specifying an .o file name without extension but '.' in its path (for example: -o ../foo), fbc created temporary files by stripping everything from the .o path until that '.' and then appending the new extension, which often resulted in bad/unexpected file names (for example: ..foo.asm). - Calling getkey() in one thread won't cause other threads' rtlib function calls to block until getkey() returns anymore -- #726: CONSTRUCTOR|DESTRUCTOR (module-level initialization/cleanup) was allowed to be specified on sub prototypes (although, it was ignored) and method bodies (silently miscompiled due to the missing THIS argument). Now both these cases are disallowed, as neither makes sense. +- #726: CONSTRUCTOR|DESTRUCTOR (module-level initialization/cleanup) was allowed to be specified on sub prototypes (although, it was ignored), method bodies (silently miscompiled due to the missing THIS argument), and PRIVATE/PROTECTED static member procedures. Now these cases are disallowed. Version 0.90.1: diff --git a/src/compiler/parser-proc.bas b/src/compiler/parser-proc.bas index 7d98a51d28..aff2d5b11f 100644 --- a/src/compiler/parser-proc.bas +++ b/src/compiler/parser-proc.bas @@ -1632,9 +1632,15 @@ function cProcHeader _ '' Register global ctors/dtors if( stats and FB_SYMBSTATS_GLOBALCTOR ) then + if( proc->attrib and (FB_SYMBATTRIB_VIS_PRIVATE or FB_SYMBATTRIB_VIS_PROTECTED) ) then + errReport( FB_ERRMSG_NOACCESSTOCTOR, TRUE ) + end if symbAddGlobalCtor( proc ) symbSetProcPriority( proc, priority ) elseif( stats and FB_SYMBSTATS_GLOBALDTOR ) then + if( proc->attrib and (FB_SYMBATTRIB_VIS_PRIVATE or FB_SYMBATTRIB_VIS_PROTECTED) ) then + errReport( FB_ERRMSG_NOACCESSTODTOR, TRUE ) + end if symbAddGlobalDtor( proc ) symbSetProcPriority( proc, priority ) end if diff --git a/tests/visibility/private-module-ctor.bas b/tests/visibility/private-module-ctor.bas new file mode 100644 index 0000000000..cfe6ec0f05 --- /dev/null +++ b/tests/visibility/private-module-ctor.bas @@ -0,0 +1,11 @@ +' TEST_MODE : COMPILE_ONLY_FAIL + +type UDT + i as integer + +private: + declare static sub ctor( ) +end type + +sub UDT.ctor( ) constructor +end sub diff --git a/tests/visibility/private-module-dtor.bas b/tests/visibility/private-module-dtor.bas new file mode 100644 index 0000000000..c8a9b0a086 --- /dev/null +++ b/tests/visibility/private-module-dtor.bas @@ -0,0 +1,11 @@ +' TEST_MODE : COMPILE_ONLY_FAIL + +type UDT + i as integer + +private: + declare static sub dtor( ) +end type + +sub UDT.dtor( ) destructor +end sub diff --git a/tests/visibility/protected-module-ctor.bas b/tests/visibility/protected-module-ctor.bas new file mode 100644 index 0000000000..3cb82da383 --- /dev/null +++ b/tests/visibility/protected-module-ctor.bas @@ -0,0 +1,11 @@ +' TEST_MODE : COMPILE_ONLY_FAIL + +type UDT + i as integer + +protected: + declare static sub ctor( ) +end type + +sub UDT.ctor( ) constructor +end sub diff --git a/tests/visibility/protected-module-dtor.bas b/tests/visibility/protected-module-dtor.bas new file mode 100644 index 0000000000..47d3d532ce --- /dev/null +++ b/tests/visibility/protected-module-dtor.bas @@ -0,0 +1,11 @@ +' TEST_MODE : COMPILE_ONLY_FAIL + +type UDT + i as integer + +protected: + declare static sub dtor( ) +end type + +sub UDT.dtor( ) destructor +end sub