]>
Commit | Line | Data |
---|---|---|
51dfd6a9 | 1 | /* RTL specific diagnostic subroutines for the GNU C compiler |
2617fe26 | 2 | Copyright (C) 2001, 2002 Free Software Foundation, Inc. |
51dfd6a9 | 3 | Contributed by Gabriel Dos Reis <gdr@codesourcery.com> |
4 | ||
049df704 | 5 | This file is part of GCC. |
51dfd6a9 | 6 | |
049df704 | 7 | GCC is free software; you can redistribute it and/or modify |
51dfd6a9 | 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. | |
11 | ||
049df704 | 12 | GCC is distributed in the hope that it will be useful, |
51dfd6a9 | 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. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
049df704 | 18 | along with GCC; see the file COPYING. If not, write to |
51dfd6a9 | 19 | the Free Software Foundation, 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
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" | |
805e22b2 | 26 | #include "coretypes.h" |
27 | #include "tm.h" | |
51dfd6a9 | 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" | |
35 | ||
36 | static void file_and_line_for_asm PARAMS ((rtx, const char **, int *)); | |
25e2ffe1 | 37 | static void diagnostic_for_asm PARAMS ((rtx, const char *, va_list *, |
38 | diagnostic_t)); | |
51dfd6a9 | 39 | |
40 | /* Figure file and line of the given INSN. */ | |
41 | static void | |
42 | file_and_line_for_asm (insn, pfile, pline) | |
43 | rtx insn; | |
44 | const char **pfile; | |
45 | int *pline; | |
46 | { | |
47 | rtx body = PATTERN (insn); | |
48 | rtx asmop; | |
49 | ||
50 | /* Find the (or one of the) ASM_OPERANDS in the insn. */ | |
51 | if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) | |
52 | asmop = SET_SRC (body); | |
53 | else if (GET_CODE (body) == ASM_OPERANDS) | |
54 | asmop = body; | |
55 | else if (GET_CODE (body) == PARALLEL | |
56 | && GET_CODE (XVECEXP (body, 0, 0)) == SET) | |
57 | asmop = SET_SRC (XVECEXP (body, 0, 0)); | |
58 | else if (GET_CODE (body) == PARALLEL | |
59 | && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS) | |
60 | asmop = XVECEXP (body, 0, 0); | |
61 | else | |
62 | asmop = NULL; | |
63 | ||
64 | if (asmop) | |
65 | { | |
66 | *pfile = ASM_OPERANDS_SOURCE_FILE (asmop); | |
67 | *pline = ASM_OPERANDS_SOURCE_LINE (asmop); | |
68 | } | |
69 | else | |
70 | { | |
71 | *pfile = input_filename; | |
72 | *pline = lineno; | |
73 | } | |
74 | } | |
75 | ||
76 | /* Report a diagnostic MESSAGE (an errror or a WARNING) at the line number | |
77 | of the insn INSN. This is used only when INSN is an `asm' with operands, | |
78 | and each ASM_OPERANDS records its own source file and line. */ | |
79 | static void | |
25e2ffe1 | 80 | diagnostic_for_asm (insn, msg, args_ptr, kind) |
51dfd6a9 | 81 | rtx insn; |
82 | const char *msg; | |
83 | va_list *args_ptr; | |
25e2ffe1 | 84 | diagnostic_t kind; |
51dfd6a9 | 85 | { |
25e2ffe1 | 86 | diagnostic_info diagnostic; |
51dfd6a9 | 87 | |
25e2ffe1 | 88 | diagnostic_set_info (&diagnostic, msg, args_ptr, NULL, 0, kind); |
89 | file_and_line_for_asm (insn, &diagnostic.location.file, | |
90 | &diagnostic.location.line); | |
91 | report_diagnostic (&diagnostic); | |
51dfd6a9 | 92 | } |
93 | ||
94 | void | |
95 | error_for_asm VPARAMS ((rtx insn, const char *msgid, ...)) | |
96 | { | |
0903457a | 97 | VA_OPEN (ap, msgid); |
98 | VA_FIXEDARG (ap, rtx, insn); | |
99 | VA_FIXEDARG (ap, const char *, msgid); | |
51dfd6a9 | 100 | |
25e2ffe1 | 101 | diagnostic_for_asm (insn, msgid, &ap, DK_ERROR); |
0903457a | 102 | VA_CLOSE (ap); |
51dfd6a9 | 103 | } |
104 | ||
105 | void | |
106 | warning_for_asm VPARAMS ((rtx insn, const char *msgid, ...)) | |
107 | { | |
0903457a | 108 | VA_OPEN (ap, msgid); |
109 | VA_FIXEDARG (ap, rtx, insn); | |
110 | VA_FIXEDARG (ap, const char *, msgid); | |
51dfd6a9 | 111 | |
25e2ffe1 | 112 | diagnostic_for_asm (insn, msgid, &ap, DK_WARNING); |
0903457a | 113 | VA_CLOSE (ap); |
51dfd6a9 | 114 | } |
115 | ||
116 | void | |
117 | _fatal_insn (msgid, insn, file, line, function) | |
118 | const char *msgid; | |
119 | rtx insn; | |
120 | const char *file; | |
121 | int line; | |
122 | const char *function; | |
123 | { | |
124 | error ("%s", _(msgid)); | |
125 | ||
126 | /* The above incremented error_count, but isn't an error that we want to | |
127 | count, so reset it here. */ | |
128 | errorcount--; | |
129 | ||
130 | debug_rtx (insn); | |
131 | fancy_abort (file, line, function); | |
132 | } | |
133 | ||
134 | void | |
135 | _fatal_insn_not_found (insn, file, line, function) | |
136 | rtx insn; | |
137 | const char *file; | |
138 | int line; | |
139 | const char *function; | |
140 | { | |
141 | if (INSN_CODE (insn) < 0) | |
cb8bacb6 | 142 | _fatal_insn ("unrecognizable insn:", insn, file, line, function); |
51dfd6a9 | 143 | else |
cb8bacb6 | 144 | _fatal_insn ("insn does not satisfy its constraints:", |
51dfd6a9 | 145 | insn, file, line, function); |
146 | } | |
147 |