Forráskód Böngészése

* Fixed bug #10681.
+ Test.

git-svn-id: trunk@9879 -

yury 17 éve
szülő
commit
801837f60d
3 módosított fájl, 21 hozzáadás és 1 törlés
  1. 1 0
      .gitattributes
  2. 5 1
      compiler/defcmp.pas
  3. 15 0
      tests/webtbs/tw10681.pp

+ 1 - 0
.gitattributes

@@ -7981,6 +7981,7 @@ tests/webtbs/tw10623.pp svneol=native#text/plain
 tests/webtbs/tw1066a.pp svneol=native#text/plain
 tests/webtbs/tw1066b.pp svneol=native#text/plain
 tests/webtbs/tw1068.pp svneol=native#text/plain
+tests/webtbs/tw10681.pp svneol=native#text/plain
 tests/webtbs/tw1071.pp svneol=native#text/plain
 tests/webtbs/tw1073.pp svneol=native#text/plain
 tests/webtbs/tw1081.pp svneol=native#text/plain

+ 5 - 1
compiler/defcmp.pas

@@ -531,8 +531,12 @@ implementation
                        eq:=te_equal
                      else
                        begin
+                         { Delphi does not allow explicit type conversions for float types like:
+                             single_var:=single(double_var);
+                           But if such conversion is inserted by compiler (internal) for some purpose,
+                           it should be allowed even in Delphi mode. }
                          if (fromtreetype=realconstn) or
-                            not((cdo_explicit in cdoptions) and
+                            not((cdoptions*[cdo_explicit,cdo_internal]=[cdo_explicit]) and
                                 (m_delphi in current_settings.modeswitches)) then
                            begin
                              doconv:=tc_real_2_real;

+ 15 - 0
tests/webtbs/tw10681.pp

@@ -0,0 +1,15 @@
+{%norun}
+
+{$IFDEF FPC}
+ {$MODE Delphi}
+{$ENDIF}
+
+var
+  AStr : string;
+  AComp : Comp;
+  AInt : Integer;
+
+begin
+  AStr := '1.2345';
+  Val(AStr, AComp, AInt);
+end.