diff --git a/.gitattributes b/.gitattributes index 1cee7d1542..625a1ad881 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13100,6 +13100,7 @@ tests/webtbs/tw17550.pp svneol=native#text/plain tests/webtbs/tw17560.pp svneol=native#text/plain tests/webtbs/tw1758.pp svneol=native#text/plain tests/webtbs/tw17591.pp svneol=native#text/plain +tests/webtbs/tw17598.pp svneol=native#text/pascal tests/webtbs/tw17604.pp svneol=native#text/plain tests/webtbs/tw17646.pp svneol=native#text/plain tests/webtbs/tw1765.pp svneol=native#text/plain diff --git a/compiler/nflw.pas b/compiler/nflw.pas index 1ae2708f38..4521c1fdb8 100644 --- a/compiler/nflw.pas +++ b/compiler/nflw.pas @@ -1874,6 +1874,8 @@ implementation if assigned(left) then firstpass(left); if (m_non_local_goto in current_settings.modeswitches) and + { the owner can be Nil for internal labels } + assigned(labsym.owner) and (current_procinfo.procdef.parast.symtablelevel<>labsym.owner.symtablelevel) then CGMessage(cg_e_labels_cannot_defined_outside_declaration_scope) end; diff --git a/compiler/pstatmnt.pas b/compiler/pstatmnt.pas index 9525b0a197..1c384a3cc3 100644 --- a/compiler/pstatmnt.pas +++ b/compiler/pstatmnt.pas @@ -1295,8 +1295,14 @@ implementation not(is_void(p.resultdef)) and { can be nil in case there was an error in the expression } assigned(tcallnode(p).procdefinition) and - not((tcallnode(p).procdefinition.proctypeoption=potype_constructor) and - is_object(tprocdef(tcallnode(p).procdefinition).struct)) then + { allow constructor calls to drop the result if they are + called as instance methods instead of class methods } + not( + (tcallnode(p).procdefinition.proctypeoption=potype_constructor) and + is_class_or_object(tprocdef(tcallnode(p).procdefinition).struct) and + assigned(tcallnode(p).methodpointer) and + (tnode(tcallnode(p).methodpointer).resultdef.typ=objectdef) + ) then Message(parser_e_illegal_expression); end; code:=p; diff --git a/tests/webtbs/tw17598.pp b/tests/webtbs/tw17598.pp new file mode 100644 index 0000000000..4b27236fc9 --- /dev/null +++ b/tests/webtbs/tw17598.pp @@ -0,0 +1,30 @@ +{ %NORUN } + +{$mode macpas} +{$extendedsyntax off} +{$modeswitch exceptions+} +{$modeswitch class+} + +program tw17598; + + uses + sysutils; + + type + EMyException = + class( Exception) + constructor Create( theMessage: Ansistring); + end; + +constructor EMyException.Create( theMessage: Ansistring); + begin + inherited Create( theMessage) + end; + +begin + try + raise EMyException.Create( 'my exception raised') + except + ShowException( ExceptObject, ExceptAddr) + end +end.