summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoost <joost@3ad0048d-3df7-0310-abae-a5850022a9f2>2013-10-20 20:49:45 +0000
committerjoost <joost@3ad0048d-3df7-0310-abae-a5850022a9f2>2013-10-20 20:49:45 +0000
commit8e62d6ce143e9136b37ef901a5ef8867a4d5abbb (patch)
tree7f127bf0a5a968d0135c6797e073d1537b175fa0
parentd70be1f8f94272c76e925821ca5972526cfd3f82 (diff)
downloadfpc-joost.tar.gz
* Allow rtti-attributes only when the modeswitch prefixedattributes is setjoost
* Set the prefixedattributes by default in mode delphi git-svn-id: http://svn.freepascal.org/svn/fpc/branches/joost@25838 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--classattributes/compiler/globals.pas2
-rw-r--r--classattributes/compiler/globtype.pas6
-rw-r--r--classattributes/compiler/pdecl.pas9
-rw-r--r--classattributes/compiler/pdecobj.pas5
-rw-r--r--classattributes/tests/test/tclassattribute1.pp1
-rw-r--r--classattributes/tests/test/tclassattribute2.pp1
-rw-r--r--classattributes/tests/test/tclassattribute3.pp1
-rw-r--r--classattributes/tests/test/tclassattribute4.pp2
-rw-r--r--classattributes/tests/test/tclassattribute5.pp1
-rw-r--r--classattributes/tests/test/tclassattribute6.pp1
-rw-r--r--classattributes/tests/test/tclassattribute7.pp1
-rw-r--r--classattributes/tests/test/tclassattribute8.pp1
-rw-r--r--classattributes/tests/test/tclassattribute9.pp1
13 files changed, 23 insertions, 9 deletions
diff --git a/classattributes/compiler/globals.pas b/classattributes/compiler/globals.pas
index c0fffb3e73..f8a0724746 100644
--- a/classattributes/compiler/globals.pas
+++ b/classattributes/compiler/globals.pas
@@ -52,7 +52,7 @@ interface
[m_delphi,m_all,m_class,m_objpas,m_result,m_string_pchar,
m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring,
m_out,m_default_para,m_duplicate_names,m_hintdirective,
- m_property,m_default_inline,m_except,m_advanced_records];
+ m_property,m_default_inline,m_except,m_advanced_records,m_prefixed_attributes];
delphiunicodemodeswitches = delphimodeswitches + [m_systemcodepage,m_default_unicodestring];
fpcmodeswitches =
[m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
diff --git a/classattributes/compiler/globtype.pas b/classattributes/compiler/globtype.pas
index e562792b91..cd7e9f4426 100644
--- a/classattributes/compiler/globtype.pas
+++ b/classattributes/compiler/globtype.pas
@@ -336,8 +336,9 @@ interface
m_final_fields, { allows declaring fields as "final", which means they must be initialised
in the (class) constructor and are constant from then on (same as final
fields in Java) }
- m_default_unicodestring { makes the default string type in $h+ mode unicodestring rather than
+ m_default_unicodestring, { makes the default string type in $h+ mode unicodestring rather than
ansistring; similarly, char becomes unicodechar rather than ansichar }
+ m_prefixed_attributes { enable attributes that are defined before the type they belong to }
);
tmodeswitches = set of tmodeswitch;
@@ -492,7 +493,8 @@ interface
'ISOUNARYMINUS',
'SYSTEMCODEPAGE',
'FINALFIELDS',
- 'UNICODESTRINGS');
+ 'UNICODESTRINGS',
+ 'PREFIXEDATTRIBUTES');
type
diff --git a/classattributes/compiler/pdecl.pas b/classattributes/compiler/pdecl.pas
index 7696bb068e..fc0067611e 100644
--- a/classattributes/compiler/pdecl.pas
+++ b/classattributes/compiler/pdecl.pas
@@ -498,10 +498,11 @@ implementation
generictokenbuf:=nil;
{ class attribute definitions? }
- while token=_LECKKLAMMER do
- begin
- parse_rttiattributes(current_rtticlassattributesdef);
- end;
+ if m_prefixed_attributes in current_settings.modeswitches then
+ while token=_LECKKLAMMER do
+ begin
+ parse_rttiattributes(current_rtticlassattributesdef);
+ end;
{ fpc generic declaration? }
isgeneric:=not(m_delphi in current_settings.modeswitches) and try_to_consume(_GENERIC);
diff --git a/classattributes/compiler/pdecobj.pas b/classattributes/compiler/pdecobj.pas
index 2268a3e5e0..f3be881722 100644
--- a/classattributes/compiler/pdecobj.pas
+++ b/classattributes/compiler/pdecobj.pas
@@ -1227,7 +1227,10 @@ implementation
end;
_LECKKLAMMER:
begin
- parse_rttiattributes(current_rttiattributesdef);
+ if m_prefixed_attributes in current_settings.modeswitches then
+ parse_rttiattributes(current_rttiattributesdef)
+ else
+ consume(_ID);
end;
_END :
begin
diff --git a/classattributes/tests/test/tclassattribute1.pp b/classattributes/tests/test/tclassattribute1.pp
index b38f7224b3..ef0b499465 100644
--- a/classattributes/tests/test/tclassattribute1.pp
+++ b/classattributes/tests/test/tclassattribute1.pp
@@ -1,6 +1,7 @@
program tclassattribute1;
{$mode objfpc}{$H+}
+{$modeswitch prefixedattributes}
uses
typinfo;
diff --git a/classattributes/tests/test/tclassattribute2.pp b/classattributes/tests/test/tclassattribute2.pp
index 13ddf2f21c..3b5cd8055f 100644
--- a/classattributes/tests/test/tclassattribute2.pp
+++ b/classattributes/tests/test/tclassattribute2.pp
@@ -2,6 +2,7 @@
program tclassattribute2;
{$mode objfpc}{$H+}
+{$modeswitch prefixedattributes}
type
// Delphi XE does compile attributes that are not defined, but ignores them.
diff --git a/classattributes/tests/test/tclassattribute3.pp b/classattributes/tests/test/tclassattribute3.pp
index 44ccebc5bc..41a968a23d 100644
--- a/classattributes/tests/test/tclassattribute3.pp
+++ b/classattributes/tests/test/tclassattribute3.pp
@@ -2,6 +2,7 @@
program tclassattribute3;
{$mode objfpc}{$H+}
+{$modeswitch prefixedattributes}
type
diff --git a/classattributes/tests/test/tclassattribute4.pp b/classattributes/tests/test/tclassattribute4.pp
index f4f73d52b0..d555ebcf0d 100644
--- a/classattributes/tests/test/tclassattribute4.pp
+++ b/classattributes/tests/test/tclassattribute4.pp
@@ -1,6 +1,6 @@
program tclassattribute4;
-{$mode objfpc}{$H+}
+{$mode delphi}
uses
typinfo;
diff --git a/classattributes/tests/test/tclassattribute5.pp b/classattributes/tests/test/tclassattribute5.pp
index cde852ca95..ea73121871 100644
--- a/classattributes/tests/test/tclassattribute5.pp
+++ b/classattributes/tests/test/tclassattribute5.pp
@@ -2,6 +2,7 @@
program tclassattribute5;
{$mode objfpc}{$H+}
+{$modeswitch prefixedattributes}
uses
typinfo;
diff --git a/classattributes/tests/test/tclassattribute6.pp b/classattributes/tests/test/tclassattribute6.pp
index c9467aa758..8734302f98 100644
--- a/classattributes/tests/test/tclassattribute6.pp
+++ b/classattributes/tests/test/tclassattribute6.pp
@@ -1,6 +1,7 @@
program tclassattribute6;
{$mode objfpc}{$H+}
+{$modeswitch prefixedattributes}
uses
typinfo;
diff --git a/classattributes/tests/test/tclassattribute7.pp b/classattributes/tests/test/tclassattribute7.pp
index fdd34eaac8..b7864efc70 100644
--- a/classattributes/tests/test/tclassattribute7.pp
+++ b/classattributes/tests/test/tclassattribute7.pp
@@ -2,6 +2,7 @@
program tclassattribute7;
{$mode objfpc}{$H+}
+{$modeswitch prefixedattributes}
uses
typinfo;
diff --git a/classattributes/tests/test/tclassattribute8.pp b/classattributes/tests/test/tclassattribute8.pp
index d5f93eb57a..1c87949f9b 100644
--- a/classattributes/tests/test/tclassattribute8.pp
+++ b/classattributes/tests/test/tclassattribute8.pp
@@ -2,6 +2,7 @@
program tclassattribute8;
{$mode objfpc}{$H+}
+{$modeswitch prefixedattributes}
uses
typinfo;
diff --git a/classattributes/tests/test/tclassattribute9.pp b/classattributes/tests/test/tclassattribute9.pp
index 4ce8f81ac9..ed07789024 100644
--- a/classattributes/tests/test/tclassattribute9.pp
+++ b/classattributes/tests/test/tclassattribute9.pp
@@ -1,6 +1,7 @@
program tclassattribute9;
{$mode objfpc}{$H+}
+{$modeswitch prefixedattributes}
uses
typinfo;