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
355142da
Commit
355142da
authored
Apr 05, 1995
by
Per Bothner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved 'high-level' error functions from cpperror.c to cpplib.c.
From-SVN: r9315
parent
784ea074
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
230 additions
and
218 deletions
+230
-218
gcc/cpperror.c
+10
-216
gcc/cpplib.c
+220
-2
No files found.
gcc/cpperror.c
View file @
355142da
...
...
@@ -25,27 +25,6 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#include "cpplib.h"
#include <stdio.h>
/* This defines "errno" properly for VMS, and gives us EACCES. */
#include <errno.h>
#ifndef errno
extern
int
errno
;
#endif
#ifndef VMS
#ifndef HAVE_STRERROR
extern
int
sys_nerr
;
#if defined(bsd4_4)
extern
const
char
*
const
sys_errlist
[];
#else
extern
char
*
sys_errlist
[];
#endif
#else
/* HAVE_STERRROR */
char
*
strerror
();
#endif
#else
/* VMS */
char
*
strerror
(
int
,...);
#endif
/* Print the file names and line numbers of the #include
commands which led to the current file. */
...
...
@@ -102,147 +81,25 @@ cpp_print_containing_files (pfile)
}
void
cpp_print_file_and_line
(
pfile
)
cpp_reader
*
pfile
;
{
cpp_buffer
*
ip
=
cpp_file_buffer
(
pfile
);
if
(
ip
!=
NULL
)
{
long
line
,
col
;
cpp_buf_line_and_col
(
ip
,
&
line
,
&
col
);
if
(
pfile
->
show_column
)
fprintf
(
stderr
,
"%s:%d:%d: "
,
ip
->
nominal_fname
,
line
,
col
);
else
fprintf
(
stderr
,
"%s:%d: "
,
ip
->
nominal_fname
,
line
);
}
}
void
cpp_error
(
pfile
,
msg
,
arg1
,
arg2
,
arg3
)
cpp_reader
*
pfile
;
char
*
msg
;
char
*
arg1
,
*
arg2
,
*
arg3
;
{
cpp_print_containing_files
(
pfile
);
cpp_print_file_and_line
(
pfile
);
fprintf
(
stderr
,
msg
,
arg1
,
arg2
,
arg3
);
fprintf
(
stderr
,
"
\n
"
);
pfile
->
errors
++
;
}
/* Print error message but don't count it. */
void
cpp_warning
(
pfile
,
msg
,
arg1
,
arg2
,
arg3
)
cpp_reader
*
pfile
;
char
*
msg
;
char
*
arg1
,
*
arg2
,
*
arg3
;
{
if
(
CPP_OPTIONS
(
pfile
)
->
inhibit_warnings
)
return
;
if
(
CPP_OPTIONS
(
pfile
)
->
warnings_are_errors
)
pfile
->
errors
++
;
cpp_print_containing_files
(
pfile
);
cpp_print_file_and_line
(
pfile
);
fprintf
(
stderr
,
"warning: "
);
fprintf
(
stderr
,
msg
,
arg1
,
arg2
,
arg3
);
fprintf
(
stderr
,
"
\n
"
);
}
void
cpp_error_with_line
(
pfile
,
line
,
msg
,
arg1
,
arg2
,
arg3
)
cpp_reader
*
pfile
;
int
line
;
char
*
msg
;
char
*
arg1
,
*
arg2
,
*
arg3
;
{
int
i
;
cpp_buffer
*
ip
=
cpp_file_buffer
(
pfile
);
cpp_print_containing_files
(
pfile
);
if
(
ip
!=
NULL
)
fprintf
(
stderr
,
"%s:%d: "
,
ip
->
nominal_fname
,
line
);
fprintf
(
stderr
,
msg
,
arg1
,
arg2
,
arg3
);
fprintf
(
stderr
,
"
\n
"
);
pfile
->
errors
++
;
}
void
cpp_warning_with_line
(
pfile
,
line
,
msg
,
arg1
,
arg2
,
arg3
)
cpp_reader
*
pfile
;
int
line
;
char
*
msg
;
char
*
arg1
,
*
arg2
,
*
arg3
;
{
int
i
;
cpp_buffer
*
ip
;
if
(
CPP_OPTIONS
(
pfile
)
->
inhibit_warnings
)
return
;
if
(
CPP_OPTIONS
(
pfile
)
->
warnings_are_errors
)
pfile
->
errors
++
;
cpp_print_containing_files
(
pfile
);
ip
=
cpp_file_buffer
(
pfile
);
if
(
ip
!=
NULL
)
fprintf
(
stderr
,
"%s:%d: "
,
ip
->
nominal_fname
,
line
);
fprintf
(
stderr
,
"warning: "
);
fprintf
(
stderr
,
msg
,
arg1
,
arg2
,
arg3
);
fprintf
(
stderr
,
"
\n
"
);
}
/* Print an error message and maybe count it. */
void
cpp_pedwarn
(
pfile
,
msg
,
arg1
,
arg2
,
arg3
)
cpp_file_line_for_message
(
pfile
,
filename
,
line
,
column
)
cpp_reader
*
pfile
;
char
*
msg
;
char
*
arg1
,
*
arg2
,
*
arg3
;
{
if
(
CPP_OPTIONS
(
pfile
)
->
pedantic_errors
)
cpp_error
(
pfile
,
msg
,
arg1
,
arg2
,
arg3
);
else
cpp_warning
(
pfile
,
msg
,
arg1
,
arg2
,
arg3
);
}
void
cpp_pedwarn_with_line
(
pfile
,
line
,
msg
,
arg1
,
arg2
,
arg3
)
cpp_reader
*
pfile
;
int
line
;
char
*
msg
;
char
*
arg1
,
*
arg2
,
*
arg3
;
char
*
filename
;
int
line
,
column
;
{
if
(
CPP_OPTIONS
(
pfile
)
->
pedantic_errors
)
cpp_error_with_line
(
pfile
,
line
,
msg
,
arg1
,
arg2
,
arg3
);
if
(
column
>
0
)
fprintf
(
stderr
,
"%s:%d:%d: "
,
filename
,
line
,
column
);
else
cpp_warning_with_line
(
pfile
,
line
,
msg
,
arg1
,
arg2
,
arg3
);
fprintf
(
stderr
,
"%s:%d: "
,
filename
,
line
);
}
/* Report a warning (or an error if pedantic_errors)
giving specified file name and line number, not current. */
void
cpp_pedwarn_with_file_and_line
(
pfile
,
file
,
line
,
msg
,
arg1
,
arg2
,
arg3
)
/* IS_ERROR is 1 for error, 0 for warning */
void
cpp_message
(
pfile
,
is_error
,
msg
,
arg1
,
arg2
,
arg3
)
int
is_error
;
cpp_reader
*
pfile
;
char
*
file
;
int
line
;
char
*
msg
;
char
*
arg1
,
*
arg2
,
*
arg3
;
{
if
(
!
CPP_OPTIONS
(
pfile
)
->
pedantic_errors
&&
CPP_OPTIONS
(
pfile
)
->
inhibit_warnings
)
return
;
if
(
file
!=
NULL
)
fprintf
(
stderr
,
"%s:%d: "
,
file
,
line
);
if
(
CPP_OPTIONS
(
pfile
)
->
pedantic_errors
)
if
(
is_error
)
pfile
->
errors
++
;
else
fprintf
(
stderr
,
"warning: "
);
...
...
@@ -261,69 +118,6 @@ fatal (str, arg)
}
/*
* my_strerror - return the descriptive text associated with an `errno' code.
*/
char
*
my_strerror
(
errnum
)
int
errnum
;
{
char
*
result
;
#ifndef VMS
#ifndef HAVE_STRERROR
result
=
(
char
*
)
((
errnum
<
sys_nerr
)
?
sys_errlist
[
errnum
]
:
0
);
#else
result
=
strerror
(
errnum
);
#endif
#else
/* VMS */
/* VAXCRTL's strerror() takes an optional second argument, which only
matters when the first argument is EVMSERR. However, it's simplest
just to pass it unconditionally. `vaxc$errno' is declared in
<errno.h>, and maintained by the library in parallel with `errno'.
We assume that caller's `errnum' either matches the last setting of
`errno' by the library or else does not have the value `EVMSERR'. */
result
=
strerror
(
errnum
,
vaxc
$
errno
);
#endif
if
(
!
result
)
result
=
"undocumented I/O error"
;
return
result
;
}
/* Error including a message from `errno'. */
void
cpp_error_from_errno
(
pfile
,
name
)
cpp_reader
*
pfile
;
char
*
name
;
{
int
i
;
cpp_buffer
*
ip
=
cpp_file_buffer
(
pfile
);
cpp_print_containing_files
(
pfile
);
if
(
ip
!=
NULL
)
fprintf
(
stderr
,
"%s:%d: "
,
ip
->
nominal_fname
,
ip
->
lineno
);
fprintf
(
stderr
,
"%s: %s
\n
"
,
name
,
my_strerror
(
errno
));
pfile
->
errors
++
;
}
void
cpp_perror_with_name
(
pfile
,
name
)
cpp_reader
*
pfile
;
char
*
name
;
{
fprintf
(
stderr
,
"%s: "
,
progname
);
fprintf
(
stderr
,
"%s: %s
\n
"
,
name
,
my_strerror
(
errno
));
pfile
->
errors
++
;
}
void
cpp_pfatal_with_name
(
pfile
,
name
)
cpp_reader
*
pfile
;
...
...
gcc/cpplib.c
View file @
355142da
...
...
@@ -4723,7 +4723,9 @@ cpp_get_token (pfile)
return
CPP_COMMENT
;
}
else
if
(
CPP_TRADITIONAL
(
pfile
))
goto
get_next
;
{
return
CPP_COMMENT
;
}
else
{
#if 0
...
...
@@ -7289,6 +7291,222 @@ cpp_read_check_assertion (pfile)
CPP_ADJUST_WRITTEN
(
pfile
,
-
name_length
);
/* pop */
return
result
;
}
void
cpp_print_file_and_line
(
pfile
)
cpp_reader
*
pfile
;
{
cpp_buffer
*
ip
=
cpp_file_buffer
(
pfile
);
if
(
ip
!=
NULL
)
{
long
line
,
col
;
cpp_buf_line_and_col
(
ip
,
&
line
,
&
col
);
cpp_file_line_for_message
(
pfile
,
ip
->
nominal_fname
,
line
,
pfile
->
show_column
?
col
:
-
1
);
}
}
void
cpp_error
(
pfile
,
msg
,
arg1
,
arg2
,
arg3
)
cpp_reader
*
pfile
;
char
*
msg
;
char
*
arg1
,
*
arg2
,
*
arg3
;
{
cpp_print_containing_files
(
pfile
);
cpp_print_file_and_line
(
pfile
);
cpp_message
(
pfile
,
1
,
msg
,
arg1
,
arg2
,
arg3
);
}
/* Print error message but don't count it. */
void
cpp_warning
(
pfile
,
msg
,
arg1
,
arg2
,
arg3
)
cpp_reader
*
pfile
;
char
*
msg
;
char
*
arg1
,
*
arg2
,
*
arg3
;
{
if
(
CPP_OPTIONS
(
pfile
)
->
inhibit_warnings
)
return
;
if
(
CPP_OPTIONS
(
pfile
)
->
warnings_are_errors
)
pfile
->
errors
++
;
cpp_print_containing_files
(
pfile
);
cpp_print_file_and_line
(
pfile
);
cpp_message
(
pfile
,
0
,
msg
,
arg1
,
arg2
,
arg3
);
}
/* Print an error message and maybe count it. */
void
cpp_pedwarn
(
pfile
,
msg
,
arg1
,
arg2
,
arg3
)
cpp_reader
*
pfile
;
char
*
msg
;
char
*
arg1
,
*
arg2
,
*
arg3
;
{
if
(
CPP_OPTIONS
(
pfile
)
->
pedantic_errors
)
cpp_error
(
pfile
,
msg
,
arg1
,
arg2
,
arg3
);
else
cpp_warning
(
pfile
,
msg
,
arg1
,
arg2
,
arg3
);
}
void
cpp_error_with_line
(
pfile
,
line
,
msg
,
arg1
,
arg2
,
arg3
)
cpp_reader
*
pfile
;
int
line
;
char
*
msg
;
char
*
arg1
,
*
arg2
,
*
arg3
;
{
int
i
;
cpp_buffer
*
ip
=
cpp_file_buffer
(
pfile
);
cpp_print_containing_files
(
pfile
);
if
(
ip
!=
NULL
)
cpp_file_line_for_message
(
pfile
,
ip
->
nominal_fname
,
line
,
-
1
);
cpp_message
(
pfile
,
1
,
msg
,
arg1
,
arg2
,
arg3
);
}
void
cpp_warning_with_line
(
pfile
,
line
,
msg
,
arg1
,
arg2
,
arg3
)
cpp_reader
*
pfile
;
int
line
;
char
*
msg
;
char
*
arg1
,
*
arg2
,
*
arg3
;
{
int
i
;
cpp_buffer
*
ip
;
if
(
CPP_OPTIONS
(
pfile
)
->
inhibit_warnings
)
return
;
if
(
CPP_OPTIONS
(
pfile
)
->
warnings_are_errors
)
pfile
->
errors
++
;
cpp_print_containing_files
(
pfile
);
ip
=
cpp_file_buffer
(
pfile
);
if
(
ip
!=
NULL
)
cpp_file_line_for_message
(
pfile
,
ip
->
nominal_fname
,
line
,
-
1
);
cpp_message
(
pfile
,
0
,
msg
,
arg1
,
arg2
,
arg3
);
}
void
cpp_pedwarn_with_line
(
pfile
,
line
,
msg
,
arg1
,
arg2
,
arg3
)
cpp_reader
*
pfile
;
int
line
;
char
*
msg
;
char
*
arg1
,
*
arg2
,
*
arg3
;
{
if
(
CPP_OPTIONS
(
pfile
)
->
pedantic_errors
)
cpp_error_with_line
(
pfile
,
line
,
msg
,
arg1
,
arg2
,
arg3
);
else
cpp_warning_with_line
(
pfile
,
line
,
msg
,
arg1
,
arg2
,
arg3
);
}
/* Report a warning (or an error if pedantic_errors)
giving specified file name and line number, not current. */
void
cpp_pedwarn_with_file_and_line
(
pfile
,
file
,
line
,
msg
,
arg1
,
arg2
,
arg3
)
cpp_reader
*
pfile
;
char
*
file
;
int
line
;
char
*
msg
;
char
*
arg1
,
*
arg2
,
*
arg3
;
{
if
(
!
CPP_OPTIONS
(
pfile
)
->
pedantic_errors
&&
CPP_OPTIONS
(
pfile
)
->
inhibit_warnings
)
return
;
if
(
file
!=
NULL
)
cpp_file_line_for_message
(
pfile
,
file
,
line
,
-
1
);
cpp_message
(
pfile
,
CPP_OPTIONS
(
pfile
)
->
pedantic_errors
,
msg
,
arg1
,
arg2
,
arg3
);
}
/* This defines "errno" properly for VMS, and gives us EACCES. */
#include <errno.h>
#ifndef errno
extern
int
errno
;
#endif
#ifndef VMS
#ifndef HAVE_STRERROR
extern
int
sys_nerr
;
#if defined(bsd4_4)
extern
const
char
*
const
sys_errlist
[];
#else
extern
char
*
sys_errlist
[];
#endif
#else
/* HAVE_STERRROR */
char
*
strerror
();
#endif
#else
/* VMS */
char
*
strerror
(
int
,...);
#endif
/*
* my_strerror - return the descriptive text associated with an `errno' code.
*/
char
*
my_strerror
(
errnum
)
int
errnum
;
{
char
*
result
;
#ifndef VMS
#ifndef HAVE_STRERROR
result
=
(
char
*
)
((
errnum
<
sys_nerr
)
?
sys_errlist
[
errnum
]
:
0
);
#else
result
=
strerror
(
errnum
);
#endif
#else
/* VMS */
/* VAXCRTL's strerror() takes an optional second argument, which only
matters when the first argument is EVMSERR. However, it's simplest
just to pass it unconditionally. `vaxc$errno' is declared in
<errno.h>, and maintained by the library in parallel with `errno'.
We assume that caller's `errnum' either matches the last setting of
`errno' by the library or else does not have the value `EVMSERR'. */
result
=
strerror
(
errnum
,
vaxc
$
errno
);
#endif
if
(
!
result
)
result
=
"undocumented I/O error"
;
return
result
;
}
/* Error including a message from `errno'. */
void
cpp_error_from_errno
(
pfile
,
name
)
cpp_reader
*
pfile
;
char
*
name
;
{
int
i
;
cpp_buffer
*
ip
=
cpp_file_buffer
(
pfile
);
cpp_print_containing_files
(
pfile
);
if
(
ip
!=
NULL
)
cpp_file_line_for_message
(
pfile
,
ip
->
nominal_fname
,
ip
->
lineno
,
-
1
);
cpp_message
(
pfile
,
1
,
"%s: %s
\n
"
,
name
,
my_strerror
(
errno
));
}
void
cpp_perror_with_name
(
pfile
,
name
)
cpp_reader
*
pfile
;
char
*
name
;
{
cpp_message
(
pfile
,
1
,
"%s: %s: %s
\n
"
,
progname
,
name
,
my_strerror
(
errno
));
}
/* TODO:
* No pre-compiled header file support.
...
...
@@ -7306,7 +7524,7 @@ cpp_read_check_assertion (pfile)
*
* Support -dM flag (dump_all_macros).
*
* -include should be made to return
s
results incrementally.
* -include should be made to return results incrementally.
* (current implementation only works when cpp is used as main program)
*
*/
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