Browse Source

* Do not crash the compiler in case of an invalid ClassAttribute type

git-svn-id: branches/joost/classattributes@22755 -
joost 13 years ago
parent
commit
19fdc2470c
1 changed files with 23 additions and 21 deletions
  1. 23 21
      compiler/pdecl.pas

+ 23 - 21
compiler/pdecl.pas

@@ -380,27 +380,29 @@ implementation
         { Parse attribute type }
         { Parse attribute type }
         p := factor(false,true);
         p := factor(false,true);
 
 
-        typesym := ttypesym(ttypenode(p).typesym);
-        od := tobjectdef(ttypenode(p).typedef);
-
-        { Search the tprocdef of the constructor which has to be called. }
-        constrpd := od.find_procdef_bytype(potype_constructor);
-
-        { Parse the attribute-parameters as if it is a list of parameters from
-          a call to the constrpd constructor in an execution-block. }
-        p1 := cloadvmtaddrnode.create(ctypenode.create(od));
-        again:=true;
-        oldblock_type := block_type;
-        block_type := bt_body;
-        do_member_read(od,false,constrpd.procsym,p1,again,[]);
-        block_type:=oldblock_type;
-
-        { Add attribute to attribute list which will be added
-          to the property which is defined next. }
-        if not assigned(rtti_attributes) then
-          rtti_attributes := trtti_attributesdef.create;
-        rtti_attributes.addattribute(typesym,p1);
-
+        if p.nodetype<>errorn then
+          begin
+          typesym := ttypesym(ttypenode(p).typesym);
+          od := tobjectdef(ttypenode(p).typedef);
+
+          { Search the tprocdef of the constructor which has to be called. }
+          constrpd := od.find_procdef_bytype(potype_constructor);
+
+          { Parse the attribute-parameters as if it is a list of parameters from
+            a call to the constrpd constructor in an execution-block. }
+          p1 := cloadvmtaddrnode.create(ctypenode.create(od));
+          again:=true;
+          oldblock_type := block_type;
+          block_type := bt_body;
+          do_member_read(od,false,constrpd.procsym,p1,again,[]);
+          block_type:=oldblock_type;
+
+          { Add attribute to attribute list which will be added
+            to the property which is defined next. }
+          if not assigned(rtti_attributes) then
+            rtti_attributes := trtti_attributesdef.create;
+          rtti_attributes.addattribute(typesym,p1);
+          end;
         p.free;
         p.free;
         consume(_RECKKLAMMER);
         consume(_RECKKLAMMER);
       end;
       end;