Commit d41fbd2c by Mark Mitchell Committed by Mark Mitchell

cp-error.def: New file.

	* cp-error.def: New file.
	* Make-lang.in (cc1plus): Add dependency on it.
	* Makefile.in (CXX_TREE_H): Likewise.
	* cp-tree.h (error_code): New type.
	Include cp-error.def to get error codes.  Make it possible to
	include cp-tree.h in errfn.c.
	(enable_warning): New function.
	(flag_diag_codes): New variable.
	* errfn.c: Include cp-tree.h.
	(cp_err_msg): New type.  Include cp-error.def to define it.
	(err_msgs): New variable.
	(is_warning_enabled): New function.
	(cp_thing): Take an error_code, not a format string.  Output the
	diagnostic code if flag_diag_codes.
	(cp_error, cp_compiler_error, cp_sprintf, cp_error_at): Take
	error_codes, not format strings.
	(cp_warning, cp_pedwarn, cp_warning_at, cp_pedwarn_at): Likewise.
	Call is_warning_enabled.
	* decl2.c (flag_diag_codes): New variable.
	(lang_decode_option): Handle -fdiag-codes and -Wnumber.
	* lang-options.h: Add -fdiag-codes, -fno-diag-codes, and
	-W-number-, and -Wno-number.
	* class.c: Update all calls to error-functions.
	* cvt.c: Likewise.
	* decl.c: Likewise.
	* decl2.c: Likewise.
	* except.c: Likewise.
	* expr.c: Likewise.
	* friend.c: Likewise.
	* lex.c: Likewise.
	* parse.y: Likewise.
	* pt.c: Likewise.
	* repo.c: Likewise.
	* rtti.c: Likewise.
	* search.c: Likewise.
	* semantics.c: Likewise.
	* sig.c: Likewise.
	* tree.c: Likewise.
	* typeck.c: Likewise.
	* typeck2.c: Likewise.
	* xref.c: Likewise.

