Sfoglia il codice sorgente

* In case no default is specified and no NoDefault is present, act as if NoDefault was given. (bug ID 10080, now we are Delphi compatible)

git-svn-id: trunk@11682 -
michael 17 anni fa
parent
commit
d2169a7e43
1 ha cambiato i file con 26 aggiunte e 14 eliminazioni
  1. 26 14
      compiler/pdecvar.pas

+ 26 - 14
compiler/pdecvar.pas

@@ -218,6 +218,26 @@ implementation
              end;
           end;
 
+          function allow_default_property(p : tpropertysym) : boolean;
+
+          begin
+             allow_default_property:=
+               (is_ordinal(p.propdef) or
+{$ifndef cpu64bitaddr}
+               is_64bitint(p.propdef) or
+{$endif cpu64bitaddr}
+               is_class(p.propdef) or
+               is_single(p.propdef) or
+               (p.propdef.typ in [classrefdef,pointerdef]) or
+                 is_smallset(p.propdef)
+               ) and not
+               (
+                (p.propdef.typ=arraydef) and
+                (ppo_indexed in p.propoptions)
+               ) and not
+               (ppo_hasparameters in p.propoptions);
+          end;
+
       var
          sym : tsym;
          p : tpropertysym;
@@ -566,20 +586,7 @@ implementation
            end;
          if try_to_consume(_DEFAULT) then
            begin
-              if not(is_ordinal(p.propdef) or
-{$ifndef cpu64bitaddr}
-                     is_64bitint(p.propdef) or
-{$endif cpu64bitaddr}
-                     is_class(p.propdef) or
-                     is_single(p.propdef) or
-                     (p.propdef.typ in [classrefdef,pointerdef]) or
-                     is_smallset(p.propdef)
-                    ) or
-                    (
-                     (p.propdef.typ=arraydef) and
-                     (ppo_indexed in p.propoptions)
-                    ) or
-                 (ppo_hasparameters in p.propoptions) then
+              if not allow_default_property(p) then
                 begin
                   Message(parser_e_property_cant_have_a_default_value);
                   { Error recovery }
@@ -619,9 +626,14 @@ implementation
                 end;
            end
          else if try_to_consume(_NODEFAULT) then
+           begin
+              p.default:=longint($80000000);
+           end
+         else if allow_default_property(p) then
            begin
               p.default:=longint($80000000);
            end;
+  
          { Parse possible "implements" keyword }
          if try_to_consume(_IMPLEMENTS) then
            begin