* regclass.c (fix_register): Fix typo.
[official-gcc.git] / gcc / rtl-error.c
blobd9b9bb68f9bfc3e326d7d1ff78bb4a644b440057
1 /* RTL specific diagnostic subroutines for the GNU C compiler
2 Copyright (C) 2001 Free Software Foundation, Inc.
3 Contributed by Gabriel Dos Reis <gdr@codesourcery.com>
5 This file is part of GNU CC.
7 GNU CC 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 GNU CC 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 GNU CC; 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 "rtl.h"
27 #include "insn-attr.h"
28 #include "insn-config.h"
29 #include "input.h"
30 #include "toplev.h"
31 #include "intl.h"
32 #include "diagnostic.h"
34 static void file_and_line_for_asm PARAMS ((rtx, const char **, int *));
35 static void diagnostic_for_asm PARAMS ((rtx, const char *, va_list *, int));
37 /* Figure file and line of the given INSN. */
38 static void
39 file_and_line_for_asm (insn, pfile, pline)
40 rtx insn;
41 const char **pfile;
42 int *pline;
44 rtx body = PATTERN (insn);
45 rtx asmop;
47 /* Find the (or one of the) ASM_OPERANDS in the insn. */
48 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
49 asmop = SET_SRC (body);
50 else if (GET_CODE (body) == ASM_OPERANDS)
51 asmop = body;
52 else if (GET_CODE (body) == PARALLEL
53 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
54 asmop = SET_SRC (XVECEXP (body, 0, 0));
55 else if (GET_CODE (body) == PARALLEL
56 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
57 asmop = XVECEXP (body, 0, 0);
58 else
59 asmop = NULL;
61 if (asmop)
63 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
64 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
66 else
68 *pfile = input_filename;
69 *pline = lineno;
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, warn)
78 rtx insn;
79 const char *msg;
80 va_list *args_ptr;
81 int warn;
83 diagnostic_context dc;
85 set_diagnostic_context (&dc, msg, args_ptr, NULL, 0, warn);
86 file_and_line_for_asm (insn, &diagnostic_file_location (&dc),
87 &diagnostic_line_location (&dc));
88 report_diagnostic (&dc);
91 void
92 error_for_asm VPARAMS ((rtx insn, const char *msgid, ...))
94 #ifndef ANSI_PROTOTYPES
95 rtx insn;
96 const char *msgid;
97 #endif
98 va_list ap;
100 VA_START (ap, msgid);
102 #ifndef ANSI_PROTOTYPES
103 insn = va_arg (ap, rtx);
104 msgid = va_arg (ap, const char *);
105 #endif
107 diagnostic_for_asm (insn, msgid, &ap, /* warn = */ 0);
108 va_end (ap);
111 void
112 warning_for_asm VPARAMS ((rtx insn, const char *msgid, ...))
114 #ifndef ANSI_PROTOTYPES
115 rtx insn;
116 const char *msgid;
117 #endif
118 va_list ap;
120 VA_START (ap, msgid);
122 #ifndef ANSI_PROTOTYPES
123 insn = va_arg (ap, rtx);
124 msgid = va_arg (ap, const char *);
125 #endif
127 diagnostic_for_asm (insn, msgid, &ap, /* warn = */ 1);
128 va_end (ap);
131 void
132 _fatal_insn (msgid, insn, file, line, function)
133 const char *msgid;
134 rtx insn;
135 const char *file;
136 int line;
137 const char *function;
139 error ("%s", _(msgid));
141 /* The above incremented error_count, but isn't an error that we want to
142 count, so reset it here. */
143 errorcount--;
145 debug_rtx (insn);
146 fancy_abort (file, line, function);
149 void
150 _fatal_insn_not_found (insn, file, line, function)
151 rtx insn;
152 const char *file;
153 int line;
154 const char *function;
156 if (INSN_CODE (insn) < 0)
157 _fatal_insn ("Unrecognizable insn:", insn, file, line, function);
158 else
159 _fatal_insn ("Insn does not satisfy its constraints:",
160 insn, file, line, function);