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