From-SVN: r22304
parent e04a16fb
1998-09-06 Mark Mitchell <mark@markmitchell.com>
* cp-error.def: New file.
* Make-lang.in (cc1plus): Add dependency on it.
* Makefile.in (CXX_TREE_H): Likewise.
* cp-tree.h (error_code): New type.
Include cp-error.def to get error codes. Make it possible to
include cp-tree.h in errfn.c.
(enable_warning): New function.
(flag_diag_codes): New variable.
* errfn.c: Include cp-tree.h.
(cp_err_msg): New type. Include cp-error.def to define it.
(err_msgs): New variable.
(is_warning_enabled): New function.
(cp_thing): Take an error_code, not a format string. Output the
diagnostic code if flag_diag_codes.
(cp_error, cp_compiler_error, cp_sprintf, cp_error_at): Take
error_codes, not format strings.
(cp_warning, cp_pedwarn, cp_warning_at, cp_pedwarn_at): Likewise.
Call is_warning_enabled.
* decl2.c (flag_diag_codes): New variable.
(lang_decode_option): Handle -fdiag-codes and -Wnumber.
* lang-options.h: Add -fdiag-codes, -fno-diag-codes, and
-W-number-, and -Wno-number.
* class.c: Update all calls to error-functions.
* cvt.c: Likewise.
* decl.c: Likewise.
* decl2.c: Likewise.
* except.c: Likewise.
* expr.c: Likewise.
* friend.c: Likewise.
* lex.c: Likewise.
* parse.y: Likewise.
* pt.c: Likewise.
* repo.c: Likewise.
* rtti.c: Likewise.
* search.c: Likewise.
* semantics.c: Likewise.
* sig.c: Likewise.
* tree.c: Likewise.
* typeck.c: Likewise.
* typeck2.c: Likewise.
* xref.c: Likewise.
Sun Sep 6 00:00:51 1998 Jeffrey A Law (law@cygnus.com)
* Makefile.in (INCLUDES): Update after recent toplevel gcc
......
......@@ -125,7 +125,7 @@ CXX_SRCS = $(srcdir)/cp/call.c $(srcdir)/cp/decl2.c \
$(srcdir)/cp/repo.c $(srcdir)/cp/semantics.c
cc1plus$(exeext): $(P) $(CXX_SRCS) $(LIBDEPS) stamp-objlist c-common.o c-pragma.o \
$(srcdir)/cp/cp-tree.h $(srcdir)/cp/cp-tree.def
$(srcdir)/cp/cp-tree.h $(srcdir)/cp/cp-tree.def $(srcdir)/cp/cp-error.def
cd cp; $(MAKE) $(FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) ../cc1plus$(exeext)
#
# Build hooks:
......
......@@ -208,7 +208,7 @@ RTL_H = $(srcdir)/../rtl.h $(srcdir)/../rtl.def \
$(srcdir)/../machmode.h $(srcdir)/../machmode.def
TREE_H = $(srcdir)/../tree.h $(srcdir)/../real.h $(srcdir)/../tree.def \
$(srcdir)/../machmode.h $(srcdir)/../machmode.def
CXX_TREE_H = $(TREE_H) cp-tree.h cp-tree.def
CXX_TREE_H = $(TREE_H) cp-tree.h cp-tree.def cp-error.def
PARSE_H = $(srcdir)/parse.h
PARSE_C = $(srcdir)/parse.c
EXPR_H = $(srcdir)/../expr.h ../insn-codes.h
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -493,6 +493,16 @@ enum cplus_tree_code {
};
#undef DEFTREECODE
/* Error codes. */
typedef enum error_code {
#undef DEFERROR
#undef DEFERRORNUM
#define DEFERROR(code, string) code,
#define DEFERRORNUM(code, string, num) DEFERROR(code, string)
#include "cp-error.def"
ec_last_error_code
} error_code;
enum languages { lang_c, lang_cplusplus, lang_java };
/* Macros to make error reporting functions' lives easier. */
......@@ -2240,6 +2250,9 @@ extern int flag_new_abi;
extern int flag_honor_std;
/* Nonzero means show diagnostic codes when printing error messages. */
extern int flag_diag_codes;
/* Nonzero if we're done parsing and into end-of-file activities. */
extern int at_eof;
......@@ -2627,6 +2640,7 @@ extern tree handle_class_head PROTO((tree, tree, tree));
extern tree lookup_arg_dependent PROTO((tree, tree, tree));
/* in errfn.c */
#ifndef NO_CP_ERROR_FNS
extern void cp_error ();
extern void cp_error_at ();
extern void cp_warning ();
......@@ -2635,6 +2649,8 @@ extern void cp_pedwarn ();
extern void cp_pedwarn_at ();
extern void cp_compiler_error ();
extern void cp_sprintf ();
#endif
extern void cp_enable_warning PROTO((int, int));
/* in error.c */
extern void init_error PROTO((void));
......
......@@ -80,7 +80,7 @@ cp_convert_to_pointer (type, expr)
intype = complete_type (intype);
if (TYPE_SIZE (intype) == NULL_TREE)
{
cp_error ("can't convert from incomplete type `%T' to `%T'",
cp_error (ec_cant_convert_from_incomplete_type_to,
intype, type);
return error_mark_node;
}
......@@ -89,7 +89,7 @@ cp_convert_to_pointer (type, expr)
if (rval)
{
if (rval == error_mark_node)
cp_error ("conversion of `%E' from `%T' to `%T' is ambiguous",
cp_error (ec_conversion_of_from_to_is_ambiguous,
expr, intype, type);
return rval;
}
......@@ -134,7 +134,7 @@ cp_convert_to_pointer (type, expr)
{
if (TREE_CODE (TREE_TYPE (TREE_TYPE (expr))) == METHOD_TYPE)
if (pedantic || warn_pmf2ptr)
cp_pedwarn ("converting from `%T' to `%T'", TREE_TYPE (expr),
cp_pedwarn (ec_converting_from_to, TREE_TYPE (expr),
type);
return build1 (NOP_EXPR, type, expr);
}
......@@ -223,7 +223,7 @@ cp_convert_to_pointer (type, expr)
|| (TREE_CODE (type) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE))
{
cp_error ("cannot convert `%E' from type `%T' to type `%T'",
cp_error (ec_cannot_convert_from_type_to_type,
expr, intype, type);
return error_mark_node;
}
......@@ -262,7 +262,7 @@ cp_convert_to_pointer (type, expr)
return convert_to_pointer (type, expr);
}
cp_error ("cannot convert `%E' from type `%T' to type `%T'",
cp_error (ec_cannot_convert_from_type_to_type,
expr, intype, type);
return error_mark_node;
}
......@@ -311,7 +311,7 @@ convert_to_pointer_force (type, expr)
if (distance == -2)
{
ambig:
cp_error ("type `%T' is ambiguous baseclass of `%s'",
cp_error (ec_type_is_ambiguous_baseclass_of_s,
TREE_TYPE (type),
TYPE_NAME_STRING (TREE_TYPE (intype)));
return error_mark_node;
......@@ -454,19 +454,19 @@ convert_to_reference (reftype, expr, convtype, flags, decl)
{
if (decl)
/* Ensure semantics of [dcl.init.ref] */
cp_pedwarn ("initialization of non-const reference `%#T' from rvalue `%T'",
cp_pedwarn (ec_initialization_of_nonconst_reference_from_rvalue,
reftype, intype);
else
cp_pedwarn ("conversion to non-const `%T' from rvalue `%T'",
cp_pedwarn (ec_conversion_to_nonconst_from_rvalue,
reftype, intype);
}
else if (! (convtype & CONV_CONST))
{
if (! TYPE_READONLY (ttl) && TYPE_READONLY (ttr))
cp_pedwarn ("conversion from `%T' to `%T' discards const",
cp_pedwarn (ec_conversion_from_to_discards_const,
ttr, reftype);
else if (! TYPE_VOLATILE (ttl) && TYPE_VOLATILE (ttr))
cp_pedwarn ("conversion from `%T' to `%T' discards volatile",
cp_pedwarn (ec_conversion_from_to_discards_volatile,
ttr, reftype);
}
}
......@@ -485,7 +485,7 @@ convert_to_reference (reftype, expr, convtype, flags, decl)
meant. */
if (TREE_CODE (intype) == POINTER_TYPE
&& (comptypes (TREE_TYPE (intype), type, -1)))
cp_warning ("casting `%T' to `%T' does not dereference pointer",
cp_warning (ec_casting_to_does_not_dereference_pointer,
intype, reftype);
rval = build_unary_op (ADDR_EXPR, expr, 0);
......@@ -504,7 +504,7 @@ convert_to_reference (reftype, expr, convtype, flags, decl)
rval = build_up_reference (reftype, rval, flags, 1);
if (rval && ! TYPE_READONLY (TREE_TYPE (reftype)))
cp_pedwarn ("initializing non-const `%T' with `%T' will use a temporary",
cp_pedwarn (ec_initializing_nonconst_with_will_use_a_temporary,
reftype, intype);
}
......@@ -517,7 +517,7 @@ convert_to_reference (reftype, expr, convtype, flags, decl)
my_friendly_assert (TREE_CODE (intype) != OFFSET_TYPE, 189);
if (flags & LOOKUP_COMPLAIN)
cp_error ("cannot convert type `%T' to type `%T'", intype, reftype);
cp_error (ec_cannot_convert_type_to_type, intype, reftype);
if (flags & LOOKUP_SPECULATIVELY)
return NULL_TREE;
......@@ -592,11 +592,11 @@ convert_pointer_to_real (binfo, expr)
but if it is, give them an error message that they can read. */
if (distance < 0)
{
cp_error ("cannot convert a pointer of type `%T' to a pointer of type `%T'",
cp_error (ec_cannot_convert_a_pointer_of_type_to_a_pointer_of_type,
intype, type);
if (distance == -2)
cp_error ("because `%T' is an ambiguous base class", type);
cp_error (ec_because_is_an_ambiguous_base_class, type);
return error_mark_node;
}
......@@ -704,7 +704,7 @@ ocp_convert (type, expr, convtype, flags)
&& ((ARITHMETIC_TYPE_P (intype) && ! (convtype & CONV_STATIC))
|| (TREE_CODE (intype) == POINTER_TYPE)))
{
cp_pedwarn ("conversion from `%#T' to `%#T'", intype, type);
cp_pedwarn (ec_conversion_from_to, intype, type);
if (flag_pedantic_errors)
return error_mark_node;
......@@ -716,7 +716,7 @@ ocp_convert (type, expr, convtype, flags)
if (rval)
return rval;
if (flags & LOOKUP_COMPLAIN)
cp_error ("`%#T' used where a `%T' was expected", intype, type);
cp_error (ec_used_where_a_was_expected, intype, type);
if (flags & LOOKUP_SPECULATIVELY)
return NULL_TREE;
return error_mark_node;
......@@ -726,7 +726,7 @@ ocp_convert (type, expr, convtype, flags)
/* Common Ada/Pascal programmer's mistake. We always warn
about this since it is so bad. */
if (TREE_CODE (expr) == FUNCTION_DECL)
cp_warning ("the address of `%D', will always be `true'", expr);
cp_warning (ec_the_address_of_will_always_be_true, expr);
return truthvalue_conversion (e);
}
return fold (convert_to_integer (type, e));
......@@ -744,7 +744,7 @@ ocp_convert (type, expr, convtype, flags)
return rval;
else
if (flags & LOOKUP_COMPLAIN)
cp_error ("`%#T' used where a floating point value was expected",
cp_error (ec_used_where_a_floating_point_value_was_expected,
TREE_TYPE (e));
}
if (code == REAL_TYPE)
......@@ -818,7 +818,7 @@ ocp_convert (type, expr, convtype, flags)
return e;
if (flags & LOOKUP_COMPLAIN)
cp_error ("conversion from `%T' to non-scalar type `%T' requested",
cp_error (ec_conversion_from_to_nonscalar_type_requested,
TREE_TYPE (expr), type);
if (flags & LOOKUP_SPECULATIVELY)
return NULL_TREE;
......@@ -948,7 +948,7 @@ build_expr_type_conversion (desires, expr, complain)
if (expr == null_node
&& (desires & WANT_INT)
&& !(desires & WANT_NULL))
cp_warning ("converting NULL to non-pointer type");
cp_warning (ec_converting_null_to_nonpointer_type);
if (TREE_CODE (basetype) == OFFSET_TYPE)
expr = resolve_offset_ref (expr);
......@@ -1021,9 +1021,9 @@ build_expr_type_conversion (desires, expr, complain)
{
if (complain)
{
cp_error ("ambiguous default type conversion from `%T'",
cp_error (ec_ambiguous_default_type_conversion_from,
basetype);
cp_error (" candidate conversions include `%D' and `%D'",
cp_error (ec_candidate_conversions_include_and,
winner, cand);
}
return error_mark_node;
......
......@@ -23,6 +23,10 @@ Boston, MA 02111-1307, USA. */
#include "system.h"
#include "tree.h"
#include "toplev.h"
/* The declarations of cp_error and such here are incompatible with
those in cp-tree.h. */
#define NO_CP_ERROR_FNS
#include "cp-tree.h"
/* cp_printer is the type of a function which converts an argument into
a string for digestion by printf. The cp_printer function should deal
......@@ -37,10 +41,36 @@ extern cp_printer * cp_printers[256];
when we're computing the conversion costs for a method call. */
int cp_silent = 0;
/* The error messages themselves. */
typedef struct cp_err_msg {
/* The format of the error message. */
char* format;
/* The code which we should check when deciding whether or not to
issue this message. Used to indicate that some errors are "the
same" even though they have different formats. */
error_code equiv_code;
/* A count of how many more times this warning has been enabled than
disabled. (Ignored for errors.) */
int enabled;
} cp_err_msg;
static cp_err_msg err_msgs[] = {
#undef DEFERROR
#undef DEFERRORNUM
#define DEFERROR(code, format) DEFERRORNUM(code, format, code)
#define DEFERRORNUM(code, format, equiv_code) \
{ format, equiv_code, 1 },
#include "cp-error.def"
{ 0, 0, 0 }
};
typedef void errorfn (); /* deliberately vague */
extern char* cp_file_of PROTO((tree));
extern int cp_line_of PROTO((tree));
static int is_warning_enabled PROTO((error_code));
#define STRDUP(f) (ap = (char *) alloca (strlen (f) +1), strcpy (ap, (f)), ap)
......@@ -49,13 +79,13 @@ extern int cp_line_of PROTO((tree));
#ifdef __STDC__
static void
cp_thing (errorfn *errfn, int atarg1, const char *format, va_list ap)
cp_thing (errorfn *errfn, int atarg1, error_code ec, va_list ap)
#else
static void
cp_thing (errfn, atarg1, format, ap)
cp_thing (errfn, atarg1, ec, ap)
errorfn *errfn;
int atarg1;
const char *format;
error_code ec;
va_list ap;
#endif
{
......@@ -66,14 +96,29 @@ cp_thing (errfn, atarg1, format, ap)
long offset;
const char *f;
tree atarg = 0;
char* format;
my_friendly_assert ((int) ec >= 0 && (int) ec < ec_last_error_code,
0);
format = err_msgs[(int) ec].format;
my_friendly_assert (format != 0, 0);
len = strlen (format) + 1;
len = strlen (format) + 1 /* '\0' */ + 16 /* code number */;
if (len > buflen)
{
buflen = len;
buf = xrealloc (buf, buflen);
}
offset = 0;
if (flag_diag_codes)
{
sprintf (buf, "[%d] ", (int) ec);
for (offset = 0; buf[offset]; ++offset)
;
}
else
offset = 0;
for (f = format; *f; ++f)
{
......@@ -198,10 +243,10 @@ cp_thing (errfn, atarg1, format, ap)
}
#ifdef __STDC__
#define DECLARE(name) void name (const char *format, ...)
#define INIT va_start (ap, format)
#define DECLARE(name) void name (error_code ec, ...)
#define INIT va_start (ap, ec)
#else
#define DECLARE(name) void name (format, va_alist) char *format; va_dcl
#define DECLARE(name) void name (ec, va_alist) error_code ec; va_dcl
#define INIT va_start (ap)
#endif
......@@ -210,7 +255,7 @@ DECLARE (cp_error)
va_list ap;
INIT;
if (! cp_silent)
cp_thing ((errorfn *) error, 0, format, ap);
cp_thing ((errorfn *) error, 0, ec, ap);
va_end (ap);
}
......@@ -218,8 +263,8 @@ DECLARE (cp_warning)
{
va_list ap;
INIT;
if (! cp_silent)
cp_thing ((errorfn *) warning, 0, format, ap);
if (! cp_silent && is_warning_enabled (ec))
cp_thing ((errorfn *) warning, 0, ec, ap);
va_end (ap);
}
......@@ -227,8 +272,8 @@ DECLARE (cp_pedwarn)
{
va_list ap;
INIT;
if (! cp_silent)
cp_thing ((errorfn *) pedwarn, 0, format, ap);
if (! cp_silent && is_warning_enabled (ec))
cp_thing ((errorfn *) pedwarn, 0, ec, ap);
va_end (ap);
}
......@@ -238,7 +283,7 @@ DECLARE (cp_compiler_error)
va_list ap;
INIT;
if (! cp_silent)
cp_thing (compiler_error, 0, format, ap);
cp_thing (compiler_error, 0, ec, ap);
va_end (ap);
}
......@@ -246,7 +291,7 @@ DECLARE (cp_sprintf)
{
va_list ap;
INIT;
cp_thing ((errorfn *) sprintf, 0, format, ap);
cp_thing ((errorfn *) sprintf, 0, ec, ap);
va_end (ap);
}
......@@ -255,7 +300,7 @@ DECLARE (cp_error_at)
va_list ap;
INIT;
if (! cp_silent)
cp_thing ((errorfn *) error_with_file_and_line, 1, format, ap);
cp_thing ((errorfn *) error_with_file_and_line, 1, ec, ap);
va_end (ap);
}
......@@ -263,8 +308,8 @@ DECLARE (cp_warning_at)
{
va_list ap;
INIT;
if (! cp_silent)
cp_thing ((errorfn *) warning_with_file_and_line, 1, format, ap);
if (! cp_silent && is_warning_enabled (ec))
cp_thing ((errorfn *) warning_with_file_and_line, 1, ec, ap);
va_end (ap);
}
......@@ -272,7 +317,42 @@ DECLARE (cp_pedwarn_at)
{
va_list ap;
INIT;
if (! cp_silent)
cp_thing ((errorfn *) pedwarn_with_file_and_line, 1, format, ap);
if (! cp_silent && is_warning_enabled (ec))
cp_thing ((errorfn *) pedwarn_with_file_and_line, 1, ec, ap);
va_end (ap);
}
/* If ON is non-zero, enable the warning with the indicated NUMBER.
If OFF is zero, disable it. Actually, this function manipulates a
counter, so that enabling/disabling of warnings can nest
appropriately. */
void
cp_enable_warning (number, on)
int number;
int on;
{
if (number < 0 || number > (int) ec_last_error_code)
error ("invalid warning number %d", number);
else if (on)
err_msgs[number].enabled++;
else
{
if (!err_msgs[number].enabled)
warning ("warning %d not enabled", number);
else
err_msgs[number].enabled--;
}
}
/* Returns non-zero if EC corresponds to an enabled error message. */
int
is_warning_enabled (ec)
error_code ec;
{
my_friendly_assert ((int) ec >= 0 && (int) ec < ec_last_error_code,
0);
return err_msgs[(int) ec].enabled;
}
......@@ -633,7 +633,7 @@ process_start_catch_block_old (declspecs, declarator)
decl = grokdeclarator (declarator, declspecs, CATCHPARM, 1, NULL_TREE);
if (decl == NULL_TREE)
error ("invalid catch parameter");
cp_error (ec_invalid_catch_parameter);
}
if (decl)
......@@ -745,7 +745,7 @@ process_start_catch_block (declspecs, declarator)
decl = grokdeclarator (declarator, declspecs, CATCHPARM, 1, NULL_TREE);
if (decl == NULL_TREE)
error ("invalid catch parameter");
cp_error (ec_invalid_catch_parameter);
}
if (decl)
......@@ -1173,7 +1173,7 @@ expand_throw (exp)
exp = build_modify_expr (object, INIT_EXPR, exp);
if (exp == error_mark_node)
error (" in thrown expression");
cp_error (ec_in_thrown_expression);
expand_expr (exp, const0_rtx, VOIDmode, 0);
expand_eh_region_end (build_terminate_handler ());
......@@ -1277,7 +1277,7 @@ build_throw (e)
return build_min (THROW_EXPR, void_type_node, e);
if (e == null_node)
cp_warning ("throwing NULL, which has integral, not pointer type");
cp_warning (ec_throwing_which_has_integral_not_pointer_type);
e = build1 (THROW_EXPR, void_type_node, e);
TREE_SIDE_EFFECTS (e) = 1;
......
......@@ -331,10 +331,10 @@ do_case (start, end)
if (start != NULL_TREE && TREE_TYPE (start) != NULL_TREE
&& POINTER_TYPE_P (TREE_TYPE (start)))
error ("pointers are not permitted as case values");
cp_error (ec_pointers_are_not_permitted_as_case_values);
if (end && pedantic)
pedwarn ("ANSI C++ forbids range expressions in switch statement");
cp_pedwarn (ec_forbids_range_expressions_in_switch_statement);
if (processing_template_decl)
{
......@@ -366,43 +366,43 @@ do_case (start, end)
if (success == 1)
{
if (end)
error ("case label not within a switch statement");
cp_error (ec_case_label_not_within_a_switch_statement);
else if (start)
cp_error ("case label `%E' not within a switch statement", start);
cp_error (ec_case_label_not_within_a_switch_statement, start);
else
error ("default label not within a switch statement");
cp_error (ec_default_label_not_within_a_switch_statement);
}
else if (success == 2)
{
if (end)
{
error ("duplicate (or overlapping) case value");
cp_error_at ("this is the first entry overlapping that value",
cp_error (ec_duplicate_or_overlapping_case_value);
cp_error_at (ec_this_is_the_first_entry_overlapping_that_value,
duplicate);
}
else if (start)
{
cp_error ("duplicate case value `%E'", start);
cp_error_at ("previously used here", duplicate);
cp_error (ec_duplicate_case_value, start);
cp_error_at (ec_previously_used_here, duplicate);
}
else
{
error ("multiple default labels in one switch");
cp_error_at ("this is the first default label", duplicate);
cp_error (ec_multiple_default_labels_in_one_switch);
cp_error_at (ec_this_is_the_first_default_label, duplicate);
}
}
else if (success == 3)
warning ("case value out of range");
cp_warning (ec_case_value_out_of_range);
else if (success == 4)
warning ("empty range specified");
cp_warning (ec_empty_range_specified);
else if (success == 5)
{
if (end)
error ("case label within scope of cleanup or variable array");
cp_error (ec_case_label_within_scope_of_cleanup_or_variable_array);
else if (! start)
error ("`default' label within scope of cleanup or variable array");
cp_error (ec_default_label_within_scope_of_cleanup_or_variable_array);
else
cp_error ("case label `%E' within scope of cleanup or variable array", start);
cp_error (ec_case_label_within_scope_of_cleanup_or_variable_array, start);
}
}
if (start)
......
......@@ -155,9 +155,9 @@ add_friend (type, decl)
{
if (decl == TREE_VALUE (friends))
{
cp_warning ("`%D' is already a friend of class `%T'",
cp_warning (ec_is_already_a_friend_of_class,
decl, type);
cp_warning_at ("previous friend declaration of `%D'",
cp_warning_at (ec_previous_friend_declaration_of,
TREE_VALUE (friends));
return;
}
......@@ -205,11 +205,11 @@ add_friends (type, name, friend_type)
if (friends)
{
if (friend_type)
warning ("method `%s::%s' is already a friend of class",
cp_warning (ec_method_ss_is_already_a_friend_of_class,
TYPE_NAME_STRING (friend_type),
IDENTIFIER_POINTER (name));
else
warning ("function `%s' is already a friend of class `%s'",
cp_warning (ec_function_s_is_already_a_friend_of_class_s,
IDENTIFIER_POINTER (name),
IDENTIFIER_POINTER (DECL_NAME (typedecl)));
}
......@@ -252,12 +252,12 @@ make_friend_class (type, friend_type)
if (IS_SIGNATURE (type))
{
error ("`friend' declaration in signature definition");
cp_error (ec_friend_declaration_in_signature_definition);
return;
}
if (IS_SIGNATURE (friend_type))
{
error ("signature type `%s' declared `friend'",
cp_error (ec_signature_type_s_declared_friend,
IDENTIFIER_POINTER (TYPE_IDENTIFIER (friend_type)));
return;
}
......@@ -269,7 +269,7 @@ make_friend_class (type, friend_type)
Friend declarations shall not declare partial
specializations. */
cp_error ("partial specialization `%T' declared `friend'",
cp_error (ec_partial_specialization_declared_friend,
friend_type);
return;
}
......@@ -281,7 +281,7 @@ make_friend_class (type, friend_type)
is_template_friend = 1;
else if (comptypes (type, friend_type, 1))
{
pedwarn ("class `%s' is implicitly friends with itself",
cp_pedwarn (ec_class_s_is_implicitly_friends_with_itself,
TYPE_NAME_STRING (type));
return;
}
......@@ -301,7 +301,7 @@ make_friend_class (type, friend_type)
comptypes (TREE_VALUE (classes), friend_type, 1)))
classes = TREE_CHAIN (classes);
if (classes)
cp_warning ("`%T' is already a friend of `%T'",
cp_warning (ec_is_already_a_friend_of,
TREE_VALUE (classes), type);
else
{
......@@ -384,7 +384,7 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
TYPE_SIZE (ctype) || template_class_depth (ctype) > 0)
add_friend (current_class_type, decl);
else
cp_error ("member `%D' declared as friend before type `%T' defined",
cp_error (ec_member_declared_as_friend_before_type_defined,
decl, ctype);
}
}
......@@ -399,7 +399,7 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
if (fields)
add_friends (current_class_type, declarator, ctype);
else
cp_error ("method `%D' is not a member of class `%T'",
cp_error (ec_method_is_not_a_member_of_class,
declarator, ctype);
decl = void_type_node;
}
......@@ -452,14 +452,14 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
&& current_template_parms && uses_template_parms (decl))
{
static int explained;
cp_warning ("friend declaration `%#D'", decl);
warning (" declares a non-template function");
cp_warning (ec_friend_declaration, decl);
cp_warning (ec_declares_a_nontemplate_function);
if (! explained)
{
warning (" (if this is not what you intended, make sure");
warning (" the function template has already been declared,");
warning (" and add <> after the function name here)");
warning (" To disable warning use -Wno-non-template-friend");
cp_warning (ec_if_this_is_not_what_you_intended_make_sure);
cp_warning (ec_the_function_template_has_already_been_declared);
cp_warning (ec_and_add_after_the_function_name_here);
cp_warning (ec_o_disable_warning_use_nonontemplatefriend);
explained = 1;
}
}
......@@ -477,7 +477,7 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
tree decl = lookup_name_nonclass (declarator);
if (decl == NULL_TREE)
{
cp_warning ("implicitly declaring `%T' as struct", declarator);
cp_warning (ec_implicitly_declaring_as_struct, declarator);
decl = xref_tag (record_type_node, declarator, 1);
decl = TYPE_MAIN_DECL (decl);
}
......@@ -486,7 +486,7 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
but not if those functions are really class names. */
if (TREE_CODE (decl) == TREE_LIST && TREE_TYPE (TREE_PURPOSE (decl)))
{
cp_warning ("`friend %T' archaic, use `friend class %T' instead",
cp_warning (ec_friend_archaic_use_friend_class_instead,
declarator, declarator);
decl = TREE_TYPE (TREE_PURPOSE (decl));
}
......
......@@ -101,6 +101,8 @@ DEFINE_LANG_NAME ("C++")
{ "-fno-weak", "" },
{ "-fxref", "Emit cross referencing information" },
{ "-fno-xref", "" },
{ "-fdiag-codes", "Show code numbers when printing diagnostics" },
{ "-fno-diag-codes", "" },
{ "-Wreturn-type", "Warn about inconsistent return types" },
{ "-Wno-return-type", "" },
......@@ -126,4 +128,6 @@ DEFINE_LANG_NAME ("C++")
{ "-Wno-old-style-cast", "" },
{ "-Wnon-template-friend", "" },
{ "-Wno-non-template-friend", "Don't warn when non-templatized friend functions are declared within a template" },
{ "-Wnumber-" },
{ "-Wno-number-" },
......@@ -679,7 +679,7 @@ build_overload_value (type, value, in_template)
REAL_VALUE_TYPE val;
char *bufp = digit_buffer;
pedwarn ("ANSI C++ forbids floating-point template arguments");
cp_pedwarn (ec_forbids_floatingpoint_template_arguments);
my_friendly_assert (TREE_CODE (value) == REAL_CST, 244);
val = TREE_REAL_CST (value);
......@@ -1814,12 +1814,12 @@ hack_identifier (value, name)
#ifdef DEAD
if (DECL_CHAIN (fndecl) == NULL_TREE)
{
warning ("methods cannot be converted to function pointers");
cp_warning (ec_methods_cannot_be_converted_to_function_pointers);
return fndecl;
}
else
{
error ("ambiguous request for method pointer `%s'",
cp_error (ec_ambiguous_request_for_method_pointer_s,
IDENTIFIER_POINTER (name));
return error_mark_node;
}
......@@ -1840,13 +1840,13 @@ hack_identifier (value, name)
{
if (current_function_decl
&& DECL_STATIC_FUNCTION_P (current_function_decl))
cp_error ("invalid use of member `%D' in static member function",
cp_error (ec_invalid_use_of_member_in_static_member_function,
value);
else
/* We can get here when processing a bad default
argument, like:
struct S { int a; void f(int i = a); } */
cp_error ("invalid use of member `%D'", value);
cp_error (ec_invalid_use_of_member, value);
return error_mark_node;
}
......@@ -1887,12 +1887,12 @@ hack_identifier (value, name)
}
else if (TREE_CODE (value) == NAMESPACE_DECL)
{
cp_error ("use of namespace `%D' as expression", value);
cp_error (ec_use_of_namespace_as_expression, value);
return error_mark_node;
}
else if (DECL_CLASS_TEMPLATE_P (value))
{
cp_error ("use of class template `%T' as expression", value);
cp_error (ec_use_of_class_template_as_expression, value);
return error_mark_node;
}
else
......@@ -1904,10 +1904,10 @@ hack_identifier (value, name)
if (context != NULL_TREE && context != current_function_decl
&& ! TREE_STATIC (value))
{
cp_error ("use of %s from containing function",
cp_error (ec_use_of_s_from_containing_function,
(TREE_CODE (value) == VAR_DECL
? "`auto' variable" : "parameter"));
cp_error_at (" `%#D' declared here", value);
cp_error_at (ec_declared_here, value);
value = error_mark_node;
}
}
......@@ -1930,12 +1930,12 @@ hack_identifier (value, name)
if (access != access_public_node)
{
if (TREE_CODE (value) == VAR_DECL)
error ("static member `%s' is %s",
cp_error (ec_static_member_s_is_s,
IDENTIFIER_POINTER (name),
TREE_PRIVATE (value) ? "private"
: "from a private base class");
else
error ("enum `%s' is from private base class",
cp_error (ec_enum_s_is_from_private_base_class,
IDENTIFIER_POINTER (name));
return error_mark_node;
}
......@@ -1946,7 +1946,7 @@ hack_identifier (value, name)
{
if (type == 0)
{
error ("request for member `%s' is ambiguous in multiple inheritance lattice",
cp_error (ec_request_for_member_s_is_ambiguous_in_multiple_inheritance_lattice,
IDENTIFIER_POINTER (name));
return error_mark_node;
}
......@@ -1992,7 +1992,7 @@ make_thunk (function, delta)
thunk = IDENTIFIER_GLOBAL_VALUE (thunk_id);
if (thunk && TREE_CODE (thunk) != THUNK_DECL)
{
cp_error ("implementation-reserved name `%D' used", thunk_id);
cp_error (ec_implementationreserved_name_used, thunk_id);
thunk = NULL_TREE;
SET_IDENTIFIER_GLOBAL_VALUE (thunk_id, thunk);
}
......@@ -2061,7 +2061,7 @@ emit_thunk (thunk_fndecl)
tree a, t;
if (varargs_function_p (function))
cp_error ("generic thunk code fails for method `%#D' which uses `...'",
cp_error (ec_generic_thunk_code_fails_for_method_which_uses,
function);
/* Set up clone argument trees for the thunk. */
......@@ -2173,7 +2173,7 @@ do_build_copy_constructor (fndecl)
p = convert_from_reference (p);
if (p == error_mark_node)
cp_error ("in default copy constructor");
cp_error (ec_in_default_copy_constructor);
else
current_base_init_list = tree_cons (basetype,
p, current_base_init_list);
......@@ -2191,7 +2191,7 @@ do_build_copy_constructor (fndecl)
CONV_IMPLICIT|CONV_CONST, LOOKUP_COMPLAIN, NULL_TREE);
if (p == error_mark_node)
cp_error ("in default copy constructor");
cp_error (ec_in_default_copy_constructor);
else
{
p = convert_from_reference (p);
......@@ -2299,17 +2299,17 @@ do_build_assign_ref (fndecl)
if (TREE_READONLY (field))
{
if (DECL_NAME (field))
cp_error ("non-static const member `%#D', can't use default assignment operator", field);
cp_error (ec_nonstatic_const_member_cant_use_default_assignment_operator, field);
else
cp_error ("non-static const member in type `%T', can't use default assignment operator", current_class_type);
cp_error (ec_nonstatic_const_member_in_type_cant_use_default_assignment_operator, current_class_type);
continue;
}
else if (TREE_CODE (TREE_TYPE (field)) == REFERENCE_TYPE)
{
if (DECL_NAME (field))
cp_error ("non-static reference member `%#D', can't use default assignment operator", field);
cp_error (ec_nonstatic_reference_member_cant_use_default_assignment_operator, field);
else
cp_error ("non-static reference member in type `%T', can't use default assignment operator", current_class_type);
cp_error (ec_nonstatic_reference_member_in_type_cant_use_default_assignment_operator, current_class_type);
continue;
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -254,7 +254,7 @@ get_base_filename (filename)
if (p && ! compiling)
{
warning ("-frepo must be used with -c");
cp_warning (ec_frepo_must_be_used_with_c);
flag_use_repository = 0;
return NULL;
}
......@@ -344,7 +344,7 @@ init_repo (filename)
}
break;
default:
error ("mysterious repository information in %s", repo_name);
cp_error (ec_mysterious_repository_information_in_s, repo_name);
}
obstack_free (&temporary_obstack, buf);
}
......@@ -359,7 +359,7 @@ reopen_repo_file_for_write ()
if (repo_file == 0)
{
error ("can't create repository information file `%s'", repo_name);
cp_error (ec_cant_create_repository_information_file_s, repo_name);
flag_use_repository = 0;
}
}
......
......@@ -101,7 +101,7 @@ build_headof (exp)
if (TREE_CODE (type) != POINTER_TYPE)
{
error ("`headof' applied to non-pointer type");
cp_error (ec_headof_applied_to_nonpointer_type);
return error_mark_node;
}
type = TREE_TYPE (type);
......@@ -190,7 +190,7 @@ get_tinfo_fn_dynamic (exp)
if (type_unknown_p (exp))
{
error ("typeid of overloaded function");
cp_error (ec_typeid_of_overloaded_function);
return error_mark_node;
}
......@@ -211,7 +211,7 @@ get_tinfo_fn_dynamic (exp)
if (! flag_rtti)
{
warning ("taking dynamic typeid of object without -frtti");
cp_warning (ec_taking_dynamic_typeid_of_object_without_frtti);
push_obstacks (&permanent_obstack, &permanent_obstack);
init_rtti_processing ();
pop_obstacks ();
......@@ -401,7 +401,7 @@ get_typeid (type)
if (! flag_rtti)
{
warning ("requesting typeid of object without -frtti");
cp_warning (ec_requesting_typeid_of_object_without_frtti);
push_obstacks (&permanent_obstack, &permanent_obstack);
init_rtti_processing ();
pop_obstacks ();
......@@ -554,7 +554,7 @@ build_dynamic_cast_1 (type, expr)
if (TREE_CODE (expr) == VAR_DECL
&& TREE_CODE (TREE_TYPE (expr)) == RECORD_TYPE)
{
cp_warning ("dynamic_cast of `%#D' to `%#T' can never succeed",
cp_warning (ec_dynamic_cast_of_to_can_never_succeed,
expr, type);
return throw_bad_cast ();
}
......@@ -566,7 +566,7 @@ build_dynamic_cast_1 (type, expr)
if (TREE_CODE (op) == VAR_DECL
&& TREE_CODE (TREE_TYPE (op)) == RECORD_TYPE)
{
cp_warning ("dynamic_cast of `%#D' to `%#T' can never succeed",
cp_warning (ec_dynamic_cast_of_to_can_never_succeed,
expr, type);
retval = build_int_2 (0, 0);
TREE_TYPE (retval) = type;
......@@ -650,7 +650,7 @@ build_dynamic_cast_1 (type, expr)
}
fail:
cp_error ("cannot dynamic_cast `%E' (of type `%#T') to type `%#T'",
cp_error (ec_cannot_dynamic_cast_of_type_to_type,
expr, exprtype, type);
return error_mark_node;
}
......
......@@ -278,13 +278,13 @@ get_binfo (parent, binfo, protect)
if (dist == -3)
{
cp_error ("fields of `%T' are inaccessible in `%T' due to private inheritance",
cp_error (ec_fields_of_are_inaccessible_in_due_to_private_inheritance,
parent, type);
return error_mark_node;
}
else if (dist == -2 && protect)
{
cp_error ("type `%T' is ambiguous base class for type `%T'", parent,
cp_error (ec_type_is_ambiguous_base_class_for_type, parent,
type);
return error_mark_node;
}
......@@ -884,7 +884,7 @@ lookup_field (xbasetype, name, protect, want_type)
we know that binfo of a virtual base class will always == itself when
found along any line. (mrs) */
char *errstr = 0;
error_code ec = ec_last_error_code;
#if 0
/* We cannot search for constructor/destructor names like this. */
......@@ -952,20 +952,10 @@ lookup_field (xbasetype, name, protect, want_type)
{
if (TREE_PRIVATE (rval) | TREE_PROTECTED (rval))
this_v = compute_access (basetype_path, rval);
if (TREE_CODE (rval) == CONST_DECL)
{
if (this_v == access_private_node)
errstr = "enum `%D' is a private value of class `%T'";
else if (this_v == access_protected_node)
errstr = "enum `%D' is a protected value of class `%T'";
}
else
{
if (this_v == access_private_node)
errstr = "member `%D' is a private member of class `%T'";
else if (this_v == access_protected_node)
errstr = "member `%D' is a protected member of class `%T'";
}
if (this_v == access_private_node)
ec = ec_private_in_class;
else if (this_v == access_protected_node)
ec = ec_protected_in_class;
}
rval_binfo = basetype_path;
......@@ -1074,7 +1064,7 @@ lookup_field (xbasetype, name, protect, want_type)
else
{
/* This is ambiguous. */
errstr = "request for member `%D' is ambiguous";
ec = ec_ambiguous_member;
protect += 2;
break;
}
......@@ -1109,10 +1099,10 @@ lookup_field (xbasetype, name, protect, want_type)
}
if (rval == NULL_TREE)
errstr = 0;
ec = ec_last_error_code;
/* If this FIELD_DECL defines its own access level, deal with that. */
if (rval && errstr == 0
if (rval && ec == ec_last_error_code
&& (protect & 1)
&& DECL_LANG_SPECIFIC (rval)
&& DECL_ACCESS (rval))
......@@ -1128,7 +1118,7 @@ lookup_field (xbasetype, name, protect, want_type)
new_v = compute_access (TREE_VALUE (TREE_CHAIN (*tp)), rval);
if (this_v != access_default_node && new_v != this_v)
{
errstr = "conflicting access to member `%D'";
ec = ec_conflicting_access;
this_v = access_default_node;
}
own_access = new_v;
......@@ -1147,20 +1137,18 @@ lookup_field (xbasetype, name, protect, want_type)
}
search_stack = pop_search_level (search_stack);
if (errstr == 0)
if (ec == ec_last_error_code)
{
if (own_access == access_private_node)
errstr = "member `%D' declared private";
ec = ec_member_private;
else if (own_access == access_protected_node)
errstr = "member `%D' declared protected";
ec = ec_member_protected;
else if (this_v == access_private_node)
errstr = TREE_PRIVATE (rval)
? "member `%D' is private"
: "member `%D' is from private base class";
ec = TREE_PRIVATE (rval)
? ec_member_private : ec_member_in_private_base;
else if (this_v == access_protected_node)
errstr = TREE_PROTECTED (rval)
? "member `%D' is protected"
: "member `%D' is from protected base class";
ec = TREE_PROTECTED (rval)
? ec_member_protected : ec_member_in_protected_base;
}
out:
......@@ -1172,9 +1160,9 @@ lookup_field (xbasetype, name, protect, want_type)
protect = 0;
}
if (errstr && protect)
if (ec != ec_last_error_code && protect)
{
cp_error (errstr, name, type);
cp_error (ec, name, type);
rval = error_mark_node;
}
......@@ -1243,7 +1231,7 @@ lookup_nested_field (name, complain)
enums in nested classes) when we do need to call
this fn at parse time. So, in those cases, we pass
complain as a 0 and just return a NULL_TREE. */
cp_error ("assignment to non-static member `%D' of enclosing class `%T'",
cp_error (ec_assignment_to_nonstatic_member_of_enclosing_class,
id, DECL_CONTEXT (t));
/* Mark this for do_identifier(). It would otherwise
claim that the variable was undeclared. */
......@@ -1367,7 +1355,7 @@ lookup_fnfields (basetype_path, name, complain)
/* For now, don't try this. */
int protect = complain;
char *errstr = 0;
error_code ec = ec_last_error_code;
if (complain == -1)
{
......@@ -1524,7 +1512,7 @@ lookup_fnfields (basetype_path, name, complain)
else
{
/* This is ambiguous. */
errstr = "request for method `%D' is ambiguous";
ec = ec_ambiguous_member;
rvals = error_mark_node;
break;
}
......@@ -1542,9 +1530,9 @@ lookup_fnfields (basetype_path, name, complain)
}
search_stack = pop_search_level (search_stack);
if (errstr && protect)
if (ec != ec_last_error_code && protect)
{
cp_error (errstr, name);
cp_error (ec, name);
rvals = error_mark_node;
}
......@@ -1854,21 +1842,21 @@ get_matching_virtual (binfo, fndecl, dtorp)
if (pedantic && i == -1)
{
cp_pedwarn_at ("invalid covariant return type for `%#D' (must be pointer or reference to class)", fndecl);
cp_pedwarn_at (" overriding `%#D'", tmp);
cp_pedwarn_at (ec_invalid_covariant_return_type_for_must_be_pointer_or_reference_to_class, fndecl);
cp_pedwarn_at (ec_overriding, tmp);
}
}
else if (IS_AGGR_TYPE_2 (brettype, drettype)
&& comptypes (brettype, drettype, 0))
{
error ("invalid covariant return type (must use pointer or reference)");
cp_error_at (" overriding `%#D'", tmp);
cp_error_at (" with `%#D'", fndecl);
cp_error (ec_invalid_covariant_return_type_must_use_pointer_or_reference);
cp_error_at (ec_overriding, tmp);
cp_error_at (ec_with, fndecl);
}
else if (IDENTIFIER_ERROR_LOCUS (name) == NULL_TREE)
{
cp_error_at ("conflicting return type specified for virtual function `%#D'", fndecl);
cp_error_at (" overriding definition as `%#D'", tmp);
cp_error_at (ec_conflicting_return_type_specified_for_virtual_function, fndecl);
cp_error_at (ec_overriding_definition_as, tmp);
SET_IDENTIFIER_ERROR_LOCUS (name, basetype);
}
break;
......@@ -2446,7 +2434,7 @@ virtual_context (fndecl, t, vbase)
}
}
/* This shouldn't happen, I don't want errors! */
warning ("recoverable compiler error, fixups for virtual function");
cp_warning (ec_recoverable_compiler_error_fixups_for_virtual_function);
return vbase;
}
while (path)
......@@ -2709,7 +2697,7 @@ expand_indirect_vtbls_init (binfo, true_exp, decl_ptr)
tree in_charge_node = lookup_name (in_charge_identifier, 0);
if (! in_charge_node)
{
warning ("recoverable internal compiler error, nobody's in charge!");
cp_warning (ec_recoverable_internal_compiler_error_nobodys_in_charge);
in_charge_node = integer_zero_node;
}
in_charge_node = build_binary_op (EQ_EXPR, in_charge_node, integer_zero_node, 1);
......@@ -2837,9 +2825,9 @@ envelope_add_decl (type, decl, values)
|| ! TREE_PRIVATE (value)))
/* Should figure out access control more accurately. */
{
cp_warning_at ("member `%#D' is shadowed", value);
cp_warning_at ("by member function `%#D'", decl);
warning ("in this context");
cp_warning_at (ec_member_is_shadowed, value);
cp_warning_at (ec_by_member_function, decl);
cp_warning (ec_in_this_context);
}
context = DECL_REAL_CONTEXT (value);
......
......@@ -453,7 +453,7 @@ finish_break_stmt ()
if (processing_template_decl)
add_tree (build_min_nt (BREAK_STMT));
else if ( ! expand_exit_something ())
cp_error ("break statement not within loop or switch");
cp_error (ec_break_statement_not_within_loop_or_switch);
}
/* Finish a continue-statement. */
......@@ -465,7 +465,7 @@ finish_continue_stmt ()
if (processing_template_decl)
add_tree (build_min_nt (CONTINUE_STMT));
else if (! expand_continue_loop (0))
cp_error ("continue statement not within a loop");
cp_error (ec_continue_statement_not_within_a_loop);
}
/* Begin a switch-statement. */
......@@ -735,7 +735,7 @@ finish_asm_stmt (cv_qualifier, string, output_operands,
{
if (cv_qualifier != NULL_TREE
&& cv_qualifier != ridpointers[(int) RID_VOLATILE])
cp_warning ("%s qualifier ignored on asm",
cp_warning (ec_qualifier_ignored_on_asm,
IDENTIFIER_POINTER (cv_qualifier));
c_expand_asm_operands (string, output_operands,
......@@ -748,7 +748,7 @@ finish_asm_stmt (cv_qualifier, string, output_operands,
else
{
if (cv_qualifier != NULL_TREE)
cp_warning ("%s qualifier ignored on asm",
cp_warning (ec_qualifier_ignored_on_asm,
IDENTIFIER_POINTER (cv_qualifier));
expand_asm (string);
}
......@@ -895,15 +895,15 @@ finish_this_expr ()
else if (current_function_decl
&& DECL_STATIC_FUNCTION_P (current_function_decl))
{
error ("`this' is unavailable for static member functions");
cp_error (ec_this_is_unavailable_for_static_member_functions);
result = error_mark_node;
}
else
{
if (current_function_decl)
error ("invalid use of `this' in non-member function");
cp_error (ec_invalid_use_of_this_in_nonmember_function);
else
error ("invalid use of `this' at top level");
cp_error (ec_invalid_use_of_this_at_top_level);
result = error_mark_node;
}
......@@ -941,7 +941,7 @@ finish_object_call_expr (fn, object, args)
fn = DECL_NAME (fn);
else
{
cp_error ("calling type `%T' like a method", fn);
cp_error (ec_calling_type_like_a_method, fn);
return error_mark_node;
}
}
......@@ -961,7 +961,7 @@ finish_qualified_object_call_expr (fn, object, args)
{
if (IS_SIGNATURE (TREE_OPERAND (fn, 0)))
{
warning ("signature name in scope resolution ignored");
cp_warning (ec_signature_name_in_scope_resolution_ignored);
return finish_object_call_expr (TREE_OPERAND (fn, 1), object, args);
}
else
......@@ -980,13 +980,13 @@ finish_pseudo_destructor_call_expr (object, scope, destructor)
tree destructor;
{
if (scope && scope != destructor)
cp_error ("destructor specifier `%T::~%T()' must have matching names",
cp_error (ec_destructor_specifier_must_have_matching_names,
scope, destructor);
if ((scope == NULL_TREE || IDENTIFIER_GLOBAL_VALUE (destructor))
&& (TREE_CODE (TREE_TYPE (object)) !=
TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (destructor)))))
cp_error ("`%E' is not of type `%T'", object, destructor);
cp_error (ec_is_not_of_type, object, destructor);
return cp_convert (void_type_node, object);
}
......@@ -1159,7 +1159,7 @@ finish_template_type_parm (aggr, identifier)
sorry ("signature as template type parameter");
else if (aggr != class_type_node)
{
pedwarn ("template type parameters must use the keyword `class' or `typename'");
cp_pedwarn (ec_template_type_parameters_must_use_the_keyword_class_or_typename);
aggr = class_type_node;
}
......@@ -1459,19 +1459,19 @@ finish_base_specifier (access_specifier, base_class,
if (base_class == NULL_TREE)
{
error ("invalid base class");
cp_error (ec_invalid_base_class);
type = error_mark_node;
}
else
type = TREE_TYPE (base_class);
if (current_aggr_is_signature && access_specifier)
error ("access and source specifiers not allowed in signature");
cp_error (ec_access_and_source_specifiers_not_allowed_in_signature);
if (! is_aggr_type (type, 1))
result = NULL_TREE;
else if (current_aggr_is_signature
&& (! type) && (! IS_SIGNATURE (type)))
{
error ("class name not allowed as base signature");
cp_error (ec_class_name_not_allowed_as_base_signature);
result = NULL_TREE;
}
else if (current_aggr_is_signature)
......@@ -1482,7 +1482,7 @@ finish_base_specifier (access_specifier, base_class,
}
else if (type && IS_SIGNATURE (type))
{
error ("signature name not allowed as base class");
cp_error (ec_signature_name_not_allowed_as_base_class);
result = NULL_TREE;
}
else
......
......@@ -492,7 +492,7 @@ build_signature_table_constructor (sig_ty, rhs)
if (oty_type == NULL_TREE || oty_type == error_mark_node)
{
cp_error ("class `%T' does not contain type `%T'",
cp_error (ec_class_does_not_contain_type,
rhstype, oty_type);
undo_casts (sig_ty);
return error_mark_node;
......@@ -518,7 +518,7 @@ build_signature_table_constructor (sig_ty, rhs)
{
if (! IS_DEFAULT_IMPLEMENTATION (sig_method))
{
cp_error ("class `%T' does not contain method `%D'",
cp_error (ec_class_does_not_contain_method,
rhstype, sig_mname);
undo_casts (sig_ty);
return error_mark_node;
......@@ -549,7 +549,7 @@ build_signature_table_constructor (sig_ty, rhs)
|| (compute_access (basetypes, rhs_method)
!= access_public_node))
{
error ("class `%s' does not contain a method conforming to `%s'",
cp_error (ec_class_s_does_not_contain_a_method_conforming_to_s,
TYPE_NAME_STRING (rhstype),
fndecl_as_string (sig_method, 1));
undo_casts (sig_ty);
......@@ -735,7 +735,7 @@ build_sigtable (sig_type, rhs_type, init_from)
if (SIGNATURE_HAS_OPAQUE_TYPEDECLS (sig_type)
&& SIGTABLE_HAS_BEEN_GENERATED (sig_type))
{
error ("signature with opaque type implemented by multiple classes");
cp_error (ec_signature_with_opaque_type_implemented_by_multiple_classes);
return error_mark_node;
}
SIGTABLE_HAS_BEEN_GENERATED (sig_type) = 1;
......@@ -806,13 +806,13 @@ build_signature_pointer_constructor (lhs, rhs)
&& (IS_SIGNATURE_POINTER (rhstype)
|| IS_SIGNATURE_REFERENCE (rhstype)))))
{
error ("invalid assignment to signature pointer or reference");
cp_error (ec_invalid_assignment_to_signature_pointer_or_reference);
return error_mark_node;
}
if (TYPE_SIZE (sig_ty) == NULL_TREE)
{
cp_error ("undefined signature `%T' used in signature %s declaration",
cp_error (ec_undefined_signature_used_in_signature_s_declaration,
sig_ty,
IS_SIGNATURE_POINTER (lhstype) ? "pointer" : "reference");
return error_mark_node;
......@@ -1018,7 +1018,7 @@ build_signature_method_call (function, parms)
|| (IS_DEFAULT_IMPLEMENTATION (function)
&& (!deflt_call || deflt_call == error_mark_node)))
{
compiler_error ("cannot build call of signature member function `%s'",
cp_compiler_error (ec_cannot_build_call_of_signature_member_function_s,
fndecl_as_string (function, 1));
return error_mark_node;
}
......
......@@ -221,7 +221,7 @@ lvalue_or_else (ref, string)
{
int win = lvalue_p (ref);
if (! win)
error ("non-lvalue in %s", string);
cp_error (ec_nonlvalue_in_s, string);
return win;
}
......@@ -755,7 +755,7 @@ layout_basetypes (rec, max)
my_friendly_assert (TREE_TYPE (field) == basetype, 23897);
if (get_base_distance (basetype, rec, 0, (tree*)0) == -2)
cp_warning ("direct base `%T' inaccessible in `%T' due to ambiguity",
cp_warning (ec_direct_base_inaccessible_in_due_to_ambiguity,
basetype, rec);
BINFO_OFFSET (base_binfo)
......@@ -776,7 +776,7 @@ layout_basetypes (rec, max)
{
tree basetype = BINFO_TYPE (vbase_types);
if (get_base_distance (basetype, rec, 0, (tree*)0) == -2)
cp_warning ("virtual base `%T' inaccessible in `%T' due to ambiguity",
cp_warning (ec_virtual_base_inaccessible_in_due_to_ambiguity,
basetype, rec);
}
}
......@@ -1240,7 +1240,7 @@ binfo_value (elem, type)
tree type;
{
if (get_base_distance (elem, type, 0, (tree *)0) == -2)
compiler_error ("base class `%s' ambiguous in binfo_value",
cp_compiler_error (ec_base_class_s_ambiguous_in_binfo_value,
TYPE_NAME_STRING (elem));
if (elem == type)
return TYPE_BINFO (type);
......
......@@ -832,7 +832,7 @@ open_xref_file(file)
if (xref_file == NULL)
{
error("Can't create cross-reference file `%s'", xref_name);
cp_error (ec_ant_create_crossreference_file_s, xref_name);
doing_xref = 0;
}
}
......@@ -108,7 +108,7 @@ in the following sections.
-fname-mangling-version-@var{n} -fno-default-inline
-fno-gnu-keywords -fnonnull-objects -fguiding-decls
-foperator-names -fno-optional-diags -fstrict-prototype -fthis-is-variable
-ftemplate-depth-@var{n} -nostdinc++ -traditional +e@var{n}
-ftemplate-depth-@var{n} -fdiag-codes -nostdinc++ -traditional +e@var{n}
@end smallexample
@item Warning Options
......@@ -129,7 +129,7 @@ in the following sections.
-Wreturn-type -Wshadow -Wsign-compare -Wstrict-prototypes
-Wswitch -Wsynth -Wtemplate-debugging -Wtraditional
-Wtrigraphs -Wundef -Wuninitialized -Wunused -Wwrite-strings
-Wunknown-pragmas
-Wunknown-pragmas -Wnumber-@var{n}
@end smallexample
@item Debugging Options
......@@ -1165,6 +1165,19 @@ A limit on the template instantiation depth is needed to detect
endless recursions during template class instantiation. ANSI/ISO C++
conforming programs must not rely on a maximum depth greater than 17.
@item -fdiag-codes
When printing a diagnostic, also print the corresponding diagnostic
code. The code is printed in square brackets, before the message
itself. For example, you might see something like:
@smallexample
test.C:3: warning: [62] all member functions in class `C' are private
@end smallexample
which indicates that this is warning number 62. Some diagnostics do not
(yet) have corresponding code numbers. This option is useful in
conjuction with @samp{-Wnumber-@var{n}}.
@item -nostdinc++
Do not search for header files in the standard directories specific to
C++, but do still search the other standard directories. (This option
......@@ -1189,6 +1202,7 @@ Do not assume @samp{inline} for functions defined inside a class scope.
@item -Wold-style-cast
@itemx -Woverloaded-virtual
@itemx -Wtemplate-debugging
@itemx -Wnumber-@var{n}
Warnings that apply only to C++ programs. @xref{Warning
Options,,Options to Request or Suppress Warnings}.
......@@ -1697,6 +1711,11 @@ conformant compiler code but disables the helpful warning.
Warn if a function can not be inlined, and either it was declared as inline,
or else the @samp{-finline-functions} option was given.
@item -Wnumber-@var{n} (C++ only)
Enable warning number @var{n}. (Or, more often, with
@samp{-Wno-number-@var{n}}, disable that warning.) To obtain the
appropriate numbers, use @samp{-fdiag-codes}.
@item -Wold-style-cast
Warn if an old-style (C-style) cast is used within a program.
......
// Build don't link:
// Special g++ Options: -Wno-number-62
class C {
C();
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment