diagnostic.h (diagnostic_set_info): Replace file and lineno parameters with a location_t.
authorNathan Sidwell <nathan@codesourcery.com>
Sat, 28 Jun 2003 16:23:29 +0000 (16:23 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Sat, 28 Jun 2003 16:23:29 +0000 (16:23 +0000)
* diagnostic.h (diagnostic_set_info): Replace file and lineno
parameters with a location_t.
* diagnostic.c (diagnostic_set_info): Replace file and lineno
parameters with a location_t.
(inform, warning, pedwarn, error, sorry, fatal_error,
internal_error, warning_with_decl, pedwarn_with_decl,
error_with_decl): Adjust.
* c-error.c (pedwarn_c99): Adjust.
* c-format.c (status_warning): Adjust.
* rtl-error.c (file_and_line_for_asm): Rename to ...
(location_for_asm): Return a location_t.
(diagnostic_for_asm): Adjust.

* cp/cp-tree.h (cp_line_of, cp_file_of): Remove.
* cp/error.c (cp_line_of, cp_file_of): Merge into ...
(location_of): ... here. Make static, return a location_t.
(cp_error_at, cp_warning_at, cp_pedwarn_at): Adjust.

* testsuite/g++.old-deja/g++.robertl/eb133.C: Set expected line
number.
* testsuite/g++.old-deja/g++.robertl/eb133a.C: Likewise.
* testsuite/g++.old-deja/g++.robertl/eb133b.C: Likewise.

From-SVN: r68643

13 files changed:
gcc/ChangeLog
gcc/c-errors.c
gcc/c-format.c
gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/error.c
gcc/diagnostic.c
gcc/diagnostic.h
gcc/rtl-error.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.robertl/eb133.C
gcc/testsuite/g++.old-deja/g++.robertl/eb133a.C
gcc/testsuite/g++.old-deja/g++.robertl/eb133b.C

index d2c9163617a942e9aed4529af4ac2fa687234b88..5a31bb03b166fc8603dd2ea9779552a9b8f7d8de 100644 (file)
@@ -1,3 +1,18 @@
+2003-06-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * diagnostic.h (diagnostic_set_info): Replace file and lineno
+       parameters with a location_t.
+       * diagnostic.c (diagnostic_set_info): Replace file and lineno
+       parameters with a location_t.
+       (inform, warning, pedwarn, error, sorry, fatal_error,
+       internal_error, warning_with_decl, pedwarn_with_decl,
+       error_with_decl): Adjust.
+       * c-error.c (pedwarn_c99): Adjust.
+       * c-format.c (status_warning): Adjust.
+       * rtl-error.c (file_and_line_for_asm): Rename to ...
+       (location_for_asm): Return a location_t.
+       (diagnostic_for_asm): Adjust.
+
 2003-06-28  Neil Booth  <neil@daikokuya.co.uk>
 
        * cpptrad.c (skip_macro_block_comment): New.
index de24a04afc6fe01cb77d2b5d60faf95169edb6f5..2a2fdc0c440cf87f22af9e44c690f6e57d4f0c6d 100644 (file)
@@ -38,7 +38,7 @@ pedwarn_c99 (const char *msgid, ...)
   va_list ap;
   
   va_start (ap, msgid);
-  diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line,
+  diagnostic_set_info (&diagnostic, msgid, &ap, input_location,
                        flag_isoc99 ? pedantic_error_kind () : DK_WARNING);
   report_diagnostic (&diagnostic);
   va_end (ap);
index 5bae1c21b4a0b0ee2c845e050311234bef6dd61e..dc17f0e9f8b4d67ff009b52315a6e73c4ff0b2c5 100644 (file)
@@ -1004,7 +1004,7 @@ status_warning (int *status, const char *msgid, ...)
     {
       /* This duplicates the warning function behavior.  */
       diagnostic_set_info (&diagnostic, _(msgid), &ap,
-                          input_filename, input_line, DK_WARNING);
+                          input_location, DK_WARNING);
       report_diagnostic (&diagnostic);
     }
 
index 41ed2699640f9d745e12f872c87e1d05a77c447b..16a909e7735aa10ebe605473dc21aa7d276525d3 100644 (file)
@@ -1,3 +1,10 @@
+2003-06-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * cp-tree.h (cp_line_of, cp_file_of): Remove.
+       * error.c (cp_line_of, cp_file_of): Merge into ...
+       (location_of): ... here. Make static, return a location_t.
+       (cp_error_at, cp_warning_at, cp_pedwarn_at): Adjust.
+
 2003-06-28  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/10784
