Browse Source

Fix for Mantis #24872.

psub.pas, tcgprocinfo.parse_body:
  * also check record symtables besides object symtables to determine whether the staticsymtable is accessed from a globally declared generic
  * use a translateable message if the static symtable is accessed if it should not
msg/errore.msg:
  + add new error message for when the static symtable is accessed from a global generic
msgidx.inc & msgtixt.inc:
  * regenerated

+ added test

git-svn-id: trunk@29427 -
svenbarth 10 years ago
parent
commit
af43e5e3e9
6 changed files with 446 additions and 415 deletions
  1. 1 0
      .gitattributes
  2. 4 1
      compiler/msg/errore.msg
  3. 3 2
      compiler/msgidx.inc
  4. 413 410
      compiler/msgtxt.inc
  5. 2 2
      compiler/psub.pas
  6. 23 0
      tests/webtbs/tw24872.pp

+ 1 - 0
.gitattributes

@@ -14060,6 +14060,7 @@ tests/webtbs/tw24863.pp svneol=native#text/plain
 tests/webtbs/tw24865.pp svneol=native#text/pascal
 tests/webtbs/tw24865.pp svneol=native#text/pascal
 tests/webtbs/tw24867.pp svneol=native#text/pascal
 tests/webtbs/tw24867.pp svneol=native#text/pascal
 tests/webtbs/tw24871.pp svneol=native#text/pascal
 tests/webtbs/tw24871.pp svneol=native#text/pascal
+tests/webtbs/tw24872.pp svneol=native#text/pascal
 tests/webtbs/tw24915.pp svneol=native#text/pascal
 tests/webtbs/tw24915.pp svneol=native#text/pascal
 tests/webtbs/tw2492.pp svneol=native#text/plain
 tests/webtbs/tw2492.pp svneol=native#text/plain
 tests/webtbs/tw2494.pp svneol=native#text/plain
 tests/webtbs/tw2494.pp svneol=native#text/plain

+ 4 - 1
compiler/msg/errore.msg

@@ -411,7 +411,7 @@ scan_e_illegal_hugepointernormalization=02098_E_Illegal argument for HUGEPOINTER
 #
 #
 # Parser
 # Parser
 #
 #
-# 03338 is the last used one
+# 03339 is the last used one
 #
 #
 % \section{Parser messages}
 % \section{Parser messages}
 % This section lists all parser messages. The parser takes care of the
 % This section lists all parser messages. The parser takes care of the
@@ -1528,6 +1528,9 @@ parser_w_ptr_type_ignored=03338_W_Pointer type "$1" ignored
 % The specified pointer type modifier is ignored, because it is not supported on
 % The specified pointer type modifier is ignored, because it is not supported on
 % the current platform. This happens, for example, when a far pointer is
 % the current platform. This happens, for example, when a far pointer is
 % declared on a non-x86 platform.
 % declared on a non-x86 platform.
+parser_e_global_generic_references_static=03339_E_Global Generic template references static symtable
+% A generic declared in the interface section of a unit must not reference symbols that belong
+% solely to the implementation section of that unit.
 %
 %
 %
 %
 %
 %

+ 3 - 2
compiler/msgidx.inc

@@ -440,6 +440,7 @@ const
   parser_e_overloaded_have_same_mangled_name=03336;
   parser_e_overloaded_have_same_mangled_name=03336;
   parser_e_default_value_val_const=03337;
   parser_e_default_value_val_const=03337;
   parser_w_ptr_type_ignored=03338;
   parser_w_ptr_type_ignored=03338;
+  parser_e_global_generic_references_static=03339;
   type_e_mismatch=04000;
   type_e_mismatch=04000;
   type_e_incompatible_types=04001;
   type_e_incompatible_types=04001;
   type_e_not_equal_types=04002;
   type_e_not_equal_types=04002;
@@ -1000,9 +1001,9 @@ const
   option_info=11024;
   option_info=11024;
   option_help_pages=11025;
   option_help_pages=11025;
 
 
-  MsgTxtSize = 74490;
+  MsgTxtSize = 74549;
 
 
   MsgIdxMax : array[1..20] of longint=(
   MsgIdxMax : array[1..20] of longint=(
-    26,99,339,123,95,57,126,27,202,64,
+    26,99,340,123,95,57,126,27,202,64,
     58,20,1,1,1,1,1,1,1,1
     58,20,1,1,1,1,1,1,1,1
   );
   );

File diff suppressed because it is too large
+ 413 - 410
compiler/msgtxt.inc


+ 2 - 2
compiler/psub.pas

@@ -1795,11 +1795,11 @@ implementation
              { Give an error for accesses in the static symtable that aren't visible
              { Give an error for accesses in the static symtable that aren't visible
                outside the current unit }
                outside the current unit }
              st:=procdef.owner;
              st:=procdef.owner;
-             while (st.symtabletype=ObjectSymtable) do
+             while (st.symtabletype in [ObjectSymtable,recordsymtable]) do
                st:=st.defowner.owner;
                st:=st.defowner.owner;
              if (pi_uses_static_symtable in flags) and
              if (pi_uses_static_symtable in flags) and
                 (st.symtabletype<>staticsymtable) then
                 (st.symtabletype<>staticsymtable) then
-               Comment(V_Error,'Global Generic template references static symtable');
+               Message(parser_e_global_generic_references_static);
            end;
            end;
 
 
          { save exit info }
          { save exit info }

+ 23 - 0
tests/webtbs/tw24872.pp

@@ -0,0 +1,23 @@
+{ %NORUN }
+
+program tw24872;
+
+{$mode delphi}
+
+procedure Test;
+begin
+end;
+
+type
+  TRec<T> = record {for generic class is ok, and non generic record too}
+    procedure Foo;
+  end;
+
+procedure TRec<T>.Foo;
+begin
+  Test
+end; // Error: Global Generic template references static symtable
+
+begin
+end.
+

Some files were not shown because too many files changed in this diff