1 /* RTL specific diagnostic subroutines for GCC
2 Copyright (C) 2001, 2002, 2003, 2004 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)
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, 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
23 #undef FLOAT /* This is for hpux. They should change hpux. */
24 #undef FFS /* Some systems define this in param.h. */
26 #include "coretypes.h"
29 #include "insn-attr.h"
30 #include "insn-config.h"
34 #include "diagnostic.h"
36 static location_t
location_for_asm (rtx
);
37 static void diagnostic_for_asm (rtx
, const char *, va_list *, diagnostic_t
) ATTRIBUTE_GCC_DIAG(2,0);
39 /* Figure the location of the given INSN. */
41 location_for_asm (rtx insn
)
43 rtx body
= PATTERN (insn
);
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
)
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);
62 #ifdef USE_MAPPED_LOCATION
63 loc
= ASM_OPERANDS_SOURCE_LOCATION (asmop
);
66 loc
.file
= ASM_OPERANDS_SOURCE_FILE (asmop
);
67 loc
.line
= ASM_OPERANDS_SOURCE_LINE (asmop
);
75 /* Report a diagnostic MESSAGE (an errror or a WARNING) at the line number
76 of the insn INSN. This is used only when INSN is an `asm' with operands,
77 and each ASM_OPERANDS records its own source file and line. */
79 diagnostic_for_asm (rtx insn
, const char *msg
, va_list *args_ptr
,
82 diagnostic_info diagnostic
;
84 diagnostic_set_info (&diagnostic
, msg
, args_ptr
,
85 location_for_asm (insn
), kind
);
86 report_diagnostic (&diagnostic
);
90 error_for_asm (rtx insn
, const char *gmsgid
, ...)
94 va_start (ap
, gmsgid
);
95 diagnostic_for_asm (insn
, gmsgid
, &ap
, DK_ERROR
);
100 warning_for_asm (rtx insn
, const char *gmsgid
, ...)
104 va_start (ap
, gmsgid
);
105 diagnostic_for_asm (insn
, gmsgid
, &ap
, DK_WARNING
);
110 _fatal_insn (const char *msgid
, rtx insn
, const char *file
, int line
,
111 const char *function
)
113 error ("%s", _(msgid
));
115 /* The above incremented error_count, but isn't an error that we want to
116 count, so reset it here. */
120 fancy_abort (file
, line
, function
);
124 _fatal_insn_not_found (rtx insn
, const char *file
, int line
,
125 const char *function
)
127 if (INSN_CODE (insn
) < 0)
128 _fatal_insn ("unrecognizable insn:", insn
, file
, line
, function
);
130 _fatal_insn ("insn does not satisfy its constraints:",
131 insn
, file
, line
, function
);