index 0e3a97115f407c853af3cada50993cfd561fa16a..51243f92dae07fd5376c405a33adf6fa6ee1e42a 100644 (file)
@@ -3820,8 +3820,6 @@ extern const char *decl_as_string         (tree, int);
 extern const char *expr_as_string              (tree, int);
 extern const char *context_as_string            (tree, int);
 extern const char *lang_decl_name              (tree, int);
-extern const char *cp_file_of                  (tree);
-extern int cp_line_of                          (tree);
 extern const char *language_to_string           (enum languages, int);
 extern void print_instantiation_context         (void);
 
index cb7c44fb9eedd3ad9e72690c0ba198f8b3a01b60..a5420a7d0b5cecacae4768c754c596801ffd8a5a 100644 (file)
@@ -113,6 +113,7 @@ static bool cp_printer (output_buffer *, text_info *);
 static void print_non_consecutive_character (output_buffer *, int);
 static void print_integer (output_buffer *, HOST_WIDE_INT);
 static tree locate_error (const char *, va_list);
+static location_t location_of (tree);
 
 void
 init_error (void)
@@ -2121,40 +2122,17 @@ lang_decl_name (tree decl, int v)
   return output_finalize_message (scratch_buffer);
 }
 
-const char *
-cp_file_of (tree t)
+static location_t
+location_of (tree t)
 {
   if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (t))
-    return DECL_SOURCE_FILE (DECL_CONTEXT (t));
+    t = DECL_CONTEXT (t);
   else if (TYPE_P (t))
-    return DECL_SOURCE_FILE (TYPE_MAIN_DECL (t));
-  else if (TREE_CODE (t) == OVERLOAD)
-    return DECL_SOURCE_FILE (OVL_FUNCTION (t));
-  else
-    return DECL_SOURCE_FILE (t);
-}
-
-int
-cp_line_of (tree t)
-{
-  int line = 0;
-  if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (t))
-    line = DECL_SOURCE_LINE (DECL_CONTEXT (t));
-  if (TREE_CODE (t) == TYPE_DECL && DECL_ARTIFICIAL (t)
-      && TYPE_MAIN_DECL (TREE_TYPE (t)))
-    t = TREE_TYPE (t);
-
-  if (TYPE_P (t))
-    line = DECL_SOURCE_LINE (TYPE_MAIN_DECL (t));
+    t = TYPE_MAIN_DECL (t);
   else if (TREE_CODE (t) == OVERLOAD)
-    line = DECL_SOURCE_LINE (OVL_FUNCTION (t));
-  else
-    line = DECL_SOURCE_LINE (t);
-
-  if (line == 0)
-    return input_line;
-
-  return line;
+    t = OVL_FUNCTION (t);
+  
+  return DECL_SOURCE_LOCATION (t);
 }
 
 /* Now the interfaces from error et al to dump_type et al. Each takes an
@@ -2612,7 +2590,7 @@ cp_error_at (const char *msgid, ...)
 
   va_start (ap, msgid);
   diagnostic_set_info (&diagnostic, msgid, &ap,
-                       cp_file_of (here), cp_line_of (here), DK_ERROR);
+                       location_of (here), DK_ERROR);
   report_diagnostic (&diagnostic);
   va_end (ap);
 }
@@ -2630,7 +2608,7 @@ cp_warning_at (const char *msgid, ...)
 
   va_start (ap, msgid);
   diagnostic_set_info (&diagnostic, msgid, &ap,
-                       cp_file_of (here), cp_line_of (here), DK_WARNING);
+                       location_of (here), DK_WARNING);
   report_diagnostic (&diagnostic);
   va_end (ap);
 }
@@ -2648,8 +2626,7 @@ cp_pedwarn_at (const char *msgid, ...)
 
   va_start (ap, msgid);
   diagnostic_set_info (&diagnostic, msgid, &ap,
-                       cp_file_of (here), cp_line_of (here),
-                       pedantic_error_kind());
+                       location_of (here), pedantic_error_kind());
   report_diagnostic (&diagnostic);
   va_end (ap);
 }
index 8e22a4819f58d9a08f8d455830dbf5f7f569963d..1312ca9924e5300088fab0245e63428afdc2263b 100644 (file)
@@ -761,19 +761,16 @@ text_specifies_location (text_info *text, location_t *locus)
 
 void
 diagnostic_set_info (diagnostic_info *diagnostic, const char *msgid,
-                    va_list *args, const char *file,  int line,
+                    va_list *args, location_t location,
                     diagnostic_t kind)
 {
   diagnostic->message.err_no = errno;
   diagnostic->message.args_ptr = args;
   diagnostic->message.format_spec = _(msgid);
   /* If the diagnostic message doesn't specify a location,
-     use FILE and LINE.  */
+     use LOCATION.  */
   if (!text_specifies_location (&diagnostic->message, &diagnostic->location))
