From 9bc3739ff5286405148970f7ec7db806dc17440d Mon Sep 17 00:00:00 2001 From: rth Date: Sun, 21 Sep 2003 05:07:20 +0000 Subject: * c-format.c (gcc_diag_char_table): Add %J. (gcc_cdiag_char_table, gcc_cxxdiag_char_table): Likewise. (check_format_types): Fix wanted_type name lookup. (init_dynamic_diag_info): Setup %J. * diagnostic.c (text_specifies_location): Implement %J. * c-common.c, c-decl.c, c-objc-common.c, c-pragma.c, calls.c, dwarfout.c, expr.c, function.c, stmt.c, stor-layout.c, toplev.c, tree-inline.c, tree-optimize.c, varasm.c, config/arm/pe.c, config/i386/winnt.c, config/ia64/ia64.c, config/mcore/mcore.c, config/v850/v850.c, objc/objc-act.c: Use %J in diagnostics. * tree-inline.c: Include intl.h (inline_forbidden_p_1): Fix i18n of inline_forbidden_reason. * Makefile.in (tree-inline.o): Update. cp/ * decl.c, decl2.c, pt.c: Use %J in diagnostics. java/ * check-init.c, class.c, decl.c, expr.c: Use %J in diagnostics. testsuite/ * gcc.dg/format/gcc_diag-1.c: Add tests for %J. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71619 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 17 ++ gcc/Makefile.in | 2 +- gcc/c-common.c | 45 ++--- gcc/c-decl.c | 331 +++++++++++++------------------ gcc/c-format.c | 37 +++- gcc/c-objc-common.c | 25 +-- gcc/c-pragma.c | 4 +- gcc/calls.c | 6 +- gcc/config/arm/pe.c | 6 +- gcc/config/i386/winnt.c | 47 ++--- gcc/config/ia64/ia64.c | 12 +- gcc/config/mcore/mcore.c | 3 +- gcc/config/v850/v850.c | 8 +- gcc/cp/ChangeLog | 4 + gcc/cp/call.c | 6 +- gcc/cp/decl.c | 50 ++--- gcc/cp/decl2.c | 6 +- gcc/cp/pt.c | 3 +- gcc/diagnostic.c | 11 +- gcc/dwarfout.c | 5 +- gcc/expr.c | 3 +- gcc/function.c | 18 +- gcc/java/ChangeLog | 4 + gcc/java/check-init.c | 4 +- gcc/java/class.c | 7 +- gcc/java/decl.c | 19 +- gcc/java/expr.c | 13 +- gcc/objc/objc-act.c | 19 +- gcc/stmt.c | 10 +- gcc/stor-layout.c | 18 +- gcc/testsuite/ChangeLog | 4 + gcc/testsuite/gcc.dg/format/gcc_diag-1.c | 9 + gcc/toplev.c | 16 +- gcc/tree-inline.c | 49 +++-- gcc/tree-optimize.c | 9 +- gcc/varasm.c | 56 ++---- 36 files changed, 411 insertions(+), 475 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6e8f5a0ab4d..35f2fba3a61 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,20 @@ +2003-09-20 Richard Henderson + + * c-format.c (gcc_diag_char_table): Add %J. + (gcc_cdiag_char_table, gcc_cxxdiag_char_table): Likewise. + (check_format_types): Fix wanted_type name lookup. + (init_dynamic_diag_info): Setup %J. + * diagnostic.c (text_specifies_location): Implement %J. + * c-common.c, c-decl.c, c-objc-common.c, c-pragma.c, calls.c, + dwarfout.c, expr.c, function.c, stmt.c, stor-layout.c, toplev.c, + tree-inline.c, tree-optimize.c, varasm.c, config/arm/pe.c, + config/i386/winnt.c, config/ia64/ia64.c, config/mcore/mcore.c, + config/v850/v850.c, objc/objc-act.c: Use %J in diagnostics. + + * tree-inline.c: Include intl.h + (inline_forbidden_p_1): Fix i18n of inline_forbidden_reason. + * Makefile.in (tree-inline.o): Update. + 2003-09-20 Roger Sayle * config/i386/i386.c (ix86_expand_carry_flag_compare): Fix diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 56b7738d978..768646ca26d 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1471,7 +1471,7 @@ tree-dump.o: tree-dump.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ tree-inline.o : tree-inline.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(TREE_H) $(RTL_H) $(EXPR_H) flags.h $(PARAMS_H) input.h insn-config.h \ $(INTEGRATE_H) $(VARRAY_H) $(HASHTAB_H) $(SPLAY_TREE_H) toplev.h \ - langhooks.h $(C_COMMON_H) tree-inline.h cgraph.h + langhooks.h $(C_COMMON_H) tree-inline.h cgraph.h intl.h tree-optimize.o : tree-optimize.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(TREE_H) toplev.h langhooks.h cgraph.h $(TIMEVAR_H) function.h $(GGC_H) diff --git a/gcc/c-common.c b/gcc/c-common.c index e6d4197d42c..39c6a5741b5 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -1140,8 +1140,7 @@ fname_decl (unsigned int rid, tree id) input_line = saved_lineno; } if (!ix && !current_function_decl) - pedwarn ("%H'%D' is not defined outside of function scope", - &DECL_SOURCE_LOCATION (decl), decl); + pedwarn ("%J'%D' is not defined outside of function scope", decl, decl); return decl; } @@ -3936,19 +3935,17 @@ c_add_case_label (splay_tree cases, tree cond, tree low_value, if (high_value) { error ("duplicate (or overlapping) case value"); - error ("%Hthis is the first entry overlapping that value", - &DECL_SOURCE_LOCATION (duplicate)); + error ("%Jthis is the first entry overlapping that value", duplicate); } else if (low_value) { error ("duplicate case value") ; - error ("%Hpreviously used here", &DECL_SOURCE_LOCATION (duplicate)); + error ("%Jpreviously used here", duplicate); } else { error ("multiple default labels in one switch"); - error ("%Hthis is the first default label", - &DECL_SOURCE_LOCATION (duplicate)); + error ("%Jthis is the first default label", duplicate); } if (!cases->root) add_stmt (build_case_label (NULL_TREE, NULL_TREE, label)); @@ -4249,7 +4246,7 @@ shadow_warning (enum sw_kind msgcode, const char *name, tree decl) }; warning (msgs[msgcode], name); - warning ("%Hshadowed declaration is here", &DECL_SOURCE_LOCATION (decl)); + warning ("%Jshadowed declaration is here", decl); } /* Attribute handlers common to C front ends. */ @@ -4690,8 +4687,8 @@ handle_section_attribute (tree *node, tree name ATTRIBUTE_UNUSED, tree args, && current_function_decl != NULL_TREE && ! TREE_STATIC (decl)) { - error ("%Hsection attribute cannot be specified for " - "local variables", &DECL_SOURCE_LOCATION (decl)); + error ("%Jsection attribute cannot be specified for " + "local variables", decl); *no_add_attrs = true; } @@ -4701,8 +4698,8 @@ handle_section_attribute (tree *node, tree name ATTRIBUTE_UNUSED, tree args, && strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)), TREE_STRING_POINTER (TREE_VALUE (args))) != 0) { - error ("%Hsection of '%D' conflicts with previous declaration", - &DECL_SOURCE_LOCATION (*node), *node); + error ("%Jsection of '%D' conflicts with previous declaration", + *node, *node); *no_add_attrs = true; } else @@ -4710,15 +4707,13 @@ handle_section_attribute (tree *node, tree name ATTRIBUTE_UNUSED, tree args, } else { - error ("%Hsection attribute not allowed for '%D'", - &DECL_SOURCE_LOCATION (*node), *node); + error ("%Jsection attribute not allowed for '%D'", *node, *node); *no_add_attrs = true; } } else { - error ("%Hsection attributes are not supported for this target", - &DECL_SOURCE_LOCATION (*node)); + error ("%Jsection attributes are not supported for this target", *node); *no_add_attrs = true; } @@ -4792,8 +4787,7 @@ handle_aligned_attribute (tree *node, tree name ATTRIBUTE_UNUSED, tree args, else if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FIELD_DECL) { - error ("%Halignment may not be specified for '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jalignment may not be specified for '%D'", decl, decl); *no_add_attrs = true; } else @@ -4831,8 +4825,7 @@ handle_alias_attribute (tree *node, tree name, tree args, if ((TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl)) || (TREE_CODE (decl) != FUNCTION_DECL && ! DECL_EXTERNAL (decl))) { - error ("%H'%D' defined both normally and as an alias", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%J'%D' defined both normally and as an alias", decl, decl); *no_add_attrs = true; } else if (decl_function_context (decl) == 0) @@ -4956,14 +4949,12 @@ handle_no_instrument_function_attribute (tree *node, tree name, if (TREE_CODE (decl) != FUNCTION_DECL) { - error ("%H'%E' attribute applies only to functions", - &DECL_SOURCE_LOCATION (decl), name); + error ("%J'%E' attribute applies only to functions", decl, name); *no_add_attrs = true; } else if (DECL_INITIAL (decl)) { - error ("%Hcan't set '%E' attribute after definition", - &DECL_SOURCE_LOCATION (decl), name); + error ("%Jcan't set '%E' attribute after definition", decl, name); *no_add_attrs = true; } else @@ -5004,14 +4995,12 @@ handle_no_limit_stack_attribute (tree *node, tree name, if (TREE_CODE (decl) != FUNCTION_DECL) { - error ("%H'%E' attribute applies only to functions", - &DECL_SOURCE_LOCATION (decl), name); + error ("%J'%E' attribute applies only to functions", decl, name); *no_add_attrs = true; } else if (DECL_INITIAL (decl)) { - error ("%Hcan't set '%E' attribute after definition", - &DECL_SOURCE_LOCATION (decl), name); + error ("%Jcan't set '%E' attribute after definition", decl, name); *no_add_attrs = true; } else diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 1eb3482cc12..db35f9a9ea9 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -367,8 +367,7 @@ c_finish_incomplete_decl (tree decl) && ! DECL_EXTERNAL (decl) && TYPE_DOMAIN (type) == 0) { - warning ("%Harray '%D' assumed to have one element", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jarray '%D' assumed to have one element", decl, decl); complete_array_type (type, NULL_TREE, 1); @@ -539,22 +538,20 @@ poplevel (int keep, int dummy ATTRIBUTE_UNUSED, int functionbody) for (p = scope->names; p; p = TREE_CHAIN (p)) { - const location_t *locus = &DECL_SOURCE_LOCATION (p); - switch (TREE_CODE (p)) { case LABEL_DECL: if (TREE_USED (p) && !DECL_INITIAL (p)) { - error ("%Hlabel `%D' used but not defined", locus, p); + error ("%Jlabel `%D' used but not defined", p, p); DECL_INITIAL (p) = error_mark_node; } else if (!TREE_USED (p) && warn_unused_label) { if (DECL_INITIAL (p)) - warning ("%Hlabel `%D' defined but not used", locus, p); + warning ("%Jlabel `%D' defined but not used", p, p); else - warning ("%Hlabel `%D' declared but not defined", locus, p); + warning ("%Jlabel `%D' declared but not defined", p, p); } IDENTIFIER_LABEL_VALUE (DECL_NAME (p)) = 0; @@ -579,7 +576,7 @@ poplevel (int keep, int dummy ATTRIBUTE_UNUSED, int functionbody) && !DECL_IN_SYSTEM_HEADER (p) && DECL_NAME (p) && !DECL_ARTIFICIAL (p)) - warning ("%Hunused variable `%D'", locus, p); + warning ("%Junused variable `%D'", p, p); /* fall through */ default: @@ -803,20 +800,19 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, && DECL_UNINLINABLE (olddecl) && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl))) { - warning ("%Hfunction '%D' redeclared as inline", - &DECL_SOURCE_LOCATION (newdecl), newdecl); - warning ("%Hprevious declaration of function '%D' " - "with attribute noinline", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + warning ("%Jfunction '%D' redeclared as inline", + newdecl, newdecl); + warning ("%Jprevious declaration of function '%D' " + "with attribute noinline", olddecl, olddecl); } else if (DECL_DECLARED_INLINE_P (olddecl) && DECL_UNINLINABLE (newdecl) && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl))) { - warning ("%Hfunction '%D' redeclared with attribute noinline", - &DECL_SOURCE_LOCATION (newdecl), newdecl); - warning ("%Hprevious declaration of function '%D' was inline", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + warning ("%Jfunction '%D' redeclared with attribute noinline", + newdecl, newdecl); + warning ("%Jprevious declaration of function '%D' was inline", + olddecl, olddecl); } } @@ -842,19 +838,18 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, if (!TREE_PUBLIC (newdecl)) { if (warn_shadow) - warning ("%Hshadowing built-in function '%D'", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + warning ("%Jshadowing built-in function '%D'", + newdecl, newdecl); } else - warning ("%Hbuilt-in function '%D' declared as non-function", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + warning ("%Jbuilt-in function '%D' declared as non-function", + newdecl, newdecl); } else { - error ("%H'%D' redeclared as different kind of symbol", - &DECL_SOURCE_LOCATION (newdecl), newdecl); - error ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + error ("%J'%D' redeclared as different kind of symbol", + newdecl, newdecl); + error ("%Jprevious declaration of '%D'", olddecl, olddecl); } return 0; @@ -883,8 +878,7 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, built-in definition is overridden, but optionally warn this was a bad choice of name. */ if (warn_shadow) - warning ("%Hshadowing built-in function '%D'", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + warning ("%Jshadowing built-in function '%D'", newdecl, newdecl); /* Discard the old built-in function. */ return 0; } @@ -906,8 +900,8 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, if (!types_match) { /* If types don't match for a built-in, throw away the built-in. */ - warning ("%Hconflicting types for built-in function '%D'", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + warning ("%Jconflicting types for built-in function '%D'", + newdecl, newdecl); return 0; } } @@ -950,8 +944,7 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (oldtype))) == void_type_node))) { if (pedantic) - pedwarn ("%Hconflicting types for '%D'", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + pedwarn ("%Jconflicting types for '%D'", newdecl, newdecl); /* Make sure we keep void * as ret type, not char *. */ if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (oldtype))) == void_type_node) TREE_TYPE (newdecl) = newtype = oldtype; @@ -969,8 +962,7 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == integer_type_node && C_FUNCTION_IMPLICIT_INT (newdecl)) { - pedwarn ("%Hconflicting types for '%D'", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + pedwarn ("%Jconflicting types for '%D'", newdecl, newdecl); /* Make sure we keep void as the return type. */ TREE_TYPE (newdecl) = newtype = oldtype; C_FUNCTION_IMPLICIT_INT (newdecl) = 0; @@ -985,8 +977,7 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, TREE_TYPE (newtype), COMPARE_STRICT) && TYPE_ARG_TYPES (newtype) == 0)) { - error ("%Hconflicting types for '%D'", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + error ("%Jconflicting types for '%D'", newdecl, newdecl); /* Check for function type mismatch involving an empty arglist vs a nonempty one. */ if (TREE_CODE (olddecl) == FUNCTION_DECL @@ -1021,11 +1012,9 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, } } if (C_DECL_IMPLICIT (olddecl)) - error ("%Hprevious implicit declaration of '%D'", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + error ("%Jprevious implicit declaration of '%D'", olddecl, olddecl); else - error ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + error ("%Jprevious declaration of '%D'", olddecl, olddecl); /* This is safer because the initializer might contain references to variables that were declared between olddecl and newdecl. This @@ -1038,62 +1027,54 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL && !DECL_THREAD_LOCAL (olddecl) && DECL_THREAD_LOCAL (newdecl)) { - error ("%Hthread-local declaration of '%D' follows non thread-local " - "declaration", &DECL_SOURCE_LOCATION (newdecl), newdecl); - error ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + error ("%Jthread-local declaration of '%D' follows non thread-local " + "declaration", newdecl, newdecl); + error ("%Jprevious declaration of '%D'", olddecl, olddecl); } /* non-TLS declaration cannot follow TLS declaration. */ else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL && DECL_THREAD_LOCAL (olddecl) && !DECL_THREAD_LOCAL (newdecl)) { - error ("%Hnon thread-local declaration of '%D' follows " - "thread-local declaration", - &DECL_SOURCE_LOCATION (newdecl), newdecl); - error ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + error ("%Jnon thread-local declaration of '%D' follows " + "thread-local declaration", newdecl, newdecl); + error ("%Jprevious declaration of '%D'", olddecl, olddecl); } else { errmsg = redeclaration_error_message (newdecl, olddecl); if (errmsg) { - const location_t *locus = &DECL_SOURCE_LOCATION (newdecl); switch (errmsg) { case 1: - error ("%Hredefinition of '%D'", locus, newdecl); + error ("%Jredefinition of '%D'", newdecl, newdecl); break; case 2: - error ("%Hredeclaration of '%D'", locus, newdecl); + error ("%Jredeclaration of '%D'", newdecl, newdecl); break; case 3: - error ("%Hconflicting declarations of '%D'", locus, newdecl); + error ("%Jconflicting declarations of '%D'", newdecl, newdecl); break; default: abort (); } - locus = &DECL_SOURCE_LOCATION (olddecl); if (DECL_INITIAL (olddecl) && current_scope == global_scope) - error ("%H'%D' previously defined here", locus, olddecl); + error ("%J'%D' previously defined here", olddecl, olddecl); else - error ("%H'%D' previously declared here", locus, olddecl); + error ("%J'%D' previously declared here", olddecl, olddecl); return 0; } else if (TREE_CODE (newdecl) == TYPE_DECL && (DECL_IN_SYSTEM_HEADER (olddecl) || DECL_IN_SYSTEM_HEADER (newdecl))) { - const location_t *locus = &DECL_SOURCE_LOCATION (newdecl); - warning ("%Hredefinition of '%D'", locus, newdecl); - locus = &DECL_SOURCE_LOCATION (olddecl); - if (DECL_INITIAL (olddecl) - && current_scope == global_scope) - warning ("%H'%D' previously defined here", locus, olddecl); + warning ("%Jredefinition of '%D'", newdecl, newdecl); + if (DECL_INITIAL (olddecl) && current_scope == global_scope) + warning ("%J'%D' previously defined here", olddecl, olddecl); else - warning ("%H'%D' previously declared here", locus, olddecl); + warning ("%J'%D' previously declared here", olddecl, olddecl); } else if (TREE_CODE (olddecl) == FUNCTION_DECL && DECL_INITIAL (olddecl) != 0 @@ -1114,20 +1095,16 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, if (TYPE_MAIN_VARIANT (TREE_VALUE (parm)) == void_type_node && TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node) { - const location_t *locus = &DECL_SOURCE_LOCATION (newdecl); - warning ("%Hprototype for '%D' follows", locus, newdecl); - locus = &DECL_SOURCE_LOCATION (olddecl); - warning ("%Hnon-prototype definition here", locus); + warning ("%Jprototype for '%D' follows", newdecl, newdecl); + warning ("%Jnon-prototype definition here", olddecl); break; } if (TYPE_MAIN_VARIANT (TREE_VALUE (parm)) == void_type_node || TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node) { - const location_t *locus = &DECL_SOURCE_LOCATION (newdecl); - error ("%Hprototype for '%D' follows and number of " - "arguments doesn't match", locus, newdecl); - locus = &DECL_SOURCE_LOCATION (olddecl); - error ("%Hnon-prototype definition here", locus); + error ("%Jprototype for '%D' follows and number of " + "arguments doesn't match", newdecl, newdecl); + error ("%Jnon-prototype definition here", olddecl); errmsg = 1; break; } @@ -1136,11 +1113,9 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, if (! comptypes (TREE_VALUE (parm), TREE_VALUE (type), COMPARE_STRICT)) { - const location_t *locus = &DECL_SOURCE_LOCATION (newdecl); - error ("%Hprototype for '%D' follows and argument %d " - "doesn't match", locus, newdecl, nargs); - locus = &DECL_SOURCE_LOCATION (olddecl); - error ("%Hnon-prototype definition here", locus); + error ("%Jprototype for '%D' follows and argument %d " + "doesn't match", newdecl, newdecl, nargs); + error ("%Jnon-prototype definition here", olddecl); errmsg = 1; break; } @@ -1149,30 +1124,28 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, /* Warn about mismatches in various flags. */ else { - const location_t *locus = &DECL_SOURCE_LOCATION (newdecl); - /* Warn if function is now inline but was previously declared not inline and has been called. */ if (TREE_CODE (olddecl) == FUNCTION_DECL && ! DECL_DECLARED_INLINE_P (olddecl) && DECL_DECLARED_INLINE_P (newdecl) && TREE_USED (olddecl)) - warning ("%H'%D' declared inline after being called", - locus, newdecl); + warning ("%J'%D' declared inline after being called", + newdecl, newdecl); if (TREE_CODE (olddecl) == FUNCTION_DECL && ! DECL_DECLARED_INLINE_P (olddecl) && DECL_DECLARED_INLINE_P (newdecl) && DECL_INITIAL (olddecl) != 0) - warning ("%H'%D' declared inline after its definition", - locus, newdecl); + warning ("%J'%D' declared inline after its definition", + newdecl, newdecl); /* If pedantic, warn when static declaration follows a non-static declaration. Otherwise, do so only for functions. */ if ((pedantic || TREE_CODE (olddecl) == FUNCTION_DECL) && TREE_PUBLIC (olddecl) && !TREE_PUBLIC (newdecl)) - warning ("%Hstatic declaration for '%D' follows non-static", - locus, newdecl); + warning ("%Jstatic declaration for '%D' follows non-static", + newdecl, newdecl); /* If warn_traditional, warn when a non-static function declaration follows a static one. */ @@ -1180,24 +1153,24 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, && TREE_CODE (olddecl) == FUNCTION_DECL && !TREE_PUBLIC (olddecl) && TREE_PUBLIC (newdecl)) - warning ("%Hnon-static declaration for '%D' follows static", - locus, newdecl); + warning ("%Jnon-static declaration for '%D' follows static", + newdecl, newdecl); /* Warn when const declaration follows a non-const declaration, but not for functions. */ if (TREE_CODE (olddecl) != FUNCTION_DECL && !TREE_READONLY (olddecl) && TREE_READONLY (newdecl)) - warning ("%Hconst declaration for '%D' follows non-const", - locus, newdecl); + warning ("%Jconst declaration for '%D' follows non-const", + newdecl, newdecl); /* These bits are logically part of the type, for variables. But not for functions (where qualifiers are not valid ANSI anyway). */ else if (pedantic && TREE_CODE (olddecl) != FUNCTION_DECL && (TREE_READONLY (newdecl) != TREE_READONLY (olddecl) || TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl))) - pedwarn ("%Htype qualifiers for '%D' conflict with previous " - "declaration", locus, newdecl); + pedwarn ("%Jtype qualifiers for '%D' conflict with previous " + "declaration", newdecl, newdecl); } } @@ -1210,10 +1183,9 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, /* Don't warn about extern decl followed by (tentative) definition. */ && !(DECL_EXTERNAL (olddecl) && ! DECL_EXTERNAL (newdecl))) { - warning ("%Hredundant redeclaration of '%D' in same scope", - &DECL_SOURCE_LOCATION (newdecl), newdecl); - warning ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + warning ("%Jredundant redeclaration of '%D' in same scope", + newdecl, newdecl); + warning ("%Jprevious declaration of '%D'", olddecl, olddecl); } /* Copy all the DECL_... slots specified in the new decl @@ -1820,8 +1792,7 @@ implicitly_declare (tree functionid) { implicit_decl_warning (DECL_NAME (decl)); if (! DECL_FILE_SCOPE_P (decl)) - warning ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jprevious declaration of '%D'", decl, decl); C_DECL_IMPLICIT (decl) = 1; } /* If this function is global, then it must already be in the @@ -2056,8 +2027,7 @@ declare_label (tree name) if (dup == label) { error ("duplicate label declaration `%s'", IDENTIFIER_POINTER (name)); - error ("%Hthis is a previous declaration", - &DECL_SOURCE_LOCATION (dup)); + error ("%Jthis is a previous declaration", dup); /* Just use the previous declaration. */ return dup; @@ -2092,12 +2062,11 @@ define_label (location_t location, tree name) || (DECL_CONTEXT (label) != current_function_decl && C_DECLARED_LABEL_FLAG (label)))) { - location_t *prev_loc = &DECL_SOURCE_LOCATION (label); error ("%Hduplicate label `%D'", &location, label); if (DECL_INITIAL (label)) - error ("%H`%D' previously defined here", prev_loc, label); + error ("%J`%D' previously defined here", label, label); else - error ("%H`%D' previously declared here", prev_loc, label); + error ("%J`%D' previously declared here", label, label); return 0; } else if (label && DECL_CONTEXT (label) == current_function_decl) @@ -2573,8 +2542,7 @@ start_decl (tree declarator, tree declspecs, int initialized, tree attributes) if (warn_main > 0 && TREE_CODE (decl) != FUNCTION_DECL && MAIN_NAME_P (DECL_NAME (decl))) - warning ("%H'%D' is usually a function", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%J'%D' is usually a function", decl, decl); if (initialized) /* Is it valid for this decl to have an initializer at all? @@ -2697,8 +2665,7 @@ start_decl (tree declarator, tree declspecs, int initialized, tree attributes) && DECL_DECLARED_INLINE_P (decl) && DECL_UNINLINABLE (decl) && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl))) - warning ("%Hinline function '%D' given attribute noinline", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jinline function '%D' given attribute noinline", decl, decl); /* Add this decl to the current scope. TEM may equal DECL or it may be a previous decl of the same name. */ @@ -2769,14 +2736,12 @@ finish_decl (tree decl, tree init, tree asmspec_tree) type = TREE_TYPE (decl); if (failure == 1) - error ("%Hinitializer fails to determine size of '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jinitializer fails to determine size of '%D'", decl, decl); else if (failure == 2) { if (do_default) - error ("%Harray size missing in '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jarray size missing in '%D'", decl, decl); /* If a `static' var's size isn't known, make it extern as well as static, so it does not get allocated. @@ -2792,8 +2757,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree) warn only if the value is less than zero. */ else if (pedantic && TYPE_DOMAIN (type) != 0 && tree_int_cst_sgn (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) < 0) - error ("%Hzero or negative size array '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jzero or negative size array '%D'", decl, decl); layout_decl (decl, 0); } @@ -2821,8 +2785,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree) is an error. */ !DECL_EXTERNAL (decl))) { - error ("%Hstorage size of '%D' isn't known", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jstorage size of '%D' isn't known", decl, decl); TREE_TYPE (decl) = error_mark_node; } @@ -2832,8 +2795,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree) if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST) constant_expression_warning (DECL_SIZE (decl)); else - error ("%Hstorage size of '%D' isn't constant", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jstorage size of '%D' isn't constant", decl, decl); } if (TREE_USED (type)) @@ -2916,8 +2878,8 @@ finish_decl (tree decl, tree init, tree asmspec_tree) if (TREE_CODE (decl) == VAR_DECL && !DECL_REGISTER (decl) && !TREE_STATIC (decl)) - warning ("%Hignoring asm-specifier for non-static local " - "variable '%D'", &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jignoring asm-specifier for non-static local " + "variable '%D'", decl, decl); else SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec)); } @@ -4402,8 +4364,7 @@ grokdeclarator (tree declarator, tree declspecs, C_DECL_VARIABLE_SIZE (decl) = 1; if (inlinep) - pedwarn ("%Hvariable '%D' declared `inline'", - &DECL_SOURCE_LOCATION (decl), decl); + pedwarn ("%Jvariable '%D' declared `inline'", decl, decl); DECL_EXTERNAL (decl) = extern_ref; @@ -4616,8 +4577,8 @@ get_parm_info (int void_at_end) if (!TREE_ASM_WRITTEN (decl)) abort (); - error ("%Hparameter \"%D\" has just a forward declaration", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jparameter \"%D\" has just a forward declaration", + decl, decl); } /* Warn about any struct, union or enum tags defined within this @@ -4853,8 +4814,7 @@ detect_field_duplicates (tree fieldlist) for (y = fieldlist; y != x; y = TREE_CHAIN (y)) if (DECL_NAME (y) == DECL_NAME (x)) { - error ("%Hduplicate member '%D'", - &DECL_SOURCE_LOCATION (x), x); + error ("%Jduplicate member '%D'", x, x); DECL_NAME (x) = NULL_TREE; } } @@ -4870,8 +4830,7 @@ detect_field_duplicates (tree fieldlist) slot = htab_find_slot (htab, y, INSERT); if (*slot) { - error ("%Hduplicate member '%D'", - &DECL_SOURCE_LOCATION (x), x); + error ("%Jduplicate member '%D'", x, x); DECL_NAME (x) = NULL_TREE; } *slot = y; @@ -4972,8 +4931,7 @@ finish_struct (tree t, tree fieldlist, tree attributes) constant_expression_warning (DECL_INITIAL (x)); else { - error ("%Hbit-field '%D' width not an integer constant", - &DECL_SOURCE_LOCATION (x), x); + error ("%Jbit-field '%D' width not an integer constant", x, x); DECL_INITIAL (x) = NULL; } } @@ -4984,8 +4942,7 @@ finish_struct (tree t, tree fieldlist, tree attributes) && TREE_CODE (TREE_TYPE (x)) != BOOLEAN_TYPE && TREE_CODE (TREE_TYPE (x)) != ENUMERAL_TYPE) { - error ("%Hbit-field '%D' has invalid type", - &DECL_SOURCE_LOCATION (x), x); + error ("%Jbit-field '%D' has invalid type", x, x); DECL_INITIAL (x) = NULL; } @@ -4997,8 +4954,7 @@ finish_struct (tree t, tree fieldlist, tree attributes) && !(TREE_CODE (TREE_TYPE (x)) == ENUMERAL_TYPE && (TYPE_PRECISION (TREE_TYPE (x)) == TYPE_PRECISION (integer_type_node)))) - pedwarn ("%Hbit-field '%D' type invalid in ISO C", - &DECL_SOURCE_LOCATION (x), x); + pedwarn ("%Jbit-field '%D' type invalid in ISO C", x, x); /* Detect and ignore out of range field width and process valid field widths. */ @@ -5009,14 +4965,11 @@ finish_struct (tree t, tree fieldlist, tree attributes) ? CHAR_TYPE_SIZE : TYPE_PRECISION (TREE_TYPE (x))); if (tree_int_cst_sgn (DECL_INITIAL (x)) < 0) - error ("%Hnegative width in bit-field '%D'", - &DECL_SOURCE_LOCATION (x), x); + error ("%Jnegative width in bit-field '%D'", x, x); else if (0 < compare_tree_int (DECL_INITIAL (x), max_width)) - pedwarn ("%Hwidth of '%D' exceeds its type", - &DECL_SOURCE_LOCATION (x), x); + pedwarn ("%Jwidth of '%D' exceeds its type", x, x); else if (integer_zerop (DECL_INITIAL (x)) && DECL_NAME (x) != 0) - error ("%Hzero width for bit-field '%D'", - &DECL_SOURCE_LOCATION (x), x); + error ("%Jzero width for bit-field '%D'", x, x); else { /* The test above has assured us that TREE_INT_CST_HIGH is 0. */ @@ -5029,8 +4982,7 @@ finish_struct (tree t, tree fieldlist, tree attributes) || (width < min_precision (TYPE_MAX_VALUE (TREE_TYPE (x)), TREE_UNSIGNED (TREE_TYPE (x)))))) - warning ("%H'%D' is narrower than values of its type", - &DECL_SOURCE_LOCATION (x), x); + warning ("%J'%D' is narrower than values of its type", x, x); DECL_SIZE (x) = bitsize_int (width); DECL_BIT_FIELD (x) = 1; @@ -5047,20 +4999,16 @@ finish_struct (tree t, tree fieldlist, tree attributes) && TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (x))) == NULL_TREE) { if (TREE_CODE (t) == UNION_TYPE) - error ("%Hflexible array member in union", - &DECL_SOURCE_LOCATION (x)); + error ("%Jflexible array member in union", x); else if (TREE_CHAIN (x) != NULL_TREE) - error ("%Hflexible array member not at end of struct", - &DECL_SOURCE_LOCATION (x)); + error ("%Jflexible array member not at end of struct", x); else if (! saw_named_field) - error ("%Hflexible array member in otherwise empty struct", - &DECL_SOURCE_LOCATION (x)); + error ("%Jflexible array member in otherwise empty struct", x); } if (pedantic && TREE_CODE (t) == RECORD_TYPE && flexible_array_type_p (TREE_TYPE (x))) - pedwarn ("%Hinvalid use of structure with flexible array member", - &DECL_SOURCE_LOCATION (x)); + pedwarn ("%Jinvalid use of structure with flexible array member", x); if (DECL_NAME (x)) saw_named_field = 1; @@ -5477,8 +5425,7 @@ start_function (tree declspecs, tree declarator, tree attributes) if (DECL_DECLARED_INLINE_P (decl1) && DECL_UNINLINABLE (decl1) && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl1))) - warning ("%Hinline function '%D' given attribute noinline", - &DECL_SOURCE_LOCATION (decl1), decl1); + warning ("%Jinline function '%D' given attribute noinline", decl1, decl1); announce_function (decl1); @@ -5528,29 +5475,27 @@ start_function (tree declspecs, tree declarator, tree attributes) && TREE_PUBLIC (decl1) && ! MAIN_NAME_P (DECL_NAME (decl1)) && C_DECL_ISNT_PROTOTYPE (old_decl)) - warning ("%Hno previous prototype for '%D'", - &DECL_SOURCE_LOCATION (decl1), decl1); + warning ("%Jno previous prototype for '%D'", decl1, decl1); /* Optionally warn of any def with no previous prototype if the function has already been used. */ else if (warn_missing_prototypes && old_decl != 0 && TREE_USED (old_decl) && TYPE_ARG_TYPES (TREE_TYPE (old_decl)) == 0) - warning ("%H'%D' was used with no prototype before its definition", - &DECL_SOURCE_LOCATION (decl1), decl1); + warning ("%J'%D' was used with no prototype before its definition", + decl1, decl1); /* Optionally warn of any global def with no previous declaration. */ else if (warn_missing_declarations && TREE_PUBLIC (decl1) && old_decl == 0 && ! MAIN_NAME_P (DECL_NAME (decl1))) - warning ("%Hno previous declaration for '%D'", - &DECL_SOURCE_LOCATION (decl1), decl1); + warning ("%Jno previous declaration for '%D'", decl1, decl1); /* Optionally warn of any def with no previous declaration if the function has already been used. */ else if (warn_missing_declarations && old_decl != 0 && TREE_USED (old_decl) && C_DECL_IMPLICIT (old_decl)) - warning ("%H`%D' was used with no declaration before its definition", - &DECL_SOURCE_LOCATION (decl1), decl1); + warning ("%J`%D' was used with no declaration before its definition", + decl1, decl1); /* This is a definition, not a reference. So normally clear DECL_EXTERNAL. @@ -5582,11 +5527,10 @@ start_function (tree declspecs, tree declarator, tree attributes) { tree args; int argct = 0; - const location_t *locus = &DECL_SOURCE_LOCATION (decl1); if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1))) != integer_type_node) - pedwarn ("%Hreturn type of '%D' is not `int'", locus, decl1); + pedwarn ("%Jreturn type of '%D' is not `int'", decl1, decl1); for (args = TYPE_ARG_TYPES (TREE_TYPE (decl1)); args; args = TREE_CHAIN (args)) @@ -5601,8 +5545,8 @@ start_function (tree declspecs, tree declarator, tree attributes) { case 1: if (TYPE_MAIN_VARIANT (type) != integer_type_node) - pedwarn ("%Hfirst argument of '%D' should be `int'", - locus, decl1); + pedwarn ("%Jfirst argument of '%D' should be `int'", + decl1, decl1); break; case 2: @@ -5610,8 +5554,8 @@ start_function (tree declspecs, tree declarator, tree attributes) || TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE || (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type))) != char_type_node)) - pedwarn ("%Hsecond argument of '%D' should be 'char **'", - locus, decl1); + pedwarn ("%Jsecond argument of '%D' should be 'char **'", + decl1, decl1); break; case 3: @@ -5619,8 +5563,8 @@ start_function (tree declspecs, tree declarator, tree attributes) || TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE || (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type))) != char_type_node)) - pedwarn ("%Hthird argument of '%D' should probably be " - "'char **'", locus, decl1); + pedwarn ("%Jthird argument of '%D' should probably be " + "'char **'", decl1, decl1); break; } } @@ -5629,10 +5573,10 @@ start_function (tree declspecs, tree declarator, tree attributes) argument because it's only mentioned in an appendix of the standard. */ if (argct > 0 && (argct < 2 || argct > 3)) - pedwarn ("%H'%D' takes only zero or two arguments", locus, decl1); + pedwarn ("%J'%D' takes only zero or two arguments", decl1, decl1); if (! TREE_PUBLIC (decl1)) - pedwarn ("%H'%D' is normally a non-static function", locus, decl1); + pedwarn ("%J'%D' is normally a non-static function", decl1, decl1); } /* Record the decl so that the function name is defined. @@ -5688,8 +5632,8 @@ store_parm_decls_newstyle (void) if (current_scope->parms || current_scope->names || current_scope->tags) { - error ("%Hold-style parameter declarations in prototyped " - "function definition", &DECL_SOURCE_LOCATION (fndecl)); + error ("%Jold-style parameter declarations in prototyped " + "function definition", fndecl); /* Get rid of the old-style declarations. */ poplevel (0, 0, 0); @@ -5702,7 +5646,7 @@ store_parm_decls_newstyle (void) { DECL_CONTEXT (decl) = current_function_decl; if (DECL_NAME (decl) == 0) - error ("%Hparameter name omitted", &DECL_SOURCE_LOCATION (decl)); + error ("%Jparameter name omitted", decl); else { if (IDENTIFIER_SYMBOL_VALUE (DECL_NAME (decl))) @@ -5777,8 +5721,7 @@ store_parm_decls_oldstyle (void) { if (TREE_VALUE (parm) == 0) { - error ("%Hparameter name missing from parameter list", - &DECL_SOURCE_LOCATION (fndecl)); + error ("%Jparameter name missing from parameter list", fndecl); TREE_PURPOSE (parm) = 0; continue; } @@ -5786,15 +5729,14 @@ store_parm_decls_oldstyle (void) decl = IDENTIFIER_SYMBOL_VALUE (TREE_VALUE (parm)); if (decl && DECL_CONTEXT (decl) == fndecl) { - const location_t *locus = &DECL_SOURCE_LOCATION (decl); /* If we got something other than a PARM_DECL it is an error. */ if (TREE_CODE (decl) != PARM_DECL) - error ("%H\"%D\" declared as a non-parameter", locus, decl); + error ("%J\"%D\" declared as a non-parameter", decl, decl); /* If the declaration is already marked, we have a duplicate name. Complain and ignore the duplicate. */ else if (DECL_WEAK (decl)) { - error ("%Hmultiple parameters named \"%D\"", locus, decl); + error ("%Jmultiple parameters named \"%D\"", decl, decl); TREE_PURPOSE (parm) = 0; continue; } @@ -5802,7 +5744,7 @@ store_parm_decls_oldstyle (void) an int. */ else if (VOID_TYPE_P (TREE_TYPE (decl))) { - error ("%Hparameter \"%D\" declared void", locus, decl); + error ("%Jparameter \"%D\" declared void", decl, decl); TREE_TYPE (decl) = integer_type_node; DECL_ARG_TYPE (decl) = integer_type_node; layout_decl (decl, 0); @@ -5811,16 +5753,15 @@ store_parm_decls_oldstyle (void) /* If no declaration found, default to int. */ else { - const location_t *locus = &DECL_SOURCE_LOCATION (fndecl); decl = build_decl (PARM_DECL, TREE_VALUE (parm), integer_type_node); DECL_ARG_TYPE (decl) = TREE_TYPE (decl); - DECL_SOURCE_LOCATION (decl) = *locus; + DECL_SOURCE_LOCATION (decl) = DECL_SOURCE_LOCATION (fndecl); pushdecl (decl); if (flag_isoc99) - pedwarn ("%Htype of \"%D\" defaults to \"int\"", locus, decl); + pedwarn ("%Jtype of \"%D\" defaults to \"int\"", decl, decl); else if (extra_warnings) - warning ("%Htype of \"%D\" defaults to \"int\"", locus, decl); + warning ("%Jtype of \"%D\" defaults to \"int\"", decl, decl); } TREE_PURPOSE (parm) = decl; @@ -5832,18 +5773,16 @@ store_parm_decls_oldstyle (void) for (parm = current_scope->parms; parm; parm = TREE_CHAIN (parm)) { - const location_t *locus = &DECL_SOURCE_LOCATION (parm); - if (!COMPLETE_TYPE_P (TREE_TYPE (parm))) { - error ("%Hparameter \"%D\" has incomplete type", locus, parm); + error ("%Jparameter \"%D\" has incomplete type", parm, parm); TREE_TYPE (parm) = error_mark_node; } if (! DECL_WEAK (parm)) { - error ("%Hdeclaration for parameter \"%D\" but no such parameter", - locus, parm); + error ("%Jdeclaration for parameter \"%D\" but no such parameter", + parm, parm); /* Pretend the parameter was not missing. This gets us to a standard state and minimizes @@ -6095,8 +6034,7 @@ finish_function () /* If warn_main is 1 (-Wmain) or 2 (-Wall), we have already warned. If warn_main is -1 (-Wno-main) we don't want to be warned. */ if (!warn_main) - pedwarn ("%Hreturn type of '%D' is not `int'", - &DECL_SOURCE_LOCATION (fndecl), fndecl); + pedwarn ("%Jreturn type of '%D' is not `int'", fndecl, fndecl); } else { @@ -6269,16 +6207,15 @@ check_for_loop_decls (void) for (t = getdecls (); t; t = TREE_CHAIN (t)) { - const location_t *locus = &DECL_SOURCE_LOCATION (t); if (TREE_CODE (t) != VAR_DECL && DECL_NAME (t)) - error ("%Hdeclaration of non-variable '%D' in 'for' loop " - "initial declaration", locus, t); + error ("%Jdeclaration of non-variable '%D' in 'for' loop " + "initial declaration", t, t); else if (TREE_STATIC (t)) - error ("%Hdeclaration of static variable '%D' in 'for' loop " - "initial declaration", locus, t); + error ("%Jdeclaration of static variable '%D' in 'for' loop " + "initial declaration", t, t); else if (DECL_EXTERNAL (t)) - error ("%Hdeclaration of 'extern' variable '%D' in 'for' loop " - "initial declaration", locus, t); + error ("%Jdeclaration of 'extern' variable '%D' in 'for' loop " + "initial declaration", t, t); } } @@ -6600,10 +6537,8 @@ merge_translation_unit_decls (void) } else { - error ("%Hredefinition of global '%D'", - &DECL_SOURCE_LOCATION (decl), decl); - error ("%H'%D' previously defined here", - &DECL_SOURCE_LOCATION (old_decl), old_decl); + error ("%Jredefinition of global '%D'", decl, decl); + error ("%J'%D' previously defined here", old_decl, old_decl); } } else diff --git a/gcc/c-format.c b/gcc/c-format.c index 665b6d1cdc9..82fb593f440 100644 --- a/gcc/c-format.c +++ b/gcc/c-format.c @@ -810,6 +810,9 @@ static const format_char_info gcc_diag_char_table[] = /* %H will require "location_t" at runtime. */ { "H", 0, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "" }, + /* These will require a "tree" at runtime. */ + { "J", 0, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "" }, + { "m", 0, STD_C89, NOARGUMENTS, "", "" }, { NULL, 0, 0, NOLENGTHS, NULL, NULL } }; @@ -830,7 +833,7 @@ static const format_char_info gcc_cdiag_char_table[] = { "H", 0, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "" }, /* These will require a "tree" at runtime. */ - { "DEFT", 0, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "" }, + { "DEFJT", 0, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "" }, { "m", 0, STD_C89, NOARGUMENTS, "", "" }, { NULL, 0, 0, NOLENGTHS, NULL, NULL } @@ -852,7 +855,7 @@ static const format_char_info gcc_cxxdiag_char_table[] = { "H", 0, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "" }, /* These will require a "tree" at runtime. */ - { "ADEFTV",0,STD_C89,{ T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "+#", "" }, + { "ADEFJTV",0,STD_C89,{ T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "+#", "" }, /* These accept either an `int' or an `enum tree_code' (which is handled as an `int'.) */ { "CLOPQ",0,STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "" }, @@ -2401,19 +2404,24 @@ check_format_types (int *status, format_wanted_type *types) { const char *this; const char *that; + tree tmp; + + tmp = TYPE_NAME (wanted_type); + if (TREE_CODE (tmp) == TYPE_DECL) + tmp = DECL_NAME (tmp); + this = IDENTIFIER_POINTER (tmp); - this = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (wanted_type))); that = 0; if (TYPE_NAME (orig_cur_type) != 0 && TREE_CODE (orig_cur_type) != INTEGER_TYPE && !(TREE_CODE (orig_cur_type) == POINTER_TYPE && TREE_CODE (TREE_TYPE (orig_cur_type)) == INTEGER_TYPE)) { - if (TREE_CODE (TYPE_NAME (orig_cur_type)) == TYPE_DECL - && DECL_NAME (TYPE_NAME (orig_cur_type)) != 0) - that = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (orig_cur_type))); - else - that = IDENTIFIER_POINTER (TYPE_NAME (orig_cur_type)); + tmp = TYPE_NAME (orig_cur_type); + if (TREE_CODE (tmp) == TYPE_DECL) + tmp = DECL_NAME (tmp); + if (tmp) + that = IDENTIFIER_POINTER (tmp); } /* A nameless type can't possibly match what the format wants. @@ -2471,7 +2479,6 @@ find_char_info_specifier_index (const format_char_info *fci, int c) /* We shouldn't be looking for a non-existent specifier. */ abort (); - } /* Given a format_length_info array FLI, and a character C, this @@ -2604,6 +2611,12 @@ init_dynamic_diag_info (void) diag_fci[i].types[0].type = &loc; diag_fci[i].pointer_count = 1; } + if (t) + { + i = find_char_info_specifier_index (diag_fci, 'J'); + diag_fci[i].types[0].type = &t; + diag_fci[i].pointer_count = 1; + } /* Handle the __gcc_cdiag__ format specifics. */ if (! cdiag_fci) @@ -2623,6 +2636,9 @@ init_dynamic_diag_info (void) i = find_char_info_specifier_index (cdiag_fci, 'D'); cdiag_fci[i].types[0].type = &t; cdiag_fci[i].pointer_count = 1; + i = find_char_info_specifier_index (cdiag_fci, 'J'); + cdiag_fci[i].types[0].type = &t; + cdiag_fci[i].pointer_count = 1; } /* Handle the __gcc_cxxdiag__ format specifics. */ @@ -2643,6 +2659,9 @@ init_dynamic_diag_info (void) i = find_char_info_specifier_index (cxxdiag_fci, 'D'); cxxdiag_fci[i].types[0].type = &t; cxxdiag_fci[i].pointer_count = 1; + i = find_char_info_specifier_index (cxxdiag_fci, 'J'); + cxxdiag_fci[i].types[0].type = &t; + cxxdiag_fci[i].pointer_count = 1; } } } diff --git a/gcc/c-objc-common.c b/gcc/c-objc-common.c index 172346b2aec..287cf300232 100644 --- a/gcc/c-objc-common.c +++ b/gcc/c-objc-common.c @@ -78,9 +78,8 @@ c_cannot_inline_tree_fn (tree *fnp) && lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL) { if (do_warning) - warning ("%Hfunction '%F' can never be inlined because it " - "is supressed using -fno-inline", - &DECL_SOURCE_LOCATION (fn), fn); + warning ("%Jfunction '%F' can never be inlined because it " + "is supressed using -fno-inline", fn, fn); goto cannot_inline; } @@ -89,18 +88,16 @@ c_cannot_inline_tree_fn (tree *fnp) if (!DECL_DECLARED_INLINE_P (fn) && !(*targetm.binds_local_p) (fn)) { if (do_warning) - warning ("%Hfunction '%F' can never be inlined because it might not " - "be bound within this unit of translation", - &DECL_SOURCE_LOCATION (fn), fn); + warning ("%Jfunction '%F' can never be inlined because it might not " + "be bound within this unit of translation", fn, fn); goto cannot_inline; } if (! function_attribute_inlinable_p (fn)) { if (do_warning) - warning ("%Hfunction '%F' can never be inlined because it uses " - "attributes conflicting with inlining", - &DECL_SOURCE_LOCATION (fn), fn); + warning ("%Jfunction '%F' can never be inlined because it uses " + "attributes conflicting with inlining", fn, fn); goto cannot_inline; } @@ -114,9 +111,8 @@ c_cannot_inline_tree_fn (tree *fnp) if (t) { if (do_warning) - warning ("%Hfunction '%F' can never be inlined because it has " - "pending sizes", - &DECL_SOURCE_LOCATION (fn), fn); + warning ("%Jfunction '%F' can never be inlined because it has " + "pending sizes", fn, fn); goto cannot_inline; } } @@ -128,9 +124,8 @@ c_cannot_inline_tree_fn (tree *fnp) if (DECL_LANG_SPECIFIC (fn)->pending_sizes) { if (do_warning) - warning ("%Hnested function '%F' can never be inlined because it " - "has possibly saved pending sizes", - &DECL_SOURCE_LOCATION (fn), fn); + warning ("%Jnested function '%F' can never be inlined because it " + "has possibly saved pending sizes", fn, fn); goto cannot_inline; } } diff --git a/gcc/c-pragma.c b/gcc/c-pragma.c index c0bfc295749..141b9061cef 100644 --- a/gcc/c-pragma.c +++ b/gcc/c-pragma.c @@ -275,8 +275,8 @@ apply_pragma_weak (tree decl, tree value) if (SUPPORTS_WEAK && DECL_EXTERNAL (decl) && TREE_USED (decl) && !DECL_WEAK (decl) /* don't complain about a redundant #pragma */ && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) - warning ("%Happlying #pragma weak '%D' after first use results " - "in unspecified behavior", &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Japplying #pragma weak '%D' after first use results " + "in unspecified behavior", decl, decl); declare_weak (decl); } diff --git a/gcc/calls.c b/gcc/calls.c index 2c952ab1b68..fa4f93473c5 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1819,8 +1819,7 @@ try_to_integrate (tree fndecl, tree actparms, rtx target, int ignore, if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline && optimize > 0 && !TREE_ADDRESSABLE (fndecl)) { - warning ("%Hinlining failed in call to '%F'", - &DECL_SOURCE_LOCATION (fndecl), fndecl); + warning ("%Jinlining failed in call to '%F'", fndecl, fndecl); warning ("called from here"); } (*lang_hooks.mark_addressable) (fndecl); @@ -2160,8 +2159,7 @@ expand_call (tree exp, rtx target, int ignore) if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline && optimize > 0) { - warning ("%Hcan't inline call to '%F'", - &DECL_SOURCE_LOCATION (fndecl), fndecl); + warning ("%Jcan't inline call to '%F'", fndecl, fndecl); warning ("called from here"); } (*lang_hooks.mark_addressable) (fndecl); diff --git a/gcc/config/arm/pe.c b/gcc/config/arm/pe.c index d9d54c10eed..d25fd0da977 100644 --- a/gcc/config/arm/pe.c +++ b/gcc/config/arm/pe.c @@ -167,8 +167,7 @@ arm_mark_dllimport (decl) && !DECL_VIRTUAL_P (decl) && DECL_INITIAL (decl)) { - error ("%Hinitialized variable '%D' is marked dllimport", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jinitialized variable '%D' is marked dllimport", decl, decl); return; } /* Nor can they be static. */ @@ -177,8 +176,7 @@ arm_mark_dllimport (decl) && !DECL_VIRTUAL_P (decl) && 0 /*???*/) { - error ("%Hstatic variable '%D' is marked dllimport", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jstatic variable '%D' is marked dllimport", decl, decl); return; } diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c index 11a93a42ff1..f376bc4c710 100644 --- a/gcc/config/i386/winnt.c +++ b/gcc/config/i386/winnt.c @@ -101,8 +101,7 @@ ix86_handle_dll_attribute (tree * pnode, tree name, tree args, int flags, if (TREE_CODE (node) == FUNCTION_DECL && DECL_INITIAL (node) && !DECL_INLINE (node)) { - error ("%Hfunction `%D' definition is marked dllimport.", - &DECL_SOURCE_LOCATION (node), node); + error ("%Jfunction `%D' definition is marked dllimport.", node, node); *no_add_attrs = true; } @@ -110,8 +109,8 @@ ix86_handle_dll_attribute (tree * pnode, tree name, tree args, int flags, { if (DECL_INITIAL (node)) { - error ("%Hvariable `%D' definition is marked dllimport.", - &DECL_SOURCE_LOCATION (node), node); + error ("%Jvariable `%D' definition is marked dllimport.", + node, node); *no_add_attrs = true; } @@ -130,8 +129,8 @@ ix86_handle_dll_attribute (tree * pnode, tree name, tree args, int flags, && (TREE_CODE (node) == VAR_DECL || TREE_CODE (node) == FUNCTION_DECL)) { - error ("%Hexternal linkage required for symbol '%D' because of '%s' attribute.", - &DECL_SOURCE_LOCATION (node), node, IDENTIFIER_POINTER (name)); + error ("%Jexternal linkage required for symbol '%D' because of " + "'%s' attribute.", node, node, IDENTIFIER_POINTER (name)); *no_add_attrs = true; } @@ -245,8 +244,8 @@ i386_pe_dllimport_p (tree decl) { /* Don't warn about artificial methods. */ if (!DECL_ARTIFICIAL (decl)) - warning ("%H function '%D' is defined after prior declaration as dllimport: attribute ignored", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jfunction '%D' is defined after prior declaration " + "as dllimport: attribute ignored", decl, decl); return 0; } @@ -256,8 +255,8 @@ i386_pe_dllimport_p (tree decl) else if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INLINE (decl)) { if (extra_warnings) - warning ("%Hinline function '%D' is declared as dllimport: attribute ignored.", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jinline function '%D' is declared as dllimport: " + "attribute ignored.", decl, decl); return 0; } @@ -268,8 +267,9 @@ i386_pe_dllimport_p (tree decl) && !DECL_EXTERNAL (decl) && context_imp) { if (!DECL_VIRTUAL_P (decl)) - error ("%Hdefinition of static data member '%D' of dllimport'd class.", - &DECL_SOURCE_LOCATION (decl), decl); return 0; + error ("%Jdefinition of static data member '%D' of " + "dllimport'd class.", decl, decl); + return 0; } /* Since we can't treat a pointer to a dllimport'd symbol as a @@ -326,8 +326,8 @@ i386_pe_mark_dllexport (tree decl) abort (); if (i386_pe_dllimport_name_p (oldname)) { - warning ("%Hinconsistent dll linkage for '%D', dllexport assumed.", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jinconsistent dll linkage for '%D', dllexport assumed.", + decl, decl); /* Remove DLL_IMPORT_PREFIX. */ oldname += strlen (DLL_IMPORT_PREFIX); DECL_NON_ADDR_CONST_P (decl) = 0; @@ -377,8 +377,8 @@ i386_pe_mark_dllimport (tree decl) /* Already done, but do a sanity check to prevent assembler errors. */ if (!DECL_EXTERNAL (decl) || !TREE_PUBLIC (decl)) { - error ("%Hfailure in redeclaration of '%D': dllimport'd symbol lacks external linkage.", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jfailure in redeclaration of '%D': dllimport'd " + "symbol lacks external linkage.", decl, decl); abort(); } return; @@ -521,15 +521,17 @@ i386_pe_encode_section_info (tree decl, rtx rtl, int first) && i386_pe_dllimport_name_p (XSTR (XEXP (XEXP (DECL_RTL (decl), 0), 0), 0))) { const char *oldname = XSTR (XEXP (XEXP (DECL_RTL (decl), 0), 0), 0); + /* Remove DLL_IMPORT_PREFIX. */ tree idp = get_identifier (oldname + strlen (DLL_IMPORT_PREFIX)); rtx newrtl = gen_rtx (SYMBOL_REF, Pmode, IDENTIFIER_POINTER (idp)); - warning ("%H%s '%D' %s after being referenced with dllimport linkage.", - &DECL_SOURCE_LOCATION (decl), - TREE_CODE (decl) == VAR_DECL ? "variable" : "function", - decl, (DECL_INITIAL (decl) || !DECL_EXTERNAL (decl)) - ? "defined locally" : "redeclared without dllimport attribute"); + if (DECL_INITIAL (decl) || !DECL_EXTERNAL (decl)) + warning ("%J'%D' defined locally after being " + "referenced with dllimport linkage", decl, decl); + else + warning ("%J'%D' redeclared without dllimport attribute " + "after being referenced with dllimport linkage", decl, decl); XEXP (DECL_RTL (decl), 0) = newrtl; @@ -699,8 +701,7 @@ i386_pe_section_type_flags (tree decl, const char *name, int reloc) else { if (decl && **slot != flags) - error ("%H'%D' causes a section type conflict", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%J'%D' causes a section type conflict", decl, decl); } return flags; diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index 9ca874d1dd4..f82981b07bf 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -1030,22 +1030,22 @@ ia64_handle_model_attribute (tree *node, tree name, tree args, int flags ATTRIBU == FUNCTION_DECL) && !TREE_STATIC (decl)) { - error ("%Ha an address area attribute cannot be specified for " - "local variables", &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jan address area attribute cannot be specified for " + "local variables", decl, decl); *no_add_attrs = true; } area = ia64_get_addr_area (decl); if (area != ADDR_AREA_NORMAL && addr_area != area) { - error ("%Ha address area of '%s' conflicts with previous " - "declaration", &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jaddress area of '%s' conflicts with previous " + "declaration", decl, decl); *no_add_attrs = true; } break; case FUNCTION_DECL: - error ("%Ha address area attribute cannot be specified for functions", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jaddress area attribute cannot be specified for functions", + decl, decl); *no_add_attrs = true; break; diff --git a/gcc/config/mcore/mcore.c b/gcc/config/mcore/mcore.c index b148c27b6aa..fe44a1ee7fc 100644 --- a/gcc/config/mcore/mcore.c +++ b/gcc/config/mcore/mcore.c @@ -3358,8 +3358,7 @@ mcore_mark_dllimport (decl) && !DECL_VIRTUAL_P (decl) && DECL_INITIAL (decl)) { - error ("%Hinitialized variable '%D' is marked dllimport", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jinitialized variable '%D' is marked dllimport", decl, decl); return; } diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c index 8da1669324d..3c40da1815c 100644 --- a/gcc/config/v850/v850.c +++ b/gcc/config/v850/v850.c @@ -2257,8 +2257,8 @@ v850_handle_data_area_attribute (node, name, args, flags, no_add_attrs) case VAR_DECL: if (current_function_decl != NULL_TREE) { - error ("%Ha data area attribute cannot be specified for " - "local variables", &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jdata area attributes cannot be specified for " + "local variables", decl, decl); *no_add_attrs = true; } @@ -2268,8 +2268,8 @@ v850_handle_data_area_attribute (node, name, args, flags, no_add_attrs) area = v850_get_data_area (decl); if (area != DATA_AREA_NORMAL && data_area != area) { - error ("%Hdata area of '%D' conflicts with previous declaration", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jdata area of '%D' conflicts with previous declaration", + decl, decl); *no_add_attrs = true; } break; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b7d65feb4d9..2734bf6f4d4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2003-09-20 Richard Henderson + + * decl.c, decl2.c, pt.c: Use %J in diagnostics. + 2003-09-20 Kriang Lerdsuwanakij PR c++/157 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index b2b9d000c6b..424ec8d3728 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -2362,11 +2362,9 @@ print_z_candidate (const char *msgstr, struct z_candidate *candidate) else if (TYPE_P (candidate->fn)) inform ("%s %T ", msgstr, candidate->fn); else if (candidate->viable == -1) - inform ("%H%s %+#D ", - &DECL_SOURCE_LOCATION (candidate->fn), msgstr, candidate->fn); + inform ("%J%s %+#D ", candidate->fn, msgstr, candidate->fn); else - inform ("%H%s %+#D", - &DECL_SOURCE_LOCATION (candidate->fn), msgstr, candidate->fn); + inform ("%J%s %+#D", candidate->fn, msgstr, candidate->fn); } static void diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 095c6fdd61b..892affacc82 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2755,19 +2755,18 @@ duplicate_decls (tree newdecl, tree olddecl) && DECL_UNINLINABLE (olddecl) && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl))) { - warning ("%Hfunction '%D' redeclared as inline", - &DECL_SOURCE_LOCATION (newdecl), newdecl); - warning ("%Hprevious declaration of '%D' with attribute noinline", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + warning ("%Jfunction '%D' redeclared as inline", newdecl, newdecl); + warning ("%Jprevious declaration of '%D' with attribute noinline", + olddecl, olddecl); } else if (DECL_DECLARED_INLINE_P (olddecl) && DECL_UNINLINABLE (newdecl) && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl))) { - warning ("%Hfunction '%D' redeclared with attribute noinline", - &DECL_SOURCE_LOCATION (newdecl), newdecl); - warning ("%Hprevious declaration of '%D' was inline", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + warning ("%Jfunction '%D' redeclared with attribute noinline", + newdecl, newdecl); + warning ("%Jprevious declaration of '%D' was inline", + olddecl, olddecl); } } @@ -3009,8 +3008,7 @@ duplicate_decls (tree newdecl, tree olddecl) { /* Prototype decl follows defn w/o prototype. */ cp_warning_at ("prototype for `%#D'", newdecl); - warning ("%Hfollows non-prototype definition here", - &DECL_SOURCE_LOCATION (olddecl)); + warning ("%Jfollows non-prototype definition here", olddecl); } else if (TREE_CODE (olddecl) == FUNCTION_DECL && DECL_LANGUAGE (newdecl) != DECL_LANGUAGE (olddecl)) @@ -3065,10 +3063,8 @@ duplicate_decls (tree newdecl, tree olddecl) && ! DECL_DECLARED_INLINE_P (olddecl) && TREE_ADDRESSABLE (olddecl) && warn_inline) { - warning ("`%#D' was used before it was declared inline", - newdecl); - warning ("%Hprevious non-inline declaration here", - &DECL_SOURCE_LOCATION (olddecl)); + warning ("`%#D' was used before it was declared inline", newdecl); + warning ("%Jprevious non-inline declaration here", olddecl); } } } @@ -4790,7 +4786,7 @@ check_goto (tree decl) if (u > 1 && DECL_ARTIFICIAL (b)) /* Can't skip init of __exception_info. */ - error ("%H enters catch block", &DECL_SOURCE_LOCATION (b)); + error ("%J enters catch block", b); else if (u > 1) cp_error_at (" skips initialization of `%#D'", b); else @@ -6577,8 +6573,8 @@ fixup_anonymous_aggr (tree t) /* ISO C++ 9.5.3. Anonymous unions may not have function members. */ if (TYPE_METHODS (t)) - error ("%Han anonymous union cannot have function members", - &DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (t))); + error ("%Jan anonymous union cannot have function members", + TYPE_MAIN_DECL (t)); /* Anonymous aggregates cannot have fields with ctors, dtors or complex assignment operators (because they cannot have these methods themselves). @@ -6911,8 +6907,7 @@ start_decl (tree declarator, && DECL_DECLARED_INLINE_P (decl) && DECL_UNINLINABLE (decl) && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl))) - warning ("%Hinline function '%D' given attribute noinline", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jinline function '%D' given attribute noinline", decl, decl); if (context && COMPLETE_TYPE_P (complete_type (context))) { @@ -7281,8 +7276,8 @@ maybe_commonize_var (tree decl) TREE_PUBLIC (decl) = 0; DECL_COMMON (decl) = 0; cp_warning_at ("sorry: semantics of inline function static data `%#D' are wrong (you'll wind up with multiple copies)", decl); - warning ("%H you can work around this by removing the initializer", - &DECL_SOURCE_LOCATION (decl)); + warning ("%J you can work around this by removing the initializer", + decl); } } } @@ -11019,8 +11014,7 @@ grokdeclarator (tree declarator, { decl = build_decl (TYPE_DECL, declarator, type); if (in_namespace || ctype) - error ("%Htypedef name may not be a nested-name-specifier", - &DECL_SOURCE_LOCATION (decl)); + error ("%Jtypedef name may not be a nested-name-specifier", decl); if (!current_function_decl) DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace); } @@ -11066,8 +11060,8 @@ grokdeclarator (tree declarator, if (ctype == NULL_TREE) { if (TREE_CODE (type) != METHOD_TYPE) - error ("%Hinvalid type qualifier for non-member function type", - &DECL_SOURCE_LOCATION (decl)); + error ("%Jinvalid type qualifier for non-member function type", + decl); else ctype = TYPE_METHOD_BASETYPE (type); } @@ -12903,8 +12897,7 @@ start_enum (tree name) if (enumtype != NULL_TREE && TREE_CODE (enumtype) == ENUMERAL_TYPE) { error ("multiple definition of `%#T'", enumtype); - error ("%Hprevious definition here", - &DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (enumtype))); + error ("%Jprevious definition here", TYPE_MAIN_DECL (enumtype)); /* Clear out TYPE_VALUES, and start again. */ TYPE_VALUES (enumtype) = NULL_TREE; } @@ -13346,8 +13339,7 @@ start_function (tree declspecs, tree declarator, tree attrs, int flags) if (DECL_DECLARED_INLINE_P (decl1) && lookup_attribute ("noinline", attrs)) - warning ("%Hinline function '%D' given attribute noinline", - &DECL_SOURCE_LOCATION (decl1), decl1); + warning ("%Jinline function '%D' given attribute noinline", decl1, decl1); if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl1)) /* This is a constructor, we must ensure that any default args diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 16991f3ca7d..b1ee970464e 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3224,10 +3224,8 @@ ambiguous_decl (tree name, cxx_binding *old, cxx_binding *new, int flags) if (flags & LOOKUP_COMPLAIN) { error ("`%D' denotes an ambiguous type",name); - error ("%H first type here", - &DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (BINDING_TYPE (old)))); - error ("%H other type here", - &DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type))); + error ("%J first type here", TYPE_MAIN_DECL (BINDING_TYPE (old))); + error ("%J other type here", TYPE_MAIN_DECL (type)); } } return old; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3e1cd0dcd8e..12baea14a33 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2946,8 +2946,7 @@ redeclare_class_template (tree type, tree parms) A template-parameter may not be given default arguments by two different declarations in the same scope. */ error ("redefinition of default argument for `%#D'", parm); - error ("%H original definition appeared here", - &DECL_SOURCE_LOCATION (tmpl_parm)); + error ("%J original definition appeared here", tmpl_parm); return; } diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 3d64b87cfdd..c29867a60b3 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -130,10 +130,17 @@ text_specifies_location (text_info *text, location_t *locus) ; /* Extract the location information if any. */ - if (*p == '%' && *++p == 'H') + if (p[0] == '%' && p[1] == 'H') { *locus = *va_arg (*text->args_ptr, location_t *); - text->format_spec = p + 1; + text->format_spec = p + 2; + return true; + } + else if (p[0] == '%' && p[1] == 'J') + { + tree t = va_arg (*text->args_ptr, tree); + *locus = DECL_SOURCE_LOCATION (t); + text->format_spec = p + 2; return true; } diff --git a/gcc/dwarfout.c b/gcc/dwarfout.c index 166addb9308..dfd1f0b57e1 100644 --- a/gcc/dwarfout.c +++ b/gcc/dwarfout.c @@ -2036,9 +2036,8 @@ output_reg_number (rtx rtl) if (regno >= DWARF_FRAME_REGISTERS) { - warning ("%Hinternal regno botch: '%D' has regno = %d\n", - &DECL_SOURCE_LOCATION (dwarf_last_decl), dwarf_last_decl, - regno); + warning ("%Jinternal regno botch: '%D' has regno = %d\n", + dwarf_last_decl, dwarf_last_decl, regno); regno = 0; } dw2_assemble_integer (4, GEN_INT (DBX_REGISTER_NUMBER (regno))); diff --git a/gcc/expr.c b/gcc/expr.c index 5c055462a90..633f4a75537 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -6757,8 +6757,7 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode, case PARM_DECL: if (!DECL_RTL_SET_P (exp)) { - error ("%Hprior parameter's size depends on '%D'", - &DECL_SOURCE_LOCATION (exp), exp); + error ("%Jprior parameter's size depends on '%D'", exp, exp); return CONST0_RTX (mode); } diff --git a/gcc/function.c b/gcc/function.c index 344e31bc1e5..baec4ab3048 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -880,8 +880,7 @@ assign_temp (tree type_or_decl, int keep, int memory_required, if (decl && size == -1 && TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST) { - error ("%Hsize of variable '%D' is too large", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jsize of variable '%D' is too large", decl, decl); size = 1; } @@ -5610,15 +5609,15 @@ uninitialized_vars_warning (tree block) if we want to warn. */ && (DECL_INITIAL (decl) == NULL_TREE || lang_hooks.decl_uninit (decl)) && regno_uninitialized (REGNO (DECL_RTL (decl)))) - warning ("%H'%D' might be used uninitialized in this function", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%J'%D' might be used uninitialized in this function", + decl, decl); if (extra_warnings && TREE_CODE (decl) == VAR_DECL && DECL_RTL (decl) != 0 && GET_CODE (DECL_RTL (decl)) == REG && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl)))) - warning ("%Hvariable '%D' might be clobbered by `longjmp' or `vfork'", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jvariable '%D' might be clobbered by `longjmp' or `vfork'", + decl, decl); } for (sub = BLOCK_SUBBLOCKS (block); sub; sub = TREE_CHAIN (sub)) uninitialized_vars_warning (sub); @@ -5636,8 +5635,8 @@ setjmp_args_warning (void) if (DECL_RTL (decl) != 0 && GET_CODE (DECL_RTL (decl)) == REG && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl)))) - warning ("%Hargument '%D' might be clobbered by `longjmp' or `vfork'", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jargument '%D' might be clobbered by `longjmp' or `vfork'", + decl, decl); } /* If this function call setjmp, put all vars into the stack @@ -6895,8 +6894,7 @@ expand_function_end (void) decl; decl = TREE_CHAIN (decl)) if (! TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl)) - warning ("%Hunused parameter '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Junused parameter '%D'", decl, decl); } /* Delete handlers for nonlocal gotos if nothing uses them. */ diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 6c6b157eb20..a14c1db5597 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,7 @@ +2003-09-20 Richard Henderson + + * check-init.c, class.c, decl.c, expr.c: Use %J in diagnostics. + 2003-09-18 Roger Sayle * expr.c (java_truthvalue_conversion): Remove FFS_EXPR case. diff --git a/gcc/java/check-init.c b/gcc/java/check-init.c index 04ce354f535..03af2faf1cf 100644 --- a/gcc/java/check-init.c +++ b/gcc/java/check-init.c @@ -976,8 +976,8 @@ check_for_initialization (tree body, tree mdecl) if (index >= 0 && ! ASSIGNED_P (before, index)) { if (! is_finit_method) - error ("%Hfinal field '%D' may not have been initialized", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jfinal field '%D' may not have been initialized", + decl, decl); } else if (is_finit_method) DECL_FIELD_FINAL_IUD (decl) = 1; diff --git a/gcc/java/class.c b/gcc/java/class.c index a1c7249156b..e3e6cc36e58 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -1211,8 +1211,7 @@ get_dispatch_table (tree type, tree this_class_addr) if (METHOD_ABSTRACT (method)) { if (! abstract_p) - warning ("%Habstract method in non-abstract class", - &DECL_SOURCE_FILE (method)); + warning ("%Jabstract method in non-abstract class", method); if (TARGET_VTABLE_USES_DESCRIPTORS) for (j = 0; j < TARGET_VTABLE_USES_DESCRIPTORS; ++j) @@ -1986,8 +1985,8 @@ layout_class_method (tree this_class, tree super_class, DECL_VINDEX (method_decl) = DECL_VINDEX (super_method); if (DECL_VINDEX (method_decl) == NULL_TREE && !CLASS_FROM_SOURCE_P (this_class)) - error ("%Hnon-static method '%D' overrides static method", - &DECL_SOURCE_LOCATION (method_decl), method_decl); + error ("%Jnon-static method '%D' overrides static method", + method_decl, method_decl); } else if (! METHOD_FINAL (method_decl) && ! METHOD_PRIVATE (method_decl) diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 90978e48ec8..7ddf704efad 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -1019,8 +1019,7 @@ pushdecl (tree x) /* error_mark_node is 0 for a while during initialization! */ { t = 0; - error ("%H'%D' used prior to declaration", - &DECL_SOURCE_LOCATION (x), x); + error ("%J'%D' used prior to declaration", x, x); } /* If we're naming a hitherto-unnamed type, set its TYPE_NAME @@ -1356,14 +1355,12 @@ poplevel (int keep, int reverse, int functionbody) if (DECL_INITIAL (label) == 0) { - error ("%Hlabel '%D' used but not defined", - &DECL_SOURCE_LOCATION (label), label); + error ("%Jlabel '%D' used but not defined", label, label); /* Avoid crashing later. */ define_label (input_location, DECL_NAME (label)); } else if (warn_unused[UNUSED_LABEL] && !TREE_USED (label)) - warning ("%Hlabel '%D' defined but not used", - &DECL_SOURCE_LOCATION (label), label); + warning ("%Jlabel '%D' defined but not used", label, label); IDENTIFIER_LABEL_VALUE (DECL_NAME (label)) = 0; /* Put the labels into the "variables" of the @@ -1491,9 +1488,9 @@ force_poplevels (int start_pc) while (current_binding_level->start_pc > start_pc) { if (pedantic && current_binding_level->start_pc > start_pc) - warning ("%HIn %D: overlapped variable and exception ranges at %d", - &DECL_SOURCE_LOCATION (current_function_decl), - current_function_decl, current_binding_level->start_pc); + warning ("%JIn %D: overlapped variable and exception ranges at %d", + current_function_decl, current_function_decl, + current_binding_level->start_pc); expand_end_bindings (getdecls (), 1, 0); poplevel (1, 0, 0); } @@ -1578,8 +1575,8 @@ give_name_to_locals (JCF *jcf) tree decl = build_decl (VAR_DECL, name, type); if (end_pc > DECL_CODE_LENGTH (current_function_decl)) { - warning ("%Hbad PC range for debug info for local '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jbad PC range for debug info for local '%D'", + decl, decl); end_pc = DECL_CODE_LENGTH (current_function_decl); } diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 94f23f3661d..803c2deff83 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -2335,22 +2335,21 @@ expand_java_field_op (int is_static, int is_putting, int field_ref_index) if (FIELD_FINAL (field_decl)) { if (DECL_CONTEXT (field_decl) != current_class) - error ("%Hassignment to final field '%D' not in field's class", - &DECL_SOURCE_LOCATION (field_decl), field_decl); + error ("%Jassignment to final field '%D' not in field's class", + field_decl, field_decl); else if (FIELD_STATIC (field_decl)) { if (!DECL_CLINIT_P (current_function_decl)) - warning ("assignment to final static field `%s' not in " - "class initializer", - &DECL_SOURCE_LOCATION (field_decl), field_decl); + warning ("%Jassignment to final static field `%D' not in " + "class initializer", field_decl, field_decl); } else { tree cfndecl_name = DECL_NAME (current_function_decl); if (! DECL_CONSTRUCTOR_P (current_function_decl) && !ID_FINIT_P (cfndecl_name)) - warning ("%Hassignment to final field '%D' not in constructor", - &DECL_SOURCE_LOCATION (field_decl), field_decl); + warning ("%Jassignment to final field '%D' not in constructor", + field_decl, field_decl); } } expand_assignment (field_ref, new_value, 0); diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 3532d481b15..0c075430502 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -890,8 +890,7 @@ objc_check_decl (tree decl) if (TREE_CODE (type) == RECORD_TYPE && TREE_STATIC_TEMPLATE (type) && type != constant_string_type) - error ("%H'%D' cannot be statically allocated", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%J'%D' cannot be statically allocated", decl, decl); } /* Implement static typing. At this point, we know we have an interface. */ @@ -2314,9 +2313,8 @@ objc_declare_class (tree ident_list) if ((decl = lookup_name (ident))) { error ("`%s' redeclared as different kind of symbol", - IDENTIFIER_POINTER (ident)); - error ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + IDENTIFIER_POINTER (ident)); + error ("%Jprevious declaration of '%D'", decl, decl); } if (! is_class_name (ident)) @@ -3414,9 +3412,7 @@ synth_forward_declarations (void) static void error_with_ivar (const char *message, tree decl, tree rawdecl) { - error ("%H%s `%s'", &DECL_SOURCE_LOCATION (decl), - message, gen_declaration (rawdecl, errbuf)); - + error ("%J%s `%s'", decl, message, gen_declaration (rawdecl, errbuf)); } static void @@ -5934,8 +5930,7 @@ start_class (enum tree_code code, tree class_name, tree super_name, { error ("`%s' redeclared as different kind of symbol", IDENTIFIER_POINTER (class_name)); - error ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jprevious declaration of '%D'", decl, decl); } if (code == CLASS_IMPLEMENTATION_TYPE) @@ -6825,8 +6820,8 @@ static void warn_with_method (const char *message, int mtype, tree method) { /* Add a readable method name to the warning. */ - warning ("%H%s `%c%s'", &DECL_SOURCE_LOCATION (method), - message, mtype, gen_method_decl (method, errbuf)); + warning ("%J%s `%c%s'", method, message, mtype, + gen_method_decl (method, errbuf)); } /* Return 1 if METHOD is consistent with PROTO. */ diff --git a/gcc/stmt.c b/gcc/stmt.c index 18f46c818d6..9d5553f2517 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -966,8 +966,8 @@ fixup_gotos (struct nesting *thisblock, rtx stack_level, && INSN_UID (first_insn) > INSN_UID (f->before_jump) && ! DECL_ERROR_ISSUED (f->target)) { - error ("%Hlabel '%D' used before containing binding contour", - &DECL_SOURCE_LOCATION (f->target), f->target); + error ("%Jlabel '%D' used before containing binding contour", + f->target, f->target); /* Prevent multiple errors for one label. */ DECL_ERROR_ISSUED (f->target) = 1; } @@ -3631,7 +3631,7 @@ warn_about_unused_variables (tree vars) && ! TREE_USED (decl) && ! DECL_IN_SYSTEM_HEADER (decl) && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl)) - warning ("%Hunused variable '%D'", &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Junused variable '%D'", decl, decl); } /* Generate RTL code to terminate a binding contour. @@ -3691,8 +3691,8 @@ expand_end_bindings (tree vars, int mark_ends, int dont_jump_in) that must be an error, because gotos without fixups come from outside all saved stack-levels. */ if (TREE_ADDRESSABLE (chain->label)) - error ("%Hlabel '%D' used before containing binding contour", - &DECL_SOURCE_LOCATION (chain->label), chain->label); + error ("%Jlabel '%D' used before containing binding contour", + chain->label, chain->label); } } diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index d1a856983a5..728b70bf9c6 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -516,11 +516,10 @@ layout_decl (tree decl, unsigned int known_align) int size_as_int = TREE_INT_CST_LOW (size); if (compare_tree_int (size, size_as_int) == 0) - warning ("%Hsize of '%D' is %d bytes", - &DECL_SOURCE_LOCATION (decl), decl, size_as_int); + warning ("%Jsize of '%D' is %d bytes", decl, decl, size_as_int); else - warning ("size of '%D' is larger than %d bytes", - &DECL_SOURCE_LOCATION (decl), decl, larger_than_size); + warning ("%Jsize of '%D' is larger than %d bytes", + decl, decl, larger_than_size); } } @@ -885,11 +884,11 @@ place_field (record_layout_info rli, tree field) if (TYPE_ALIGN (type) > desired_align) { if (STRICT_ALIGNMENT) - warning ("%Hpacked attribute causes inefficient alignment " - "for '%D'", &DECL_SOURCE_LOCATION (field), field); + warning ("%Jpacked attribute causes inefficient alignment " + "for '%D'", field, field); else - warning ("%Hpacked attribute is unnecessary for '%D'", - &DECL_SOURCE_LOCATION (field), field); + warning ("%Jpacked attribute is unnecessary for '%D'", + field, field); } } else @@ -904,8 +903,7 @@ place_field (record_layout_info rli, tree field) Bump the cumulative size to multiple of field alignment. */ if (warn_padded) - warning ("%Hpadding struct to align '%D'", - &DECL_SOURCE_LOCATION (field), field); + warning ("%Jpadding struct to align '%D'", field, field); /* If the alignment is still within offset_align, just align the bit position. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1ba55f62ebb..a65e623fd40 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-09-20 Richard Henderson + + * gcc.dg/format/gcc_diag-1.c: Add tests for %J. + 2003-09-20 Roger Sayle * gcc.c-torture/execute/20030920-1.c: New test case. diff --git a/gcc/testsuite/gcc.dg/format/gcc_diag-1.c b/gcc/testsuite/gcc.dg/format/gcc_diag-1.c index 7cf18c1b15f..69e572e7385 100644 --- a/gcc/testsuite/gcc.dg/format/gcc_diag-1.c +++ b/gcc/testsuite/gcc.dg/format/gcc_diag-1.c @@ -60,6 +60,9 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p, diag ("%H", loc); cdiag ("%H", loc); cxxdiag ("%H", loc); + diag ("%J", t1); + cdiag ("%J", t1); + cxxdiag ("%J", t1); cdiag ("%D%F%T", t1, t1, t1); cdiag ("%D%D%D%D", t1, t2, *t3, t4[5]); @@ -83,12 +86,18 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p, diag ("%H"); /* { dg-warning "format" "missing arg" } */ cdiag ("%H"); /* { dg-warning "format" "missing arg" } */ cxxdiag ("%H"); /* { dg-warning "format" "missing arg" } */ + diag ("%J"); /* { dg-warning "format" "missing arg" } */ + cdiag ("%J"); /* { dg-warning "format" "missing arg" } */ + cxxdiag ("%J"); /* { dg-warning "format" "missing arg" } */ diag ("%H", i); /* { dg-warning "format" "wrong arg" } */ cdiag ("%H", i); /* { dg-warning "format" "wrong arg" } */ cxxdiag ("%H", i); /* { dg-warning "format" "wrong arg" } */ diag ("%H", p); /* { dg-warning "format" "wrong arg" } */ cdiag ("%H", p); /* { dg-warning "format" "wrong arg" } */ cxxdiag ("%H", p); /* { dg-warning "format" "wrong arg" } */ + diag ("%J", loc); /* { dg-warning "format" "wrong arg" } */ + cdiag ("%J", loc); /* { dg-warning "format" "wrong arg" } */ + cxxdiag ("%J", loc); /* { dg-warning "format" "wrong arg" } */ diag ("%#H", loc); /* { dg-warning "format" "bogus modifier" } */ cdiag ("%#H", loc); /* { dg-warning "format" "bogus modifier" } */ cxxdiag ("%#H", loc); /* { dg-warning "format" "bogus modifier" } */ diff --git a/gcc/toplev.c b/gcc/toplev.c index 91409bf7134..03485bc8aed 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1663,11 +1663,9 @@ check_global_declarations (tree *vec, int len) && ! TREE_PUBLIC (decl)) { if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) - pedwarn ("%H'%F' used but never defined", - &DECL_SOURCE_LOCATION (decl), decl); + pedwarn ("%J'%F' used but never defined", decl, decl); else - warning ("%H'%F' declared `static' but never defined", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%J'%F' declared `static' but never defined", decl, decl); /* This symbol is effectively an "extern" declaration now. */ TREE_PUBLIC (decl) = 1; assemble_external (decl); @@ -1688,8 +1686,7 @@ check_global_declarations (tree *vec, int len) && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl)) /* Otherwise, ask the language. */ && (*lang_hooks.decls.warn_unused_global) (decl)) - warning ("%H'%D' defined but not used", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%J'%D' defined but not used", decl, decl); /* Avoid confusing the debug information machinery when there are errors. */ @@ -2575,11 +2572,8 @@ rest_of_handle_inlining (tree decl) { if (warn_inline && lose && DECL_INLINE (decl)) { - char *msg = xmalloc (2 + strlen (lose) + 1); - msg[0] = '%'; - msg[1] = 'H'; - strcpy(msg + 2, lose); - warning (msg, &DECL_SOURCE_LOCATION (decl)); + char *msg = concat ("%J", lose, NULL); + warning (msg, decl); free (msg); } DECL_ABSTRACT_ORIGIN (decl) = 0; diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 8a435a62de1..e4e24b2b3b2 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -38,6 +38,8 @@ Boston, MA 02111-1307, USA. */ #include "splay-tree.h" #include "langhooks.h" #include "cgraph.h" +#include "intl.h" + /* This should be eventually be generalized to other languages, but this would require a shared function-as-trees infrastructure. */ @@ -896,9 +898,9 @@ inline_forbidden_p_1 (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED, if (alloca_call_p (node) && !lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn))) { - inline_forbidden_reason = "%Hfunction '%F' can never be inlined " - "because it uses alloca (override using " - "the always_inline attribute)"; + inline_forbidden_reason + = N_("%Jfunction '%F' can never be inlined because it uses " + "alloca (override using the always_inline attribute)"); return node; } t = get_callee_fndecl (node); @@ -909,8 +911,8 @@ inline_forbidden_p_1 (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED, /* We cannot inline functions that call setjmp. */ if (setjmp_call_p (t)) { - inline_forbidden_reason = "%Hfunction '%F' can never be inlined" - " because it uses setjmp"; + inline_forbidden_reason + = N_("%Jfunction '%F' can never be inlined because it uses setjmp"); return node; } @@ -921,8 +923,9 @@ inline_forbidden_p_1 (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED, case BUILT_IN_VA_START: case BUILT_IN_STDARG_START: { - inline_forbidden_reason = "%Hfunction '%F' can never be inlined " - "because it uses variable argument lists"; + inline_forbidden_reason + = N_("%Jfunction '%F' can never be inlined because it " + "uses variable argument lists"); return node; } case BUILT_IN_LONGJMP: @@ -935,9 +938,9 @@ inline_forbidden_p_1 (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED, /* ??? Need front end help to identify "regular" non-local goto. */ if (DECL_BUILT_IN_CLASS (t) == BUILT_IN_NORMAL) { - inline_forbidden_reason = "%Hfunction '%F' can never be inlined " - "because it uses setjmp-longjmp " - "exception handling"; + inline_forbidden_reason + = N_("%Jfunction '%F' can never be inlined " + "because it uses setjmp-longjmp exception handling"); return node; } } @@ -953,8 +956,9 @@ inline_forbidden_p_1 (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED, if (TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL && DECL_INITIAL (TREE_OPERAND (node, 0))) { - inline_forbidden_reason = "%Hfunction '%F' can never be inlined " - "because it contains a nested function"; + inline_forbidden_reason + = N_("%Jfunction '%F' can never be inlined " + "because it contains a nested function"); return node; } break; @@ -969,8 +973,9 @@ inline_forbidden_p_1 (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED, instantiations, which causes unexpected behavior. */ if (TREE_CODE (t) != LABEL_DECL) { - inline_forbidden_reason = "%Hfunction '%F' can never be inlined " - "because it contains a nonlocal label"; + inline_forbidden_reason + = N_("%Jfunction '%F' can never be inlined " + "because it contains a computed goto"); return node; } @@ -978,8 +983,9 @@ inline_forbidden_p_1 (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED, label. */ if (TREE_CODE (t) == LABEL_DECL && DECL_CONTEXT (t) != fn) { - inline_forbidden_reason = "%Hfunction '%F' can never be inlined " - "because it contains a nonlocal goto"; + inline_forbidden_reason + = N_("%Jfunction '%F' can never be inlined " + "because it contains a nonlocal goto"); return node; } @@ -1000,8 +1006,9 @@ inline_forbidden_p_1 (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED, for (t = TYPE_FIELDS (node); t; t = TREE_CHAIN (t)) if (variably_modified_type_p (TREE_TYPE (t))) { - inline_forbidden_reason = "%Hfunction '%F' can never be inlined " - "because it uses variable sized variables"; + inline_forbidden_reason + = N_("%Jfunction '%F' can never be inlined " + "because it uses variable sized variables"); return node; } #endif @@ -1089,8 +1096,7 @@ inlinable_function_p (tree fn) && !DECL_IN_SYSTEM_HEADER (fn)); if (do_warning) - warning (inline_forbidden_reason, - &DECL_SOURCE_LOCATION (fn), fn); + warning (inline_forbidden_reason, fn, fn); inlinable = false; } @@ -1302,8 +1308,7 @@ expand_call_inline (tree *tp, int *walk_subtrees, void *data) if (warn_inline && DECL_INLINE (fn) && DECL_DECLARED_INLINE_P (fn) && !DECL_IN_SYSTEM_HEADER (fn)) { - warning ("%Hinlining failed in call to '%F'", - &DECL_SOURCE_LOCATION (fn), fn); + warning ("%Jinlining failed in call to '%F'", fn, fn); warning ("called from here"); } return NULL_TREE; diff --git a/gcc/tree-optimize.c b/gcc/tree-optimize.c index 397bb490cb6..e6049cb2b29 100644 --- a/gcc/tree-optimize.c +++ b/gcc/tree-optimize.c @@ -183,16 +183,15 @@ tree_rest_of_compilation (tree fndecl, bool nested_p) && 0 < compare_tree_int (TYPE_SIZE_UNIT (ret_type), larger_than_size)) { - const location_t *locus = &DECL_SOURCE_LOCATION (fndecl); unsigned int size_as_int = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (ret_type)); if (compare_tree_int (TYPE_SIZE_UNIT (ret_type), size_as_int) == 0) - warning ("%Hsize of return value of '%D' is %u bytes", - locus, fndecl, size_as_int); + warning ("%Jsize of return value of '%D' is %u bytes", + fndecl, fndecl, size_as_int); else - warning ("%Hsize of return value of '%D' is larger than %wd bytes", - locus, fndecl, larger_than_size); + warning ("%Jsize of return value of '%D' is larger than %wd bytes", + fndecl, fndecl, larger_than_size); } } diff --git a/gcc/varasm.c b/gcc/varasm.c index d7c60682cd1..d0bdbc15bdc 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -432,8 +432,7 @@ named_section (tree decl, const char *name, int reloc) { flags = get_named_section_flags (name); if ((flags & SECTION_OVERRIDE) == 0) - error ("%H%D causes a section type conflict", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%J%D causes a section type conflict", decl, decl); } named_section_flags (name, flags); @@ -803,17 +802,15 @@ make_decl_rtl (tree decl, const char *asmspec) { /* First detect errors in declaring global registers. */ if (reg_number == -1) - error ("%Hregister name not specified for '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jregister name not specified for '%D'", decl, decl); else if (reg_number < 0) - error ("%Hinvalid register name for '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jinvalid register name for '%D'", decl, decl); else if (TYPE_MODE (TREE_TYPE (decl)) == BLKmode) - error ("%Hdata type of '%D' isn't suitable for a register", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jdata type of '%D' isn't suitable for a register", + decl, decl); else if (! HARD_REGNO_MODE_OK (reg_number, TYPE_MODE (TREE_TYPE (decl)))) - error ("%Hregister specified for '%D' isn't suitable for data type", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jregister specified for '%D' isn't suitable for data type", + decl, decl); /* Now handle properly declared static register variables. */ else { @@ -857,8 +854,7 @@ make_decl_rtl (tree decl, const char *asmspec) Also handle vars declared register invalidly. */ if (reg_number >= 0 || reg_number == -3) - error ("%Hregister name given for non-register variable '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jregister name given for non-register variable '%D'", decl, decl); /* Specifying a section attribute on a variable forces it into a non-.bss section, and thus it cannot be common. */ @@ -1380,9 +1376,7 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, if (!dont_output_data && DECL_SIZE (decl) == 0) { - error ("%Hstorage size of `%s' isn't known", - &DECL_SOURCE_LOCATION (decl), - IDENTIFIER_POINTER (DECL_NAME (decl))); + error ("%Jstorage size of `%D' isn't known", decl, decl); TREE_ASM_WRITTEN (decl) = 1; return; } @@ -1410,8 +1404,7 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, if (! dont_output_data && ! host_integerp (DECL_SIZE_UNIT (decl), 1)) { - error ("%Hsize of variable '%D' is too large", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jsize of variable '%D' is too large", decl, decl); return; } @@ -1437,9 +1430,9 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, #endif if (align > MAX_OFILE_ALIGNMENT) { - warning ("%Halignment of '%D' is greater than maximum object " - "file alignment. Using %d", &DECL_SOURCE_LOCATION (decl), - decl, MAX_OFILE_ALIGNMENT/BITS_PER_UNIT); + warning ("%Jalignment of '%D' is greater than maximum object " + "file alignment. Using %d", decl, decl, + MAX_OFILE_ALIGNMENT/BITS_PER_UNIT); align = MAX_OFILE_ALIGNMENT; } @@ -1505,9 +1498,8 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, #if !defined(ASM_OUTPUT_ALIGNED_COMMON) && !defined(ASM_OUTPUT_ALIGNED_DECL_COMMON) && !defined(ASM_OUTPUT_ALIGNED_BSS) if ((unsigned HOST_WIDE_INT) DECL_ALIGN (decl) / BITS_PER_UNIT > rounded) - warning ("%Hrequested alignment for '%D' is greater than " - "implemented alignment of %d", &DECL_SOURCE_LOCATION (decl), - decl, rounded); + warning ("%Jrequested alignment for '%D' is greater than " + "implemented alignment of %d", decl, decl, rounded); #endif /* If the target cannot output uninitialized but not common global data @@ -4213,17 +4205,16 @@ merge_weak (tree newdecl, tree olddecl) declare_weak because the NEWDECL and OLDDECL was not yet been merged; therefore, TREE_ASM_WRITTEN was not set. */ if (TREE_ASM_WRITTEN (olddecl)) - error ("%Hweak declaration of '%D' must precede definition", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + error ("%Jweak declaration of '%D' must precede definition", + newdecl, newdecl); /* If we've already generated rtl referencing OLDDECL, we may have done so in a way that will not function properly with a weak symbol. */ else if (TREE_USED (olddecl) && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl))) - warning ("%Hweak declaration of '%D' after first use results " - "in unspecified behavior", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + warning ("%Jweak declaration of '%D' after first use results " + "in unspecified behavior", newdecl, newdecl); if (SUPPORTS_WEAK) { @@ -4256,19 +4247,16 @@ void declare_weak (tree decl) { if (! TREE_PUBLIC (decl)) - error ("%Hweak declaration of '%D' must be public", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jweak declaration of '%D' must be public", decl, decl); else if (TREE_CODE (decl) == FUNCTION_DECL && TREE_ASM_WRITTEN (decl)) - error ("%Hweak declaration of '%D' must precede definition", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jweak declaration of '%D' must precede definition", decl, decl); else if (SUPPORTS_WEAK) { if (! DECL_WEAK (decl)) weak_decls = tree_cons (NULL, decl, weak_decls); } else - warning ("%Hweak declaration of '%D' not supported", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jweak declaration of '%D' not supported", decl, decl); mark_weak (decl); } -- cgit v1.2.1