rtl-error.c revision 117395
190075Sobrien/* RTL specific diagnostic subroutines for the GNU C compiler 2117395Skan Copyright (C) 2001, 2002 Free Software Foundation, Inc. 390075Sobrien Contributed by Gabriel Dos Reis <gdr@codesourcery.com> 490075Sobrien 590075SobrienThis file is part of GCC. 690075Sobrien 790075SobrienGCC is free software; you can redistribute it and/or modify 890075Sobrienit under the terms of the GNU General Public License as published by 990075Sobrienthe Free Software Foundation; either version 2, or (at your option) 1090075Sobrienany later version. 1190075Sobrien 1290075SobrienGCC is distributed in the hope that it will be useful, 1390075Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of 1490075SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1590075SobrienGNU General Public License for more details. 1690075Sobrien 1790075SobrienYou should have received a copy of the GNU General Public License 1890075Sobrienalong with GCC; see the file COPYING. If not, write to 1990075Sobrienthe Free Software Foundation, 59 Temple Place - Suite 330, 2090075SobrienBoston, MA 02111-1307, USA. */ 2190075Sobrien 2290075Sobrien#include "config.h" 2390075Sobrien#undef FLOAT /* This is for hpux. They should change hpux. */ 2490075Sobrien#undef FFS /* Some systems define this in param.h. */ 2590075Sobrien#include "system.h" 2690075Sobrien#include "rtl.h" 2790075Sobrien#include "insn-attr.h" 2890075Sobrien#include "insn-config.h" 2990075Sobrien#include "input.h" 3090075Sobrien#include "toplev.h" 3190075Sobrien#include "intl.h" 3290075Sobrien#include "diagnostic.h" 3390075Sobrien 3490075Sobrienstatic void file_and_line_for_asm PARAMS ((rtx, const char **, int *)); 35117395Skanstatic void diagnostic_for_asm PARAMS ((rtx, const char *, va_list *, 36117395Skan diagnostic_t)); 3790075Sobrien 3890075Sobrien/* Figure file and line of the given INSN. */ 3990075Sobrienstatic void 4090075Sobrienfile_and_line_for_asm (insn, pfile, pline) 4190075Sobrien rtx insn; 4290075Sobrien const char **pfile; 4390075Sobrien int *pline; 4490075Sobrien{ 4590075Sobrien rtx body = PATTERN (insn); 4690075Sobrien rtx asmop; 4790075Sobrien 4890075Sobrien /* Find the (or one of the) ASM_OPERANDS in the insn. */ 4990075Sobrien if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) 5090075Sobrien asmop = SET_SRC (body); 5190075Sobrien else if (GET_CODE (body) == ASM_OPERANDS) 5290075Sobrien asmop = body; 5390075Sobrien else if (GET_CODE (body) == PARALLEL 5490075Sobrien && GET_CODE (XVECEXP (body, 0, 0)) == SET) 5590075Sobrien asmop = SET_SRC (XVECEXP (body, 0, 0)); 5690075Sobrien else if (GET_CODE (body) == PARALLEL 5790075Sobrien && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS) 5890075Sobrien asmop = XVECEXP (body, 0, 0); 5990075Sobrien else 6090075Sobrien asmop = NULL; 6190075Sobrien 6290075Sobrien if (asmop) 6390075Sobrien { 6490075Sobrien *pfile = ASM_OPERANDS_SOURCE_FILE (asmop); 6590075Sobrien *pline = ASM_OPERANDS_SOURCE_LINE (asmop); 6690075Sobrien } 6790075Sobrien else 6890075Sobrien { 6990075Sobrien *pfile = input_filename; 7090075Sobrien *pline = lineno; 7190075Sobrien } 7290075Sobrien} 7390075Sobrien 7490075Sobrien/* Report a diagnostic MESSAGE (an errror or a WARNING) at the line number 7590075Sobrien of the insn INSN. This is used only when INSN is an `asm' with operands, 7690075Sobrien and each ASM_OPERANDS records its own source file and line. */ 7790075Sobrienstatic void 78117395Skandiagnostic_for_asm (insn, msg, args_ptr, kind) 7990075Sobrien rtx insn; 8090075Sobrien const char *msg; 8190075Sobrien va_list *args_ptr; 82117395Skan diagnostic_t kind; 8390075Sobrien{ 84117395Skan diagnostic_info diagnostic; 8590075Sobrien 86117395Skan diagnostic_set_info (&diagnostic, msg, args_ptr, NULL, 0, kind); 87117395Skan file_and_line_for_asm (insn, &diagnostic.location.file, 88117395Skan &diagnostic.location.line); 89117395Skan report_diagnostic (&diagnostic); 9090075Sobrien} 9190075Sobrien 9290075Sobrienvoid 9390075Sobrienerror_for_asm VPARAMS ((rtx insn, const char *msgid, ...)) 9490075Sobrien{ 9590075Sobrien VA_OPEN (ap, msgid); 9690075Sobrien VA_FIXEDARG (ap, rtx, insn); 9790075Sobrien VA_FIXEDARG (ap, const char *, msgid); 9890075Sobrien 99117395Skan diagnostic_for_asm (insn, msgid, &ap, DK_ERROR); 10090075Sobrien VA_CLOSE (ap); 10190075Sobrien} 10290075Sobrien 10390075Sobrienvoid 10490075Sobrienwarning_for_asm VPARAMS ((rtx insn, const char *msgid, ...)) 10590075Sobrien{ 10690075Sobrien VA_OPEN (ap, msgid); 10790075Sobrien VA_FIXEDARG (ap, rtx, insn); 10890075Sobrien VA_FIXEDARG (ap, const char *, msgid); 10990075Sobrien 110117395Skan diagnostic_for_asm (insn, msgid, &ap, DK_WARNING); 11190075Sobrien VA_CLOSE (ap); 11290075Sobrien} 11390075Sobrien 11490075Sobrienvoid 11590075Sobrien_fatal_insn (msgid, insn, file, line, function) 11690075Sobrien const char *msgid; 11790075Sobrien rtx insn; 11890075Sobrien const char *file; 11990075Sobrien int line; 12090075Sobrien const char *function; 12190075Sobrien{ 12290075Sobrien error ("%s", _(msgid)); 12390075Sobrien 12490075Sobrien /* The above incremented error_count, but isn't an error that we want to 12590075Sobrien count, so reset it here. */ 12690075Sobrien errorcount--; 12790075Sobrien 12890075Sobrien debug_rtx (insn); 12990075Sobrien fancy_abort (file, line, function); 13090075Sobrien} 13190075Sobrien 13290075Sobrienvoid 13390075Sobrien_fatal_insn_not_found (insn, file, line, function) 13490075Sobrien rtx insn; 13590075Sobrien const char *file; 13690075Sobrien int line; 13790075Sobrien const char *function; 13890075Sobrien{ 13990075Sobrien if (INSN_CODE (insn) < 0) 14090075Sobrien _fatal_insn ("unrecognizable insn:", insn, file, line, function); 14190075Sobrien else 14290075Sobrien _fatal_insn ("insn does not satisfy its constraints:", 14390075Sobrien insn, file, line, function); 14490075Sobrien} 14590075Sobrien 146