]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/rtl-error.c
Update copyright years in gcc/
[thirdparty/gcc.git] / gcc / rtl-error.c
CommitLineData
5e6908ea 1/* RTL specific diagnostic subroutines for GCC
23a5b65a 2 Copyright (C) 2001-2014 Free Software Foundation, Inc.
c895acf2
GDR
3 Contributed by Gabriel Dos Reis <gdr@codesourcery.com>
4
40803cd5 5This file is part of GCC.
c895acf2 6
40803cd5 7GCC is free software; you can redistribute it and/or modify
c895acf2 8it under the terms of the GNU General Public License as published by
9dcd6f09 9the Free Software Foundation; either version 3, or (at your option)
c895acf2
GDR
10any later version.
11
40803cd5 12GCC is distributed in the hope that it will be useful,
c895acf2
GDR
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
9dcd6f09
NC
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
c895acf2
GDR
20
21#include "config.h"
c895acf2 22#include "system.h"
4977bab6
ZW
23#include "coretypes.h"
24#include "tm.h"
0cbd9993 25#include "rtl-error.h"
c895acf2
GDR
26#include "insn-attr.h"
27#include "insn-config.h"
28#include "input.h"
c895acf2
GDR
29#include "intl.h"
30#include "diagnostic.h"
31
f7d504c2
KG
32static location_t location_for_asm (const_rtx);
33static void diagnostic_for_asm (const_rtx, const char *, va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(2,0);
c895acf2 34
9a472a42
NS
35/* Figure the location of the given INSN. */
36static location_t
f7d504c2 37location_for_asm (const_rtx insn)
c895acf2
GDR
38{
39 rtx body = PATTERN (insn);
40 rtx asmop;
9a472a42 41 location_t loc;
0c20a65f 42
c895acf2
GDR
43 /* Find the (or one of the) ASM_OPERANDS in the insn. */
44 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
45 asmop = SET_SRC (body);
46 else if (GET_CODE (body) == ASM_OPERANDS)
47 asmop = body;
48 else if (GET_CODE (body) == PARALLEL
49 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
50 asmop = SET_SRC (XVECEXP (body, 0, 0));
51 else if (GET_CODE (body) == PARALLEL
52 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
53 asmop = XVECEXP (body, 0, 0);
54 else
55 asmop = NULL;
56
57 if (asmop)
6773e15f 58 loc = ASM_OPERANDS_SOURCE_LOCATION (asmop);
c895acf2 59 else
9a472a42
NS
60 loc = input_location;
61 return loc;
c895acf2
GDR
62}
63
fa10beec 64/* Report a diagnostic MESSAGE (an error or a WARNING) at the line number
c895acf2
GDR
65 of the insn INSN. This is used only when INSN is an `asm' with operands,
66 and each ASM_OPERANDS records its own source file and line. */
67static void
f7d504c2 68diagnostic_for_asm (const_rtx insn, const char *msg, va_list *args_ptr,
0c20a65f 69 diagnostic_t kind)
c895acf2 70{
47b69537 71 diagnostic_info diagnostic;
0c20a65f 72
9a472a42
NS
73 diagnostic_set_info (&diagnostic, msg, args_ptr,
74 location_for_asm (insn), kind);
47b69537 75 report_diagnostic (&diagnostic);
c895acf2
GDR
76}
77
78void
f7d504c2 79error_for_asm (const_rtx insn, const char *gmsgid, ...)
c895acf2 80{
e34d07f2 81 va_list ap;
0c20a65f 82
4b794eaf
JJ
83 va_start (ap, gmsgid);
84 diagnostic_for_asm (insn, gmsgid, &ap, DK_ERROR);
e34d07f2 85 va_end (ap);
c895acf2
GDR
86}
87
88void
f7d504c2 89warning_for_asm (const_rtx insn, const char *gmsgid, ...)
c895acf2 90{
e34d07f2 91 va_list ap;
0c20a65f 92
4b794eaf
JJ
93 va_start (ap, gmsgid);
94 diagnostic_for_asm (insn, gmsgid, &ap, DK_WARNING);
e34d07f2 95 va_end (ap);
c895acf2
GDR
96}
97
98void
f7d504c2 99_fatal_insn (const char *msgid, const_rtx insn, const char *file, int line,
0c20a65f 100 const char *function)
c895acf2
GDR
101{
102 error ("%s", _(msgid));
103
104 /* The above incremented error_count, but isn't an error that we want to
105 count, so reset it here. */
106 errorcount--;
107
108 debug_rtx (insn);
109 fancy_abort (file, line, function);
110}
111
112void
f7d504c2 113_fatal_insn_not_found (const_rtx insn, const char *file, int line,
0c20a65f 114 const char *function)
c895acf2
GDR
115{
116 if (INSN_CODE (insn) < 0)
1f978f5f 117 _fatal_insn ("unrecognizable insn:", insn, file, line, function);
c895acf2 118 else
1f978f5f 119 _fatal_insn ("insn does not satisfy its constraints:",
c895acf2
GDR
120 insn, file, line, function);
121}