Browse Source

* accept const <guid const> = <guid string>; again, resolves #14134

git-svn-id: trunk@13384 -
florian 16 years ago
parent
commit
9d659dc937
3 changed files with 48 additions and 25 deletions
  1. 1 0
      .gitattributes
  2. 38 25
      compiler/ptconst.pas
  3. 9 0
      tests/webtbs/tw14134.pp

+ 1 - 0
.gitattributes

@@ -9189,6 +9189,7 @@ tests/webtbs/tw1407.pp svneol=native#text/plain
 tests/webtbs/tw1408.pp svneol=native#text/plain
 tests/webtbs/tw1409.pp svneol=native#text/plain
 tests/webtbs/tw1412.pp svneol=native#text/plain
+tests/webtbs/tw14134.pp svneol=native#text/plain
 tests/webtbs/tw1414.pp svneol=native#text/plain
 tests/webtbs/tw1416.pp svneol=native#text/plain
 tests/webtbs/tw1430.pp svneol=native#text/plain

+ 38 - 25
compiler/ptconst.pas

@@ -988,10 +988,9 @@ implementation
           n.free;
         end;
 
-        procedure parse_recorddef(list:tasmlist;def:trecorddef);
+      procedure parse_recorddef(list:tasmlist;def:trecorddef);
         var
           n       : tnode;
-          i,
           symidx  : longint;
           recsym,
           srsym   : tsym;
@@ -1003,35 +1002,40 @@ implementation
           bp   : tbitpackedval;
           error,
           is_packed: boolean;
+
+        procedure handle_stringconstn;
+          var
+            i       : longint;
+          begin
+            hs:=strpas(tstringconstnode(n).value_str);
+            if string2guid(hs,tmpguid) then
+              begin
+                list.concat(Tai_const.Create_32bit(longint(tmpguid.D1)));
+                list.concat(Tai_const.Create_16bit(tmpguid.D2));
+                list.concat(Tai_const.Create_16bit(tmpguid.D3));
+                for i:=Low(tmpguid.D4) to High(tmpguid.D4) do
+                  list.concat(Tai_const.Create_8bit(tmpguid.D4[i]));
+              end
+            else
+              Message(parser_e_improper_guid_syntax);
+          end;
+
+        var
+          i       : longint;
+
         begin
           { GUID }
           if (def=rec_tguid) and (token=_ID) then
             begin
               n:=comp_expr(true);
-              inserttypeconv(n,rec_tguid);
-              if n.nodetype=guidconstn then
-                begin
-                  tmpguid:=tguidconstnode(n).value;
-                  list.concat(Tai_const.Create_32bit(longint(tmpguid.D1)));
-                  list.concat(Tai_const.Create_16bit(tmpguid.D2));
-                  list.concat(Tai_const.Create_16bit(tmpguid.D3));
-                  for i:=Low(tmpguid.D4) to High(tmpguid.D4) do
-                    list.concat(Tai_const.Create_8bit(tmpguid.D4[i]));
-                end
-              else
-                Message(parser_e_illegal_expression);
-              n.free;
-              exit;
-            end;
-          if (def=rec_tguid) and ((token=_CSTRING) or (token=_CCHAR)) then
-            begin
-              n:=comp_expr(true);
-              inserttypeconv(n,cshortstringtype);
               if n.nodetype=stringconstn then
+                handle_stringconstn
+              else
                 begin
-                  hs:=strpas(tstringconstnode(n).value_str);
-                  if string2guid(hs,tmpguid) then
+                  inserttypeconv(n,rec_tguid);
+                  if n.nodetype=guidconstn then
                     begin
+                      tmpguid:=tguidconstnode(n).value;
                       list.concat(Tai_const.Create_32bit(longint(tmpguid.D1)));
                       list.concat(Tai_const.Create_16bit(tmpguid.D2));
                       list.concat(Tai_const.Create_16bit(tmpguid.D3));
@@ -1039,8 +1043,17 @@ implementation
                         list.concat(Tai_const.Create_8bit(tmpguid.D4[i]));
                     end
                   else
-                    Message(parser_e_improper_guid_syntax);
-                end
+                    Message(parser_e_illegal_expression);
+                end;
+              n.free;
+              exit;
+            end;
+          if (def=rec_tguid) and ((token=_CSTRING) or (token=_CCHAR)) then
+            begin
+              n:=comp_expr(true);
+              inserttypeconv(n,cshortstringtype);
+              if n.nodetype=stringconstn then
+                handle_stringconstn
               else
                 Message(parser_e_illegal_expression);
               n.free;

+ 9 - 0
tests/webtbs/tw14134.pp

@@ -0,0 +1,9 @@
+program t4;
+{$mode delphi}{$h+}
+
+const
+  OurGUID_str = '{F572C54B-EB2B-454A-B2A0-D9138C0D2F07}';
+  OurGUID: TGUID = OurGUID_str;
+
+begin
+end.