Преглед на файлове

* 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 години
родител
ревизия
d2169a7e43
променени са 1 файла, в които са добавени 26 реда и са изтрити 14 реда
  1. 26 14
      compiler/pdecvar.pas

+ 26 - 14
compiler/pdecvar.pas

@@ -218,6 +218,26 @@ implementation
              end;
              end;
           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
       var
          sym : tsym;
          sym : tsym;
          p : tpropertysym;
          p : tpropertysym;
@@ -566,20 +586,7 @@ implementation
            end;
            end;
          if try_to_consume(_DEFAULT) then
          if try_to_consume(_DEFAULT) then
            begin
            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
                 begin
                   Message(parser_e_property_cant_have_a_default_value);
                   Message(parser_e_property_cant_have_a_default_value);
                   { Error recovery }
                   { Error recovery }
@@ -619,9 +626,14 @@ implementation
                 end;
                 end;
            end
            end
          else if try_to_consume(_NODEFAULT) then
          else if try_to_consume(_NODEFAULT) then
+           begin
+              p.default:=longint($80000000);
+           end
+         else if allow_default_property(p) then
            begin
            begin
               p.default:=longint($80000000);
               p.default:=longint($80000000);
            end;
            end;
+  
          { Parse possible "implements" keyword }
          { Parse possible "implements" keyword }
          if try_to_consume(_IMPLEMENTS) then
          if try_to_consume(_IMPLEMENTS) then
            begin
            begin