mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 02:09:14 +02:00
* fix handling of const string symbols in preprocessor expressions
+ accept string constants in preprocessor expressions, resolves #31246 git-svn-id: trunk@35432 -
This commit is contained in:
parent
0276bb374d
commit
3d6d5145bf
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -15364,6 +15364,7 @@ tests/webtbs/tw31120.pp svneol=native#text/pascal
|
|||||||
tests/webtbs/tw3113.pp svneol=native#text/plain
|
tests/webtbs/tw3113.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw31201.pp svneol=native#text/pascal
|
tests/webtbs/tw31201.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw3124.pp svneol=native#text/plain
|
tests/webtbs/tw3124.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw31246.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw31305.pp svneol=native#text/pascal
|
tests/webtbs/tw31305.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw3131.pp svneol=native#text/plain
|
tests/webtbs/tw3131.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw31332.pp svneol=native#text/pascal
|
tests/webtbs/tw31332.pp svneol=native#text/pascal
|
||||||
|
@ -948,7 +948,7 @@ type
|
|||||||
begin
|
begin
|
||||||
value.len:=c.value.len;
|
value.len:=c.value.len;
|
||||||
getmem(value.valueptr,value.len+1);
|
getmem(value.valueptr,value.len+1);
|
||||||
move(c.value.valueptr^,value.valueptr,value.len+1);
|
move(c.value.valueptr^,value.valueptr^,value.len+1);
|
||||||
end;
|
end;
|
||||||
constwstring:
|
constwstring:
|
||||||
begin
|
begin
|
||||||
@ -1028,7 +1028,7 @@ type
|
|||||||
getmem(sp,len+1);
|
getmem(sp,len+1);
|
||||||
move(s[1],sp^,len+1);
|
move(s[1],sp^,len+1);
|
||||||
value.valueptr:=sp;
|
value.valueptr:=sp;
|
||||||
value.len:=length(s);
|
value.len:=len;
|
||||||
def:=strdef;
|
def:=strdef;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1091,7 +1091,7 @@ type
|
|||||||
(is_ordinal(v.def) or is_fpu(v.def)) and
|
(is_ordinal(v.def) or is_fpu(v.def)) and
|
||||||
(is_ordinal(def) or is_fpu(def))
|
(is_ordinal(def) or is_fpu(def))
|
||||||
) or
|
) or
|
||||||
(is_string(v.def) and is_string(def));
|
(is_stringlike(v.def) and is_stringlike(def));
|
||||||
if not result then
|
if not result then
|
||||||
Message2(type_e_incompatible_types,def.typename,v.def.typename);
|
Message2(type_e_incompatible_types,def.typename,v.def.typename);
|
||||||
end;
|
end;
|
||||||
@ -1359,7 +1359,7 @@ type
|
|||||||
case consttyp of
|
case consttyp of
|
||||||
conststring,
|
conststring,
|
||||||
constresourcestring :
|
constresourcestring :
|
||||||
freemem(pchar(value.valueptr),value.len+1);
|
freemem(value.valueptr,value.len+1);
|
||||||
constwstring :
|
constwstring :
|
||||||
donewidestring(pcompilerwidestring(value.valueptr));
|
donewidestring(pcompilerwidestring(value.valueptr));
|
||||||
constreal :
|
constreal :
|
||||||
@ -2042,6 +2042,11 @@ type
|
|||||||
end;
|
end;
|
||||||
preproc_consume(_INTCONST);
|
preproc_consume(_INTCONST);
|
||||||
end
|
end
|
||||||
|
else if current_scanner.preproc_token = _CSTRING then
|
||||||
|
begin
|
||||||
|
result:=texprvalue.create_str(current_scanner.preproc_pattern);
|
||||||
|
preproc_consume(_CSTRING);
|
||||||
|
end
|
||||||
else if current_scanner.preproc_token = _REALNUMBER then
|
else if current_scanner.preproc_token = _REALNUMBER then
|
||||||
begin
|
begin
|
||||||
result:=texprvalue.try_parse_real(current_scanner.preproc_pattern);
|
result:=texprvalue.try_parse_real(current_scanner.preproc_pattern);
|
||||||
@ -5331,6 +5336,7 @@ exit_label:
|
|||||||
var
|
var
|
||||||
low,high,mid: longint;
|
low,high,mid: longint;
|
||||||
optoken: ttoken;
|
optoken: ttoken;
|
||||||
|
s : string;
|
||||||
begin
|
begin
|
||||||
skipspace;
|
skipspace;
|
||||||
case c of
|
case c of
|
||||||
@ -5367,6 +5373,12 @@ exit_label:
|
|||||||
current_scanner.preproc_pattern:=pattern;
|
current_scanner.preproc_pattern:=pattern;
|
||||||
readpreproc:=optoken;
|
readpreproc:=optoken;
|
||||||
end;
|
end;
|
||||||
|
'''' :
|
||||||
|
begin
|
||||||
|
s:=readquotedstring;
|
||||||
|
current_scanner.preproc_pattern:=cstringpattern;
|
||||||
|
readpreproc:=_CSTRING;
|
||||||
|
end;
|
||||||
'0'..'9' :
|
'0'..'9' :
|
||||||
begin
|
begin
|
||||||
readnumber;
|
readnumber;
|
||||||
|
13
tests/webtbs/tw31246.pp
Normal file
13
tests/webtbs/tw31246.pp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
program Project1;
|
||||||
|
const
|
||||||
|
|
||||||
|
text = '';
|
||||||
|
|
||||||
|
text2 = {$IF text <> ''}
|
||||||
|
asdf
|
||||||
|
{$ELSE}
|
||||||
|
'';
|
||||||
|
{$IFEND}
|
||||||
|
|
||||||
|
begin
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user