Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
e26ceb28
Commit
e26ceb28
authored
31 years ago
by
Richard Stallman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(yylex): Handle i together with f or l in float constant.
From-SVN: r5501
parent
2da63e2a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
39 deletions
+78
-39
gcc/c-lex.c
+78
-39
No files found.
gcc/c-lex.c
View file @
e26ceb28
...
...
@@ -1477,47 +1477,86 @@ yylex ()
}
else
{
int
fflag
=
0
,
lflag
=
0
;
/* Copy token_buffer now, while it has just the number
and not the suffixes; once we add `f' or `i',
REAL_VALUE_ATOF may not work any more. */
char
*
copy
=
(
char
*
)
alloca
(
p
-
token_buffer
+
1
);
bcopy
(
token_buffer
,
copy
,
p
-
token_buffer
+
1
);
set_float_handler
(
handler
);
/* The second argument, machine_mode, of REAL_VALUE_ATOF tells the
desired precision of the binary result of decimal-to-binary conversion. */
while
(
1
)
{
int
lose
=
0
;
/* Read the suffixes to choose a data type. */
switch
(
c
)
{
case
'f'
:
case
'F'
:
type
=
float_type_node
;
value
=
REAL_VALUE_ATOF
(
token_buffer
,
TYPE_MODE
(
type
));
if
(
TARGET_FLOAT_FORMAT
!=
IEEE_FLOAT_FORMAT
&&
REAL_VALUE_ISINF
(
value
)
&&
pedantic
)
pedwarn
(
"floating point number exceeds range of `float'"
);
garbage_chars
=
-
1
;
break
;
case
'l'
:
case
'L'
:
type
=
long_double_type_node
;
value
=
REAL_VALUE_ATOF
(
token_buffer
,
TYPE_MODE
(
type
));
if
(
TARGET_FLOAT_FORMAT
!=
IEEE_FLOAT_FORMAT
&&
REAL_VALUE_ISINF
(
value
)
&&
pedantic
)
pedwarn
(
"floating point number exceeds range of `long double'"
);
garbage_chars
=
-
1
;
break
;
case
'i'
:
case
'I'
:
if
(
imag
)
error
(
"more than one `i' or `j' in numeric constant"
);
imag
=
1
;
garbage_chars
=
-
1
;
break
;
default
:
value
=
REAL_VALUE_ATOF
(
token_buffer
,
TYPE_MODE
(
type
));
if
(
TARGET_FLOAT_FORMAT
!=
IEEE_FLOAT_FORMAT
&&
REAL_VALUE_ISINF
(
value
)
&&
pedantic
)
pedwarn
(
"floating point number exceeds range of `double'"
);
}
set_float_handler
(
NULL_PTR
);
/* Read the suffixes to choose a data type. */
switch
(
c
)
{
case
'f'
:
case
'F'
:
if
(
fflag
)
error
(
"more than one `f' in numeric constant"
);
fflag
=
1
;
break
;
case
'l'
:
case
'L'
:
if
(
lflag
)
error
(
"more than one `l' in numeric constant"
);
lflag
=
1
;
break
;
case
'i'
:
case
'I'
:
if
(
imag
)
error
(
"more than one `i' or `j' in numeric constant"
);
imag
=
1
;
break
;
default
:
lose
=
1
;
}
if
(
lose
)
break
;
if
(
p
>=
token_buffer
+
maxtoken
-
3
)
p
=
extend_token_buffer
(
p
);
*
p
++
=
c
;
*
p
=
0
;
c
=
getc
(
finput
);
}
/* The second argument, machine_mode, of REAL_VALUE_ATOF
tells the desired precision of the binary result
of decimal-to-binary conversion. */
if
(
fflag
)
{
if
(
lflag
)
error
(
"both `f' and `l' in floating constant"
);
type
=
float_type_node
;
value
=
REAL_VALUE_ATOF
(
copy
,
TYPE_MODE
(
type
));
if
(
TARGET_FLOAT_FORMAT
!=
IEEE_FLOAT_FORMAT
&&
REAL_VALUE_ISINF
(
value
)
&&
pedantic
)
pedwarn
(
"floating point number exceeds range of `float'"
);
}
else
if
(
lflag
)
{
type
=
long_double_type_node
;
value
=
REAL_VALUE_ATOF
(
copy
,
TYPE_MODE
(
type
));
if
(
TARGET_FLOAT_FORMAT
!=
IEEE_FLOAT_FORMAT
&&
REAL_VALUE_ISINF
(
value
)
&&
pedantic
)
pedwarn
(
"floating point number exceeds range of `long double'"
);
}
else
{
value
=
REAL_VALUE_ATOF
(
copy
,
TYPE_MODE
(
type
));
if
(
TARGET_FLOAT_FORMAT
!=
IEEE_FLOAT_FORMAT
&&
REAL_VALUE_ISINF
(
value
)
&&
pedantic
)
pedwarn
(
"floating point number exceeds range of `double'"
);
}
set_float_handler
(
NULL_PTR
);
}
#ifdef ERANGE
if
(
errno
==
ERANGE
&&
!
flag_traditional
&&
pedantic
)
...
...
@@ -1533,7 +1572,7 @@ yylex ()
}
}
#endif
/* Note: garbage_chars is -1 if first char is *not* garbage. */
garbage_chars
=
0
;
while
(
isalnum
(
c
)
||
c
==
'.'
||
c
==
'_'
||
(
!
flag_traditional
&&
(
c
==
'+'
||
c
==
'-'
)
&&
(
p
[
-
1
]
==
'e'
||
p
[
-
1
]
==
'E'
)))
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment