compiler: don't output an error twice in 'on Exception do' block if Exception is not a valid type

git-svn-id: trunk@25419 -
This commit is contained in:
paul 2013-09-05 00:46:26 +00:00
parent e2ec3bbcb0
commit d25ae84113

View File

@ -825,6 +825,18 @@ implementation
function try_statement : tnode; function try_statement : tnode;
procedure check_type_valid(var def: tdef);
begin
if not (is_class(def) or is_javaclass(def) or
{ skip showing error message the second time }
(def.typ=errordef)) then
begin
Message1(type_e_class_type_expected,def.typename);
def:=generrordef;
end;
end;
var var
p_try_block,p_finally_block,first,last, p_try_block,p_finally_block,first,last,
p_default,p_specific,hp : tnode; p_default,p_specific,hp : tnode;
@ -901,11 +913,7 @@ implementation
if try_to_consume(_COLON) then if try_to_consume(_COLON) then
begin begin
single_type(ot,[]); single_type(ot,[]);
if not (is_class(ot) or is_javaclass(ot)) then check_type_valid(ot);
begin
Message1(type_e_class_type_expected,ot.typename);
ot:=generrordef;
end;
sym:=tlocalvarsym.create(objrealname,vs_value,ot,[]); sym:=tlocalvarsym.create(objrealname,vs_value,ot,[]);
end end
else else
@ -928,11 +936,7 @@ implementation
begin begin
ot:=ttypesym(srsym).typedef; ot:=ttypesym(srsym).typedef;
parse_nested_types(ot,false,nil); parse_nested_types(ot,false,nil);
if not (is_class(ot) or is_javaclass(ot)) then check_type_valid(ot);
begin
Message1(type_e_class_type_expected,ot.typename);
ot:=generrordef;
end;
end end
else else
begin begin