LCOV - code coverage report
Current view: top level - gcc - rtl-error.c (source / functions) Hit Total Coverage
Test: gcc.info Lines: 26 42 61.9 %
Date: 2020-03-28 11:57:23 Functions: 3 6 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* RTL specific diagnostic subroutines for GCC
       2                 :            :    Copyright (C) 2001-2020 Free Software Foundation, Inc.
       3                 :            :    Contributed by Gabriel Dos Reis <gdr@codesourcery.com>
       4                 :            : 
       5                 :            : This file is part of GCC.
       6                 :            : 
       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 3, or (at your option)
      10                 :            : any later version.
      11                 :            : 
      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.
      16                 :            : 
      17                 :            : You should have received a copy of the GNU General Public License
      18                 :            : along with GCC; see the file COPYING3.  If not see
      19                 :            : <http://www.gnu.org/licenses/>.  */
      20                 :            : 
      21                 :            : #include "config.h"
      22                 :            : #include "system.h"
      23                 :            : #include "coretypes.h"
      24                 :            : #include "tm.h"
      25                 :            : #include "rtl-error.h"
      26                 :            : #include "diagnostic.h"
      27                 :            : #include "intl.h"
      28                 :            : 
      29                 :            : static location_t location_for_asm (const rtx_insn *);
      30                 :            : static void diagnostic_for_asm (const rtx_insn *, const char *, va_list *,
      31                 :            :                                 diagnostic_t) ATTRIBUTE_GCC_DIAG(2,0);
      32                 :            : 
      33                 :            : /* Figure the location of the given INSN.  */
      34                 :            : static location_t
      35                 :         63 : location_for_asm (const rtx_insn *insn)
      36                 :            : {
      37                 :         63 :   rtx body = PATTERN (insn);
      38                 :         63 :   rtx asmop;
      39                 :         63 :   location_t loc;
      40                 :            : 
      41                 :            :   /* Find the (or one of the) ASM_OPERANDS in the insn.  */
      42                 :         63 :   if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
      43                 :            :     asmop = SET_SRC (body);
      44                 :         62 :   else if (GET_CODE (body) == ASM_OPERANDS)
      45                 :            :     asmop = body;
      46                 :         62 :   else if (GET_CODE (body) == PARALLEL
      47                 :         62 :            && GET_CODE (XVECEXP (body, 0, 0)) == SET)
      48                 :         26 :     asmop = SET_SRC (XVECEXP (body, 0, 0));
      49                 :         36 :   else if (GET_CODE (body) == PARALLEL
      50                 :         36 :            && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
      51                 :            :     asmop = XVECEXP (body, 0, 0);
      52                 :            :   else
      53                 :            :     asmop = NULL;
      54                 :            : 
      55                 :         63 :   if (asmop)
      56                 :         63 :     loc = ASM_OPERANDS_SOURCE_LOCATION (asmop);
      57                 :            :   else
      58                 :          0 :     loc = input_location;
      59                 :         63 :   return loc;
      60                 :            : }
      61                 :            : 
      62                 :            : /* Report a diagnostic MESSAGE (an error or a WARNING) at the line number
      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.  */
      65                 :            : static void
      66                 :         63 : diagnostic_for_asm (const rtx_insn *insn, const char *msg, va_list *args_ptr,
      67                 :            :                     diagnostic_t kind)
      68                 :            : {
      69                 :         63 :   diagnostic_info diagnostic;
      70                 :        126 :   rich_location richloc (line_table, location_for_asm (insn));
      71                 :            : 
      72                 :         63 :   diagnostic_set_info (&diagnostic, msg, args_ptr,
      73                 :            :                        &richloc, kind);
      74                 :         63 :   diagnostic_report_diagnostic (global_dc, &diagnostic);
      75                 :         63 : }
      76                 :            : 
      77                 :            : void
      78                 :         63 : error_for_asm (const rtx_insn *insn, const char *gmsgid, ...)
      79                 :            : {
      80                 :         63 :   va_list ap;
      81                 :            : 
      82                 :         63 :   va_start (ap, gmsgid);
      83                 :         63 :   diagnostic_for_asm (insn, gmsgid, &ap, DK_ERROR);
      84                 :         63 :   va_end (ap);
      85                 :         63 : }
      86                 :            : 
      87                 :            : void
      88                 :          0 : warning_for_asm (const rtx_insn *insn, const char *gmsgid, ...)
      89                 :            : {
      90                 :          0 :   va_list ap;
      91                 :            : 
      92                 :          0 :   va_start (ap, gmsgid);
      93                 :          0 :   diagnostic_for_asm (insn, gmsgid, &ap, DK_WARNING);
      94                 :          0 :   va_end (ap);
      95                 :          0 : }
      96                 :            : 
      97                 :            : void
      98                 :          0 : _fatal_insn (const char *msgid, const_rtx insn, const char *file, int line,
      99                 :            :              const char *function)
     100                 :            : {
     101                 :          0 :   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                 :          0 :   errorcount--;
     106                 :            : 
     107                 :          0 :   debug_rtx (insn);
     108                 :          0 :   fancy_abort (file, line, function);
     109                 :            : }
     110                 :            : 
     111                 :            : void
     112                 :          0 : _fatal_insn_not_found (const_rtx insn, const char *file, int line,
     113                 :            :                        const char *function)
     114                 :            : {
     115                 :          0 :   if (INSN_CODE (insn) < 0)
     116                 :          0 :     _fatal_insn ("unrecognizable insn:", insn, file, line, function);
     117                 :            :   else
     118                 :          0 :     _fatal_insn ("insn does not satisfy its constraints:",
     119                 :            :                 insn, file, line, function);
     120                 :            : }

Generated by: LCOV version 1.0

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto --enable-host-shared. GCC test suite is run with the built compiler.