Procházet zdrojové kódy

* set PIC defines earlier, resolve #25788

git-svn-id: trunk@26924 -
florian před 11 roky
rodič
revize
68f1a51164
3 změnil soubory, kde provedl 45 přidání a 11 odebrání
  1. 1 0
      .gitattributes
  2. 27 11
      compiler/pmodules.pas
  3. 17 0
      tests/webtbf/tw25788.pp

+ 1 - 0
.gitattributes

@@ -12668,6 +12668,7 @@ tests/webtbf/tw25504.pp svneol=native#text/plain
 tests/webtbf/tw2562.pp svneol=native#text/plain
 tests/webtbf/tw25622.pp svneol=native#text/plain
 tests/webtbf/tw25622a.pp svneol=native#text/plain
+tests/webtbf/tw25788.pp svneol=native#text/pascal
 tests/webtbf/tw2657.pp svneol=native#text/plain
 tests/webtbf/tw2670.pp svneol=native#text/plain
 tests/webtbf/tw2719.pp svneol=native#text/plain

+ 27 - 11
compiler/pmodules.pas

@@ -803,13 +803,16 @@ type
          try_consume_hintdirective(current_module.moduleoptions, current_module.deprecatedmsg);
 
          consume(_SEMICOLON);
-         consume(_INTERFACE);
-         { global switches are read, so further changes aren't allowed }
-         current_module.in_global:=false;
 
-         { handle the global switches }
+         { handle the global switches, do this before interface, because after interface has been
+           read, all following directives are parsed as well }
          setupglobalswitches;
 
+         consume(_INTERFACE);
+
+         { global switches are read, so further changes aren't allowed  }
+         current_module.in_global:=false;
+
          message1(unit_u_loading_interface_units,current_module.modulename^);
 
          { update status }
@@ -1649,14 +1652,16 @@ type
          if tf_library_needs_pic in target_info.flags then
            include(current_settings.moduleswitches,cs_create_pic);
 
+         { setup things using the switches, do this before the semicolon, because after the semicolon has been
+           read, all following directives are parsed as well }
+
+         setupglobalswitches;
+
          consume(_SEMICOLON);
 
          { global switches are read, so further changes aren't allowed }
          current_module.in_global:=false;
 
-         { setup things using the switches }
-         setupglobalswitches;
-
          { set implementation flag }
          current_module.in_interface:=false;
          current_module.interface_compiled:=true;
@@ -1972,6 +1977,10 @@ type
               if tf_library_needs_pic in target_info.flags then
                 include(current_settings.moduleswitches,cs_create_pic);
 
+              { setup things using the switches, do this before the semicolon, because after the semicolon has been
+                read, all following directives are parsed as well }
+              setupglobalswitches;
+
               consume(_SEMICOLON);
            end
          else
@@ -2013,17 +2022,24 @@ type
                    until not try_to_consume(_COMMA);
                    consume(_RKLAMMER);
                 end;
+
+              { setup things using the switches, do this before the semicolon, because after the semicolon has been
+                read, all following directives are parsed as well }
+              setupglobalswitches;
+
               consume(_SEMICOLON);
             end
          else if (target_info.system in systems_unit_program_exports) then
-           exportlib.preparelib(current_module.realmodulename^);
+           begin
+             exportlib.preparelib(current_module.realmodulename^);
+
+             { setup things using the switches }
+             setupglobalswitches;
+           end;
 
          { global switches are read, so further changes aren't allowed }
          current_module.in_global:=false;
 
-         { setup things using the switches }
-         setupglobalswitches;
-
          { set implementation flag }
          current_module.in_interface:=false;
          current_module.interface_compiled:=true;

+ 17 - 0
tests/webtbf/tw25788.pp

@@ -0,0 +1,17 @@
+{ %norun }
+{ %opt=-Cg }
+{ %fail }
+{ %target=linux,win64,freebsd,darwin }
+
+unit tw25788;
+
+interface
+
+//const a=1; // uncomment this to make it fail as expected
+
+{$ifdef FPC_PIC}
+{$error Don't want this to compile with PIC}
+{$endif}
+
+implementation
+end.