rtl-error.c revision 132718
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> 4 5This file is part of GCC. 6 7GCC is free software; you can redistribute it and/or modify 8it under the terms of the GNU General Public License as published by 9the Free Software Foundation; either version 2, or (at your option) 10any later version. 11 12GCC is distributed in the hope that it will be useful, 13but WITHOUT ANY WARRANTY; without even the implied warranty of 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15GNU General Public License for more details. 16 17You should have received a copy of the GNU General Public License 18along with GCC; see the file COPYING. If not, write to 19the Free Software Foundation, 59 Temple Place - Suite 330, 20Boston, 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" 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" 35 36static location_t location_for_asm (rtx); 37static void diagnostic_for_asm (rtx, const char *, va_list *, diagnostic_t); 38 39/* Figure the location of the given INSN. */ 40static location_t 41location_for_asm (rtx insn) 42{ 43 rtx body = PATTERN (insn); 44 rtx asmop; 45 location_t loc; 46 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; 60 61 if (asmop) 62 { 63 loc.file = ASM_OPERANDS_SOURCE_FILE (asmop); 64 loc.line = ASM_OPERANDS_SOURCE_LINE (asmop); 65 } 66 else 67 loc = input_location; 68 return loc; 69} 70 71/* Report a diagnostic MESSAGE (an errror or a WARNING) at the line number 72 of the insn INSN. This is used only when INSN is an `asm' with operands, 73 and each ASM_OPERANDS records its own source file and line. */ 74static void 75diagnostic_for_asm (rtx insn, const char *msg, va_list *args_ptr, 76 diagnostic_t kind) 77{ 78 diagnostic_info diagnostic; 79 80 diagnostic_set_info (&diagnostic, msg, args_ptr, 81 location_for_asm (insn), kind); 82 report_diagnostic (&diagnostic); 83} 84 85void 86error_for_asm (rtx insn, const char *msgid, ...) 87{ 88 va_list ap; 89 90 va_start (ap, msgid); 91 diagnostic_for_asm (insn, msgid, &ap, DK_ERROR); 92 va_end (ap); 93} 94 95void 96warning_for_asm (rtx insn, const char *msgid, ...) 97{ 98 va_list ap; 99 100 va_start (ap, msgid); 101 diagnostic_for_asm (insn, msgid, &ap, DK_WARNING); 102 va_end (ap); 103} 104 105void 106_fatal_insn (const char *msgid, rtx insn, const char *file, int line, 107 const char *function) 108{ 109 error ("%s", _(msgid)); 110 111 /* The above incremented error_count, but isn't an error that we want to 112 count, so reset it here. */ 113 errorcount--; 114 115 debug_rtx (insn); 116 fancy_abort (file, line, function); 117} 118 119void 120_fatal_insn_not_found (rtx insn, const char *file, int line, 121 const char *function) 122{ 123 if (INSN_CODE (insn) < 0) 124 _fatal_insn ("unrecognizable insn:", insn, file, line, function); 125 else 126 _fatal_insn ("insn does not satisfy its constraints:", 127 insn, file, line, function); 128} 129