aboutsummaryrefslogtreecommitdiff
path: root/gcc/java
diff options
context:
space:
mode:
authorRanjit Mathew <rmathew@hotmail.com>2004-10-05 17:07:14 +0000
committerRanjit Mathew <rmathew@gcc.gnu.org>2004-10-05 17:07:14 +0000
commit5544148e928e9fb556792281b5a856f89d265d77 (patch)
tree8e39e022d3dc1848c313c01830d01d75c059c4b1 /gcc/java
parent73407061a1bd7debdc883bd1cd1addc7dd5c06f6 (diff)
downloadgcc-5544148e928e9fb556792281b5a856f89d265d77.zip
gcc-5544148e928e9fb556792281b5a856f89d265d77.tar.gz
gcc-5544148e928e9fb556792281b5a856f89d265d77.tar.bz2
Prepare for %q, %< and %> in diagnostic message strings.
* java-tree.h (parse_error_context): remove ATTRIBUTE_PRINTF_2. Name second parameter 'msgid'. * parse.y: Additionally include pretty-print.h and diagnostic.h. (issue_warning_error_from_context): Use pretty-printer functions instead of vsprintf for constructing formatted messages. Rename parameter 'msg' to 'msgid'. (parse_error_context): Rename parameter 'msg' to 'msgid'. (parse_warning_context): Likewise. From-SVN: r88562
Diffstat (limited to 'gcc/java')
-rw-r--r--gcc/java/ChangeLog12
-rw-r--r--gcc/java/java-tree.h3
-rw-r--r--gcc/java/parse.y31
3 files changed, 34 insertions, 12 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 5426a7f..56ac57e 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,15 @@
+2004-10-05 Ranjit Mathew <rmathew@hotmail.com>
+
+ Prepare for %q, %< and %> in diagnostic message strings.
+ * java-tree.h (parse_error_context): remove ATTRIBUTE_PRINTF_2.
+ Name second parameter 'msgid'.
+ * parse.y: Additionally include pretty-print.h and diagnostic.h.
+ (issue_warning_error_from_context): Use pretty-printer functions
+ instead of vsprintf for constructing formatted messages. Rename
+ parameter 'msg' to 'msgid'.
+ (parse_error_context): Rename parameter 'msg' to 'msgid'.
+ (parse_warning_context): Likewise.
+
2004-10-05 Andrew Haley <aph@redhat.com>
PR java/17779
diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index 991eb03..a43bc2e 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -1247,8 +1247,7 @@ extern tree emit_symbol_table (tree, tree, tree, tree, tree);
extern void lang_init_source (int);
extern void write_classfile (tree);
extern char *print_int_node (tree);
-extern void parse_error_context (tree cl, const char *, ...)
- ATTRIBUTE_PRINTF_2;
+extern void parse_error_context (tree cl, const char *msgid, ...);
extern void finish_class (void);
extern void java_layout_seen_class_methods (void);
extern void check_for_initialization (tree, tree);
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index dc62f86..5544cae 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -57,6 +57,8 @@ definitions and other extensions. */
#include "real.h"
#include "obstack.h"
#include "toplev.h"
+#include "pretty-print.h"
+#include "diagnostic.h"
#include "flags.h"
#include "java-tree.h"
#include "jcf.h"
@@ -3141,7 +3143,7 @@ issue_warning_error_from_context (
#else
tree cl,
#endif
- const char *msg, va_list ap)
+ const char *msgid, va_list ap)
{
#ifdef USE_MAPPED_LOCATION
source_location saved_location = input_location;
@@ -3151,7 +3153,16 @@ issue_warning_error_from_context (
const char *saved = ctxp->filename, *saved_input_filename;
#endif
char buffer [4096];
- vsprintf (buffer, msg, ap);
+ text_info text;
+
+ text.err_no = errno;
+ text.args_ptr = &ap;
+ text.format_spec = msgid;
+ pp_format_text (global_dc->printer, &text);
+ strncpy (buffer, pp_formatted_text (global_dc->printer), sizeof (buffer) - 1);
+ buffer[sizeof (buffer) - 1] = '\0';
+ pp_clear_output_area (global_dc->printer);
+
force_error = 1;
#ifdef USE_MAPPED_LOCATION
@@ -3188,14 +3199,14 @@ issue_warning_error_from_context (
FUTURE/FIXME: change cl to be a source_location. */
void
-parse_error_context (tree cl, const char *msg, ...)
+parse_error_context (tree cl, const char *msgid, ...)
{
va_list ap;
- va_start (ap, msg);
+ va_start (ap, msgid);
#ifdef USE_MAPPED_LOCATION
- issue_warning_error_from_context (EXPR_LOCATION (cl), msg, ap);
+ issue_warning_error_from_context (EXPR_LOCATION (cl), msgid, ap);
#else
- issue_warning_error_from_context (cl, msg, ap);
+ issue_warning_error_from_context (cl, msgid, ap);
#endif
va_end (ap);
}
@@ -3204,16 +3215,16 @@ parse_error_context (tree cl, const char *msg, ...)
FUTURE/FIXME: change cl to be a source_location. */
static void
-parse_warning_context (tree cl, const char *msg, ...)
+parse_warning_context (tree cl, const char *msgid, ...)
{
va_list ap;
- va_start (ap, msg);
+ va_start (ap, msgid);
do_warning = 1;
#ifdef USE_MAPPED_LOCATION
- issue_warning_error_from_context (EXPR_LOCATION (cl), msg, ap);
+ issue_warning_error_from_context (EXPR_LOCATION (cl), msgid, ap);
#else
- issue_warning_error_from_context (cl, msg, ap);
+ issue_warning_error_from_context (cl, msgid, ap);
#endif
do_warning = 0;
va_end (ap);