diff --git a/compiler/browcol.pas b/compiler/browcol.pas index f2979526b4..32230064f7 100644 --- a/compiler/browcol.pas +++ b/compiler/browcol.pas @@ -373,14 +373,14 @@ begin GetStr:=P^; end; -function IntToStr(L: longint): string; +function IntToStr(L: longint): string; {$ifdef USEPURE}pure;{$endif} var S: string; begin Str(L,S); IntToStr:=S; end; -function UpcaseStr(S: string): string; +function UpcaseStr(S: string): string; {$ifdef USEPURE}pure;{$endif} var I: integer; begin for I:=1 to length(S) do diff --git a/compiler/cutils.pas b/compiler/cutils.pas index d2ccd3c9cf..df44573f70 100644 --- a/compiler/cutils.pas +++ b/compiler/cutils.pas @@ -59,14 +59,14 @@ interface function max(const a,b : Tconstexprint) : Tconstexprint;{$ifdef USEINLINE}inline;{$endif} {# Return value @var(i) aligned on @var(a) boundary } - function align(i,a:longint):longint;{$ifdef USEINLINE}inline;{$endif} - function align(i,a:int64):int64;{$ifdef USEINLINE}inline;{$endif} - function align(i,a:qword):qword;{$ifdef USEINLINE}inline;{$endif} + function align(i,a:longint):longint;{$ifdef USEPURE}pure;{$endif}{$ifdef USEINLINE}inline;{$endif} + function align(i,a:int64):int64;{$ifdef USEPURE}pure;{$endif}{$ifdef USEINLINE}inline;{$endif} + function align(i,a:qword):qword;{$ifdef USEPURE}pure;{$endif}{$ifdef USEINLINE}inline;{$endif} { if you have an address aligned using "oldalignment" and add an offset of (a multiple of) offset to it, this function calculates the new minimally guaranteed alignment } - function newalignment(oldalignment: longint; offset: int64): longint; + function newalignment(oldalignment: longint; offset: int64): longint;{$ifdef USEPURE}pure;{$endif} {# Return @var(b) with the bit order reversed } function reverse_byte(b: byte): byte; {# Return @var(w) with the bit order reversed } @@ -74,11 +74,11 @@ interface {# Return @var(l) with the bit order reversed } function reverse_longword(l: longword): longword; - function next_prime(l: longint): longint; + function next_prime(l: longint): longint;{$ifdef USEPURE}pure;{$endif} - function used_align(varalign,minalign,maxalign:longint):longint; - function isbetteralignedthan(new, org, limit: cardinal): boolean; - function packedbitsloadsize(bitlen: int64) : int64; + function used_align(varalign,minalign,maxalign:longint):longint;{$ifdef USEPURE}pure;{$endif} + function isbetteralignedthan(new, org, limit: cardinal): boolean;{$ifdef USEPURE}pure;{$endif} + function packedbitsloadsize(bitlen: int64) : int64;{$ifdef USEPURE}pure;{$endif} procedure Replace(var s:string;s1:string;const s2:string); procedure Replace(var s:AnsiString;s1:string;const s2:AnsiString); procedure ReplaceCase(var s:string;const s1,s2:string); @@ -103,13 +103,13 @@ interface function GetToken(var s:ansistring;endchar:char):ansistring; procedure uppervar(var s : string); function realtostr(e:extended):string;{$ifdef USEINLINE}inline;{$endif} - function tostr(i : qword) : string;{$ifdef USEINLINE}inline;{$endif}overload; - function tostr(i : int64) : string;{$ifdef USEINLINE}inline;{$endif}overload; - function tostr(i : longint) : string;{$ifdef USEINLINE}inline;{$endif}overload; - function tostr_with_plus(i : int64) : string;{$ifdef USEINLINE}inline;{$endif} + function tostr(i : qword) : string;{$ifdef USEPURE}pure;{$endif}{$ifdef USEINLINE}inline;{$endif}overload; + function tostr(i : int64) : string;{$ifdef USEPURE}pure;{$endif}{$ifdef USEINLINE}inline;{$endif}overload; + function tostr(i : longint) : string;{$ifdef USEPURE}pure;{$endif}{$ifdef USEINLINE}inline;{$endif}overload; + function tostr_with_plus(i : int64) : string;{$ifdef USEPURE}pure;{$endif}{$ifdef USEINLINE}inline;{$endif} function DStr(l:longint):string; {# Returns true if the string s is a number } - function is_number(const s : string) : boolean;{$ifdef USEINLINE}inline;{$endif} + function is_number(const s : string) : boolean;{$ifdef USEPURE}pure;{$endif}{$ifdef USEINLINE}inline;{$endif} {# Returns true if value is a power of 2, the actual exponent value is returned in power. } diff --git a/compiler/fpcdefs.inc b/compiler/fpcdefs.inc index ca0bc68fc0..4a6ed3e2a3 100644 --- a/compiler/fpcdefs.inc +++ b/compiler/fpcdefs.inc @@ -36,6 +36,13 @@ {$define cpawaremessages} {$endif} +{ Use pure functions where appropriate, but not when EXTDEBUG is used } +{$ifndef EXTDEBUG} + {$ifdef FPC_HAS_PURE} + {$define USEPURE} + {$endif FPC_HAS_PURE} +{$endif EXTDEBUG} + {$ifdef DEBUG_ALL_OPT} { for aopt unit } {$define DEBUG_OPTALLOC} diff --git a/compiler/nld.pas b/compiler/nld.pas index e3f1e44301..2442418a4f 100644 --- a/compiler/nld.pas +++ b/compiler/nld.pas @@ -333,6 +333,7 @@ implementation n.symtableentry:=symtableentry; n.fprocdef:=fprocdef; n.loadnodeflags:=loadnodeflags; + if symtableentry.typ=labelsym then begin { see the comments for the tgotonode.labelsym field }