diff --git a/changelog.txt b/changelog.txt index a365ba9f1..11f700838 100644 --- a/changelog.txt +++ b/changelog.txt @@ -25,6 +25,7 @@ Version 1.10.1 - emscripten/fbc: -sASYNCIFY wasn't passed to emcc at link-time as needed by recent Emscripten - sf.net #993: ignore (parse) single line comments for macros invoked with optional parentheses instead of passing as an argument to macro - sf.net #994: Bad handling of macro argument evaluation - reset file pointers to previous context after evaluating arguments in __fb_query_symbol__, __fb_eval__, __fb_arg_extract__, __fb_iif__, and releasing lexer context +- sf.net #996: fbc null pointer access testing defined(UDT.cast) Version 1.10.0 diff --git a/src/compiler/parser-identifier.bas b/src/compiler/parser-identifier.bas index 8ae92d3f5..b873790eb 100644 --- a/src/compiler/parser-identifier.bas +++ b/src/compiler/parser-identifier.bas @@ -689,19 +689,33 @@ function cIdentifierOrUDTMember _ end if '' else there are member procs, so search for keywords as members + '' !!!TODO!!! - optimize lookups + '' symbGetCompXXX() functions test for things we already know here select case as const lexGetToken( ) case FB_TK_CONSTRUCTOR sym = symbGetCompCtorHead( base_parent ) + '' if( base_parent->udt.ext ) then + '' sym = base_parent->udt.ext->ctorhead + '' end if case FB_TK_DESTRUCTOR sym = symbGetCompDtor1( base_parent ) + '' if( base_parent->udt.ext ) then + '' sym = base_parent->udt.ext->dtor1 + '' end if case FB_TK_LET sym = symbGetCompOpOvlHead( base_parent, AST_OP_ASSIGN ) + '' if( base_parent->udt.ext ) then + '' sym = symbGetUDTOpOvlTb( base_parent )(AST_OP_ASSIGN - AST_OP_SELFBASE) + '' end if case FB_TK_CAST - sym = symbGetUDTOpOvlTb( base_parent )(AST_OP_CAST - AST_OP_SELFBASE) + sym = symbGetCompOpOvlHead( base_parent, AST_OP_CAST ) + '' if( base_parent->udt.ext ) then + '' sym = symbGetUDTOpOvlTb( base_parent )(AST_OP_CAST - AST_OP_SELFBASE) + '' end if end select diff --git a/tests/syntax/defined-3.bas b/tests/syntax/defined-3.bas index 543e4d1fa..02ec1feb2 100644 --- a/tests/syntax/defined-3.bas +++ b/tests/syntax/defined-3.bas @@ -1,11 +1,47 @@ -type T +#print "T1 -- fields only" +type T1 + value as integer +end type + +#if defined( T1.value ) + #print "T1.value defined" +#else + #print "T1.value not defined - NOK" +#endif + +#if defined( T1.constructor ) + #print "T1.constructor defined - NOK" +#else + #print "T1.constructor not defined" +#endif + +#if defined( T1.destructor ) + #print "T1.constructor defined - NOK" +#else + #print "T1.constructor not defined" +#endif + +#if defined( T1.let ) + #print "T1.let defined - NOK" +#else + #print "T1.let not defined" +#endif + +#if defined( T1.cast ) + #print "T1.cast defined - NOK" +#else + #print "T1.cast not defined" +#endif + +#print "T2 -- fields and procedures" +type T2 value as integer static svalue as integer declare sub proc() declare static sub sproc() end type -sub T.proc() +sub T2.proc() #if defined( value ) #print "value defined" @@ -31,31 +67,55 @@ sub T.proc() #print "sproc not defined - NOK" #endif -#if ENABLE_CHECK_BUGS + #if defined( T2.value ) + #print "T2.value defined" + #else + #print "T2.value not defined - NOK" + #endif - #if defined( T.value ) - #print "T.value defined" + #if defined( T2.proc ) + #print "T2.proc defined" #else - #print "T.value not defined - NOK" + #print "T2.proc not defined - NOK" #endif - #if defined( T.proc ) - #print "T.proc defined" + #if defined( T2.svalue ) + #print "T2.svalue defined" #else - #print "T.proc not defined - NOK" + #print "T2.svalue not defined - NOK" #endif - #if defined( T.svalue ) - #print "T.svalue defined" + #if defined( T2.sproc ) + #print "T2.sproc defined" #else - #print "T.svalue not defined - NOK" + #print "T2.sproc not defined - NOK" #endif - #if defined( T.sproc ) - #print "T.sproc defined" + #if defined( T2.constructor ) + #print "T2.constructor defined - NOK" + #else + #print "T2.constructor not defined" + #endif + + #if defined( T2.destructor ) + #print "T2.constructor defined - NOK" #else - #print "T.sproc not defined - NOK" + #print "T2.constructor not defined" #endif + + #if defined( T2.let ) + #print "T2.let defined - NOK" + #else + #print "T2.let not defined" + #endif + + #if defined( T2.cast ) + #print "T2.cast defined - NOK" + #else + #print "T2.cast not defined" + #endif + +#if ENABLE_CHECK_BUGS #if defined( this.svalue ) #print "this.svalue defined" diff --git a/tests/syntax/r/dos/defined-3.txt b/tests/syntax/r/dos/defined-3.txt index 59ecdc2d1..a2752e685 100644 --- a/tests/syntax/r/dos/defined-3.txt +++ b/tests/syntax/r/dos/defined-3.txt @@ -1,4 +1,19 @@ +T1 -- fields only +T1.value defined +T1.constructor not defined +T1.constructor not defined +T1.let not defined +T1.cast not defined +T2 -- fields and procedures value defined proc defined svalue defined sproc defined +T2.value defined +T2.proc defined +T2.svalue defined +T2.sproc defined +T2.constructor not defined +T2.constructor not defined +T2.let not defined +T2.cast not defined diff --git a/tests/syntax/r/linux-x86/defined-3.txt b/tests/syntax/r/linux-x86/defined-3.txt index 59ecdc2d1..a2752e685 100644 --- a/tests/syntax/r/linux-x86/defined-3.txt +++ b/tests/syntax/r/linux-x86/defined-3.txt @@ -1,4 +1,19 @@ +T1 -- fields only +T1.value defined +T1.constructor not defined +T1.constructor not defined +T1.let not defined +T1.cast not defined +T2 -- fields and procedures value defined proc defined svalue defined sproc defined +T2.value defined +T2.proc defined +T2.svalue defined +T2.sproc defined +T2.constructor not defined +T2.constructor not defined +T2.let not defined +T2.cast not defined diff --git a/tests/syntax/r/linux-x86_64/defined-3.txt b/tests/syntax/r/linux-x86_64/defined-3.txt index 59ecdc2d1..a2752e685 100644 --- a/tests/syntax/r/linux-x86_64/defined-3.txt +++ b/tests/syntax/r/linux-x86_64/defined-3.txt @@ -1,4 +1,19 @@ +T1 -- fields only +T1.value defined +T1.constructor not defined +T1.constructor not defined +T1.let not defined +T1.cast not defined +T2 -- fields and procedures value defined proc defined svalue defined sproc defined +T2.value defined +T2.proc defined +T2.svalue defined +T2.sproc defined +T2.constructor not defined +T2.constructor not defined +T2.let not defined +T2.cast not defined diff --git a/tests/syntax/r/win32/defined-3.txt b/tests/syntax/r/win32/defined-3.txt index 59ecdc2d1..a2752e685 100644 --- a/tests/syntax/r/win32/defined-3.txt +++ b/tests/syntax/r/win32/defined-3.txt @@ -1,4 +1,19 @@ +T1 -- fields only +T1.value defined +T1.constructor not defined +T1.constructor not defined +T1.let not defined +T1.cast not defined +T2 -- fields and procedures value defined proc defined svalue defined sproc defined +T2.value defined +T2.proc defined +T2.svalue defined +T2.sproc defined +T2.constructor not defined +T2.constructor not defined +T2.let not defined +T2.cast not defined diff --git a/tests/syntax/r/win64/defined-3.txt b/tests/syntax/r/win64/defined-3.txt index 59ecdc2d1..a2752e685 100644 --- a/tests/syntax/r/win64/defined-3.txt +++ b/tests/syntax/r/win64/defined-3.txt @@ -1,4 +1,19 @@ +T1 -- fields only +T1.value defined +T1.constructor not defined +T1.constructor not defined +T1.let not defined +T1.cast not defined +T2 -- fields and procedures value defined proc defined svalue defined sproc defined +T2.value defined +T2.proc defined +T2.svalue defined +T2.sproc defined +T2.constructor not defined +T2.constructor not defined +T2.let not defined +T2.cast not defined