Missed one in last change.
[official-gcc.git] / gcc / rtl-error.c
blob028cedd2ca1400d8c3e27a1e2ec7d73620089e1f
1 /* RTL specific diagnostic subroutines for GCC
2 Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
3 Contributed by Gabriel Dos Reis <gdr@codesourcery.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 #include "config.h"
23 #undef FLOAT /* This is for hpux. They should change hpux. */
24 #undef FFS /* Some systems define this in param.h. */
25 #include "system.h"
26 #include "coretypes.h"
27 #include "tm.h"
28 #include "rtl.h"
29 #include "insn-attr.h"
30 #include "insn-config.h"
31 #include "input.h"
32 #include "toplev.h"
33 #include "intl.h"
34 #include "diagnostic.h"
36 static location_t location_for_asm PARAMS ((rtx));
37 static void diagnostic_for_asm PARAMS ((rtx, const char *, va_list *,
38 diagnostic_t));
40 /* Figure the location of the given INSN. */
41 static location_t
42 location_for_asm (insn)
43 rtx insn;
45 rtx body = PATTERN (insn);
46 rtx asmop;
47 location_t loc;
49 /* Find the (or one of the) ASM_OPERANDS in the insn. */
50 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
51 asmop = SET_SRC (body);
52 else if (GET_CODE (body) == ASM_OPERANDS)
53 asmop = body;
54 else if (GET_CODE (body) == PARALLEL
55 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
56 asmop = SET_SRC (XVECEXP (body, 0, 0));
57 else if (GET_CODE (body) == PARALLEL
58 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
59 asmop = XVECEXP (body, 0, 0);
60 else
61 asmop = NULL;
63 if (asmop)
65 loc.file = ASM_OPERANDS_SOURCE_FILE (asmop);
66 loc.line = ASM_OPERANDS_SOURCE_LINE (asmop);
68 else
69 loc = input_location;
70 return loc;
73 /* Report a diagnostic MESSAGE (an errror or a WARNING) at the line number
74 of the insn INSN. This is used only when INSN is an `asm' with operands,
75 and each ASM_OPERANDS records its own source file and line. */
76 static void
77 diagnostic_for_asm (insn, msg, args_ptr, kind)
78 rtx insn;
79 const char *msg;
80 va_list *args_ptr;
81 diagnostic_t kind;
83 diagnostic_info diagnostic;
85 diagnostic_set_info (&diagnostic, msg, args_ptr,
86 location_for_asm (insn), kind);
87 report_diagnostic (&diagnostic);
90 void
91 error_for_asm (rtx insn, const char *msgid, ...)
93 va_list ap;
95 va_start (ap, msgid);
96 diagnostic_for_asm (insn, msgid, &ap, DK_ERROR);
97 va_end (ap);
100 void
101 warning_for_asm (rtx insn, const char *msgid, ...)
103 va_list ap;
105 va_start (ap, msgid);
106 diagnostic_for_asm (insn, msgid, &ap, DK_WARNING);
107 va_end (ap);
110 void
111 _fatal_insn (msgid, insn, file, line, function)
112 const char *msgid;
113 rtx insn;
114 const char *file;
115 int line;
116 const char *function;
118 error ("%s", _(msgid));
120 /* The above incremented error_count, but isn't an error that we want to
121 count, so reset it here. */
122 errorcount--;
124 debug_rtx (insn);
125 fancy_abort (file, line, function);
128 void
129 _fatal_insn_not_found (insn, file, line, function)
130 rtx insn;
131 const char *file;
132 int line;
133 const char *function;
135 if (INSN_CODE (insn) < 0)
136 _fatal_insn ("unrecognizable insn:", insn, file, line, function);
137 else
138 _fatal_insn ("insn does not satisfy its constraints:",
139 insn, file, line, function);