-    {
-      diagnostic->location.file = file;
-      diagnostic->location.line = line;
-    }
+    diagnostic->location = location;
   diagnostic->kind = kind;
 }
 
@@ -1134,8 +1131,7 @@ inform (const char *msgid, ...)
   va_list ap;
 
   va_start (ap, msgid);
-  diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line,
-                       DK_NOTE);
+  diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_NOTE);
   report_diagnostic (&diagnostic);
   va_end (ap);
 }
@@ -1149,8 +1145,7 @@ warning (const char *msgid, ...)
   va_list ap;
 
   va_start (ap, msgid);
-  diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line,
-                       DK_WARNING);
+  diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_WARNING);
   report_diagnostic (&diagnostic);
   va_end (ap);
 }
@@ -1170,8 +1165,8 @@ pedwarn (const char *msgid, ...)
   va_list ap;
 
   va_start (ap, msgid);
-  diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line,
-                       pedantic_error_kind ());
+  diagnostic_set_info (&diagnostic, msgid, &ap, input_location,
+                      pedantic_error_kind ());
   report_diagnostic (&diagnostic);
   va_end (ap);
 }
@@ -1185,8 +1180,7 @@ error (const char *msgid, ...)
   va_list ap;
 
   va_start (ap, msgid);
-  diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line,
-                       DK_ERROR);
+  diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_ERROR);
   report_diagnostic (&diagnostic);
   va_end (ap);
 }
@@ -1201,8 +1195,7 @@ sorry (const char *msgid, ...)
   va_list ap;
 
   va_start (ap, msgid);
-  diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line,
-                      DK_SORRY);
+  diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_SORRY);
   report_diagnostic (&diagnostic);
   va_end (ap);
 }
@@ -1217,8 +1210,7 @@ fatal_error (const char *msgid, ...)
   va_list ap;
 
   va_start (ap, msgid);
-  diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line,
-                       DK_FATAL);
+  diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_FATAL);
   report_diagnostic (&diagnostic);
   va_end (ap);
 
@@ -1237,8 +1229,7 @@ internal_error (const char *msgid, ...)
   va_list ap;
 
   va_start (ap, msgid);
-  diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line,
-                       DK_ICE);
+  diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_ICE);
   report_diagnostic (&diagnostic);
   va_end (ap);
 
@@ -1263,8 +1254,7 @@ warning_with_decl (tree decl, const char *msgid, ...)
     return;
 
   diagnostic_set_info (&diagnostic, msgid, &ap,
-                       DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl),
-                       DK_WARNING);
+                       DECL_SOURCE_LOCATION (decl), DK_WARNING);
   diagnostic_for_decl (global_dc, &diagnostic, decl);
   va_end (ap);
 }
@@ -1283,8 +1273,7 @@ pedwarn_with_decl (tree decl, const char *msgid, ...)
     return;
 
   diagnostic_set_info (&diagnostic, msgid, &ap,
-                       DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl),
-                       pedantic_error_kind ());
+                       DECL_SOURCE_LOCATION (decl), pedantic_error_kind ());
   diagnostic_for_decl (global_dc, &diagnostic, decl);
 
   va_end (ap);
@@ -1298,8 +1287,7 @@ error_with_decl (tree decl, const char *msgid, ...)
 
   va_start (ap, msgid);
   diagnostic_set_info (&diagnostic, msgid, &ap,
-                       DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl),
-                       DK_ERROR);
+                       DECL_SOURCE_LOCATION (decl), DK_ERROR);
   diagnostic_for_decl (global_dc, &diagnostic, decl);
   va_end (ap);
 }
index 80d6a44d68daee2b93a638ccd5322c4b4441e6b9..18a11b673541a783f29985e2f685d36fb6f04834 100644 (file)
@@ -298,7 +298,7 @@ extern void diagnostic_flush_buffer (diagnostic_context *);
 extern void diagnostic_report_diagnostic (diagnostic_context *,
                                          diagnostic_info *);
 extern void diagnostic_set_info (diagnostic_info *, const char *, va_list *,
-                                const char *, int, diagnostic_t);
+                                location_t, diagnostic_t);
 extern char *diagnostic_build_prefix (diagnostic_info *);
 
 /* Pure text formatting support functions.  */
