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
3292923d
Commit
3292923d
authored
Sep 17, 1992
by
Richard Stallman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(parse_number): Warn about '9' in octal constants.
Commonize overflow detection for various radices. From-SVN: r2139
parent
58939c25
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
13 deletions
+17
-13
gcc/cexp.y
+17
-13
No files found.
gcc/cexp.y
View file @
3292923d
...
...
@@ -347,6 +347,7 @@ parse_number (olen)
register int base = 10;
register int len = olen;
register int overflow = 0;
register int digit, largest_digit = 0;
int spec_long = 0;
for (c = 0; c < len; c++)
...
...
@@ -370,19 +371,14 @@ parse_number (olen)
for (; len > 0; len--) {
c = *p++;
if (c >= 'A' && c <= 'Z') c += 'a' - 'A';
if (c >= '0' && c <= '9') {
overflow |= ULONG_MAX_over_base < n;
nd = n * base + c - '0';
overflow |= nd < n;
n = nd;
} else if (base == 16 && c >= 'a' && c <= 'f') {
overflow |= ULONG_MAX_over_base < n;
nd = n * 16 + c - 'a' + 10;
overflow |= nd < n;
n = nd;
} else {
if (c >= '0' && c <= '9')
digit = c - '0';
else if (base == 16 && c >= 'a' && c <= 'f')
digit = c - 'a' + 10;
else if (base == 16 && c >= 'A' && c <= 'F')
digit = c - 'A' + 10;
else {
/* `l' means long, and `u' means unsigned. */
while (1) {
if (c == 'l' || c == 'L')
...
...
@@ -407,6 +403,11 @@ parse_number (olen)
/* Don't look for any more digits after the suffixes. */
break;
}
if (largest_digit < digit)
largest_digit = digit;
nd = n * base + digit;
overflow |= ULONG_MAX_over_base < n | nd < n;
n = nd;
}
if (len != 0) {
...
...
@@ -414,6 +415,9 @@ parse_number (olen)
return ERROR;
}
if (base <= largest_digit)
warning ("integer constant contains digits beyond the radix");
if (overflow)
warning ("integer constant out of range");
...
...
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