diff options
author | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-23 21:27:25 +0000 |
---|---|---|
committer | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-23 21:27:25 +0000 |
commit | b9dd3954e0bd53cf675974ad9e18c6a43f102730 (patch) | |
tree | 7c8b072e4a0dd5d53355cf9e4fe5a56ff9c7a5c6 /gcc/cp/init.c | |
parent | f89bc994383c400e63a39f505703ff59b0127602 (diff) | |
download | gcc-b9dd3954e0bd53cf675974ad9e18c6a43f102730.tar.gz |
gcc/cp:
* decl.c (grokfndecl): If ::main is found not to return int,
correct it after issuing a diagnostic.
(grokdeclarator): If the incoming type was error_mark_node, do
not complain about declaring something with no type.
(start_function): Change check for ::main not returning int to
an assertion, as grokfndecl now catches this when the user did it.
* init.c (perform_member_init, sort_mem_initializers)
(emit_mem_initializers): Make most diagnostics be issued on
the line of current_function_decl, not whatever the current
input line is.
* parser.c (cp_lexer_peek_token_emit_debug_info): Surround
definition and declaration with #ifdef ENABLE_CHECKING.
Avoid unnecessary use of fprintf.
(cp_lexer_print_token, cp_lexer_debug_stream): Adjust stub
definitions to avoid warnings.
(cp_lexer_new_main): Add assertion that first token is not a
padding token.
(cp_lexer_new_from_token_array): Fold into ...
(cp_lexer_new_from_tokens): ... here. Add assertion that
first token is not a padding token.
(cp_lexer_set_source_position_from_token): Move nearer to callers.
Remove unused lexer argument.
(cp_lexer_peek_token): Just print debugging report (if enabled)
and return lexer->next_token.
(cp_lexer_skip_purged_tokens): Delete.
(cp_lexer_next_token_is, cp_lexer_next_token_is_not): Make
inline, simplify bodies.
(cp_lexer_peek_nth_token): Add debugging report a la
cp_lexer_peek_token.
(cp_lexer_consume_token): Correct commentary. Advance over
purged tokens here. Set current source position here, from
token to be returned. Avoid unnecessary use of fprintf.
(cp_lexer_purge_token): Advance next_token pointer over this and
subsequent purged tokens.
(cp_parser_error): Adjust source position to that of the
peeked token.
(cp_parser_push_lexer_for_tokens, cp_parser_pop_lexer): New functions.
(cp_parser_string_literal): Remove some excessive cleverness.
(cp_parser_enum_specifier): Call start_enum before consuming
the opening brace.
(cp_parser_member_declaration): Make the "extra semicolon"
diagnostic consistently-worded with the other place this is
diagnosed. Explicitly set the diagnostic location to the
location of the offending semicolon.
(cp_parser_enclosed_template_argument_list): Use %</%> quoting
in diagnostics. Do not use cp_parser_require. Set location
of diagnostics about improper use of '>>' to location of
offending token.
(cp_parser_late_parsing_for_member):
Use cp_parser_push_lexer_for_tokens and cp_parser_pop_lexer.
(cp_parser_late_parsing_default_args): Likewise. Manually
move some logic outside the loop.
gcc/testsuite:
* g++.dg/ext/complit1.C
* g++.dg/other/error2.C
* g++.dg/other/nontype-1.C
* g++.dg/parse/crash11.C
* g++.dg/parse/crash12.C
* g++.dg/parse/error15.C
* g++.dg/parse/error4.C
* g++.dg/parse/tmpl-outside1.C
* g++.dg/parse/too-many-tmpl-args1.C
* g++.dg/template/dependent-expr3.C
* g++.dg/template/error10.C
* g++.dg/template/instantiate1.C
* g++.dg/template/vtable2.C
* g++.dg/warn/Wshadow-1.C
* g++.dg/warn/weak1.C
* g++.old-deja/g++.brendan/crash16.C
* g++.old-deja/g++.brendan/crash18.C
* g++.old-deja/g++.brendan/crash48.C
* g++.old-deja/g++.brendan/crash49.C
* g++.old-deja/g++.brendan/crash55.C
* g++.old-deja/g++.brendan/crash56.C
* g++.old-deja/g++.brendan/crash8.C
* g++.old-deja/g++.brendan/enum11.C
* g++.old-deja/g++.brendan/enum8.C
* g++.old-deja/g++.brendan/enum9.C
* g++.old-deja/g++.brendan/friend3.C
* g++.old-deja/g++.brendan/misc14.C
* g++.old-deja/g++.bugs/900402_02.C
* g++.old-deja/g++.bugs/900404_03.C
* g++.old-deja/g++.bugs/900404_04.C
* g++.old-deja/g++.bugs/900428_03.C
* g++.old-deja/g++.jason/crash4.C
* g++.old-deja/g++.jason/overload21.C
* g++.old-deja/g++.jason/redecl1.C
* g++.old-deja/g++.jason/report.C
* g++.old-deja/g++.jason/rfg10.C
* g++.old-deja/g++.jason/template30.C
* g++.old-deja/g++.law/arm12.C
* g++.old-deja/g++.law/ctors5.C
* g++.old-deja/g++.law/cvt20.C
* g++.old-deja/g++.law/init10.C
* g++.old-deja/g++.law/init8.C
* g++.old-deja/g++.law/visibility17.C
* g++.old-deja/g++.law/visibility7.C
* g++.old-deja/g++.mike/net8.C
* g++.old-deja/g++.mike/p646.C
* g++.old-deja/g++.mike/p700.C
* g++.old-deja/g++.mike/p701.C
* g++.old-deja/g++.mike/p811.C
* g++.old-deja/g++.ns/template13.C
* g++.old-deja/g++.other/array3.C
* g++.old-deja/g++.other/crash25.C
* g++.old-deja/g++.other/dtor3.C
* g++.old-deja/g++.other/dtor4.C
* g++.old-deja/g++.other/main1.C
* g++.old-deja/g++.other/warn7.C
* g++.old-deja/g++.pt/crash11.C
* g++.old-deja/g++.pt/crash36.C
* g++.old-deja/g++.pt/spec22.C
* g++.old-deja/g++.pt/spec9.C
* g++.old-deja/g++.pt/ttp52.C
* g++.old-deja/g++.robertl/eb103.C
* g++.old-deja/g++.robertl/eb121.C
* g++.old-deja/g++.robertl/eb22.C
* g++.old-deja/g++.robertl/eb8.C:
Update locations and/or regexps of dg-error markers.
Remove markers for some bogus messages that are no longer issued.
libstdc++-v3:
* testsuite/20_util/memory/auto_ptr/assign_neg.cc
* testsuite/23_containers/map/operators/1_neg.cc
* testsuite/23_containers/set/operators/1_neg.cc:
Update locations and/or regexps of dg-error markers.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@87985 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 58dac9685a7..b820e9ed837 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -315,9 +315,8 @@ perform_member_init (tree member, tree init) /* Effective C++ rule 12 requires that all data members be initialized. */ if (warn_ecpp && !explicit && TREE_CODE (type) != ARRAY_TYPE) - warning ("`%D' should be initialized in the member initialization " - "list", - member); + warning ("%J%qD should be initialized in the member initialization " + "list", current_function_decl, member); if (init == void_type_node) init = NULL_TREE; @@ -363,16 +362,17 @@ perform_member_init (tree member, tree init) { init = build_default_init (type, /*nelts=*/NULL_TREE); if (TREE_CODE (type) == REFERENCE_TYPE) - warning - ("default-initialization of `%#D', which has reference type", - member); + warning ("%Jdefault-initialization of %q#D, " + "which has reference type", + current_function_decl, member); } /* member traversal: note it leaves init NULL */ else if (TREE_CODE (type) == REFERENCE_TYPE) - pedwarn ("uninitialized reference member `%D'", member); + pedwarn ("%Juninitialized reference member %qD", + current_function_decl, member); else if (CP_TYPE_CONST_P (type)) - pedwarn ("uninitialized member `%D' with `const' type `%T'", - member, type); + pedwarn ("%Juninitialized member %qD with %<const%> type %qT", + current_function_decl, member, type); } else if (TREE_CODE (init) == TREE_LIST) /* There was an explicit member initialization. Do some work @@ -509,7 +509,8 @@ sort_mem_initializers (tree t, tree mem_inits) break; /* Issue a warning if the explicit initializer order does not - match that which will actually occur. */ + match that which will actually occur. + ??? Are all these on the correct lines? */ if (warn_reorder && !subobject_init) { if (TREE_CODE (TREE_PURPOSE (next_subobject)) == FIELD_DECL) @@ -522,7 +523,7 @@ sort_mem_initializers (tree t, tree mem_inits) cp_warning_at (" `%#D'", subobject); else warning (" base `%T'", subobject); - warning (" when initialized here"); + warning ("%J when initialized here", current_function_decl); } /* Look again, from the beginning of the list. */ @@ -538,10 +539,11 @@ sort_mem_initializers (tree t, tree mem_inits) if (TREE_VALUE (subobject_init)) { if (TREE_CODE (subobject) == FIELD_DECL) - error ("multiple initializations given for `%D'", subobject); + error ("%Jmultiple initializations given for %qD", + current_function_decl, subobject); else - error ("multiple initializations given for base `%T'", - subobject); + error ("%Jmultiple initializations given for base %qT", + current_function_decl, subobject); } /* Record the initialization. */ @@ -607,8 +609,8 @@ sort_mem_initializers (tree t, tree mem_inits) if (same_type_p (last_field_type, field_type)) { if (TREE_CODE (field_type) == UNION_TYPE) - error ("initializations for multiple members of `%T'", - last_field_type); + error ("%Jinitializations for multiple members of %qT", + current_function_decl, last_field_type); done = 1; break; } @@ -664,9 +666,9 @@ emit_mem_initializers (tree mem_inits) if (extra_warnings && !arguments && DECL_COPY_CONSTRUCTOR_P (current_function_decl) && TYPE_NEEDS_CONSTRUCTING (BINFO_TYPE (subobject))) - warning ("base class `%#T' should be explicitly initialized in the " + warning ("%Jbase class `%#T' should be explicitly initialized in the " "copy constructor", - BINFO_TYPE (subobject)); + current_function_decl, BINFO_TYPE (subobject)); /* If an explicit -- but empty -- initializer list was present, treat it just like default initialization at this point. */ |