index 5be5cd558491dee7d89ca0f5414dc371090eb0eb..028cedd2ca1400d8c3e27a1e2ec7d73620089e1f 100644 (file)
@@ -33,20 +33,19 @@ Boston, MA 02111-1307, USA.  */
 #include "intl.h"
 #include "diagnostic.h"
 
-static void file_and_line_for_asm PARAMS ((rtx, const char **, int *));
+static location_t location_for_asm PARAMS ((rtx));
 static void diagnostic_for_asm PARAMS ((rtx, const char *, va_list *,
                                         diagnostic_t));
 
-/* Figure file and line of the given INSN.  */
-static void
-file_and_line_for_asm (insn, pfile, pline)
+/* Figure the location of the given INSN.  */
+static location_t
+location_for_asm (insn)
      rtx insn;
-     const char **pfile;
-     int *pline;
 {
   rtx body = PATTERN (insn);
   rtx asmop;
-
+  location_t loc;
+  
   /* Find the (or one of the) ASM_OPERANDS in the insn.  */
   if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
     asmop = SET_SRC (body);
@@ -63,14 +62,12 @@ file_and_line_for_asm (insn, pfile, pline)
 
   if (asmop)
     {
-      *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
-      *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
+      loc.file = ASM_OPERANDS_SOURCE_FILE (asmop);
+      loc.line = ASM_OPERANDS_SOURCE_LINE (asmop);
     }
   else
-    {
-      *pfile = input_filename;
-      *pline = input_line;
-    }
+    loc = input_location;
+  return loc;
 }
 
 /* Report a diagnostic MESSAGE (an errror or a WARNING) at the line number
@@ -84,10 +81,9 @@ diagnostic_for_asm (insn, msg, args_ptr, kind)
      diagnostic_t kind;
 {
   diagnostic_info diagnostic;
-
-  diagnostic_set_info (&diagnostic, msg, args_ptr, NULL, 0, kind);
-  file_and_line_for_asm (insn, &diagnostic.location.file,
-                         &diagnostic.location.line);
+  
+  diagnostic_set_info (&diagnostic, msg, args_ptr,
+                      location_for_asm (insn), kind);
   report_diagnostic (&diagnostic);
 }
 
index bc2058a0ee2f0521183efe8f8fe3d89b64500844..3af77db3dcb9f8757efa92eb10c79dcf520ac59d 100644 (file)
@@ -1,3 +1,9 @@
+2003-06-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * g++.old-deja/g++.robertl/eb133.C: Set expected line number.
+       * g++.old-deja/g++.robertl/eb133a.C: Likewise.
+       * g++.old-deja/g++.robertl/eb133b.C: Likewise.
+
 2003-06-28  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.c-torture/execute/builtins/string-8.c: New test.
index 685fdf1867445b2063c8115a6003e20879b22bfc..b6002248d558f01d3ee94a80d34fd3f2218c6f8f 100644 (file)
@@ -3,16 +3,17 @@
 // From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> 
 // Reported against EGCS snaps 98/06/28.
 
+// { dg-error "forward declaration" "" { target *-*-* } 0 }
+
 using namespace std;
 
 int main()
 {
        try {
        }
-       catch (bad_alloc) { // { dg-error "" } parse error
+       catch (bad_alloc) { // { dg-error "invalid use" }
                return 1;
        }
        return 0;
 }
 
-       
index eb6c72d20a606fe709619ab92cb4d466dff7c366..f9265851d11c8b50edc23d19832f5e25703fe039 100644 (file)
@@ -3,6 +3,8 @@
 // From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> 
 // Reported against EGCS snaps 98/06/28.
 
+// { dg-error "forward declaration" "" { target *-*-* } 0 }
+
 int main()
 {
        try {
index 685fdf1867445b2063c8115a6003e20879b22bfc..82605146a191cb50e1f61b8fb78ea85911a9ecd3 100644 (file)
@@ -3,13 +3,15 @@
 // From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> 
 // Reported against EGCS snaps 98/06/28.
 
+// { dg-error "forward declaration" "" { target *-*-* } 0 }
+
 using namespace std;
 
 int main()
 {
        try {
        }
-       catch (bad_alloc) { // { dg-error "" } parse error
+       catch (bad_alloc) { // { dg-error "invalid use" }
                return 1;
        }
        return 0;