@@ -627,7 +627,8 @@ private function hTypeAdd _
627627 byval isunion as integer , _
628628 byval align as integer , _
629629 byval baseDType as integer = 0 , _
630- byval baseSubtype as FBSYMBOL ptr = NULL _
630+ byval baseSubtype as FBSYMBOL ptr = NULL, _
631+ byval baseStringType as integer = 0 _
631632 ) as FBSYMBOL ptr
632633
633634 dim as FBSYMBOL ptr s = any
@@ -639,12 +640,10 @@ private function hTypeAdd _
639640 s = symbStructBegin( NULL, NULL, parent, symbUniqueLabel( ), NULL, isunion, align, (baseSubtype <> NULL), 0 , 0 )
640641 end if
641642
642- select case baseDType
643+ select case baseStringType
643644 case FB_DATATYPE_CHAR
644- assert( baseSubtype = NULL )
645645 symbSetUdtIsZstring( s )
646646 case FB_DATATYPE_WCHAR
647- assert( baseSubtype = NULL )
648647 symbSetUdtIsWstring( s )
649648 end select
650649
@@ -1009,6 +1008,7 @@ sub cTypeDecl( byval attrib as integer )
10091008 '' (EXTENDS SymbolType)?
10101009 dim as FBSYMBOL ptr baseSubtype = NULL
10111010 dim as integer baseDType = 0
1011+ dim as integer stringType = 0
10121012
10131013 if ( lexGetToken( ) = FB_TK_EXTENDS ) then
10141014 lexSkipToken( )
@@ -1022,15 +1022,61 @@ sub cTypeDecl( byval attrib as integer )
10221022 '' allow extending WSTRING and ZSTRING, the UDT
10231023 '' will use different rules for conversions,
10241024 if (baseDType = FB_DATATYPE_WCHAR) or (baseDType = FB_DATATYPE_CHAR) then
1025+ stringType = baseDType
1026+ baseDType = 0
10251027 assert( baseSubtype = NULL )
1026-
1028+
10271029 '' anything else? don't allow
10281030 else
10291031 errReport( FB_ERRMSG_EXPECTEDCLASSTYPE )
10301032 '' error recovery: skip
10311033 baseSubtype = NULL
10321034 end if
10331035 end if
1036+
1037+ '' got a string type? check for another base type
1038+ if ( stringType <> 0 ) then
1039+
1040+ '' ','?
1041+ if ( lexGetToken( ) = CHAR_COMMA ) then
1042+ lexSkipToken( )
1043+
1044+ '' SymbolType
1045+ hSymbolType( baseDType, baseSubtype, 0 , FALSE , TRUE )
1046+
1047+ '' is the base type a struct?
1048+ if ( baseDType <> FB_DATATYPE_STRUCT ) then
1049+ errReport( FB_ERRMSG_EXPECTEDCLASSTYPE )
1050+ '' error recovery: skip
1051+ baseSubtype = NULL
1052+ end if
1053+ end if
1054+ end if
1055+
1056+ '' base type? check if z|wstring was already extended
1057+ if ( baseSubType ) then
1058+ select case stringType
1059+ case FB_DATATYPE_CHAR
1060+ '' can't extend zstring if inheriting from wstring
1061+ if ( symbGetUdtIsWstring( baseSubtype ) ) then
1062+ errReport( FB_ERRMSG_INVALIDDATATYPES )
1063+ stringType = FB_DATATYPE_WCHAR
1064+ end if
1065+ case FB_DATATYPE_WCHAR
1066+ '' can't extend wstring if inheriting from zstring
1067+ if ( symbGetUdtIsZstring( baseSubtype ) ) then
1068+ errReport( FB_ERRMSG_INVALIDDATATYPES )
1069+ stringType = FB_DATATYPE_CHAR
1070+ end if
1071+ case else
1072+ '' inherit from base type
1073+ if ( symbGetUdtIsZstring( baseSubtype ) ) then
1074+ stringType = FB_DATATYPE_CHAR
1075+ elseif ( symbGetUdtIsWstring( baseSubtype ) ) then
1076+ stringType = FB_DATATYPE_WCHAR
1077+ end if
1078+ end select
1079+ end if
10341080 end if
10351081
10361082 '' [FIELD '=' ConstExpression]
@@ -1049,7 +1095,7 @@ sub cTypeDecl( byval attrib as integer )
10491095 dim as FBSYMBOL ptr currprocsym = parser.currproc, currblocksym = parser.currblock
10501096 dim as integer scope_depth = parser.scope
10511097
1052- sym = hTypeAdd( NULL, id, palias, isunion, align, baseDType, baseSubtype )
1098+ sym = hTypeAdd( NULL, id, palias, isunion, align, baseDType, baseSubtype, stringType )
10531099
10541100 '' restore the context
10551101 ast.proc.curr = currproc
0 commit comments