Branch data Line data Source code
1 : : /* do not edit automatically generated by mc from M2Emit. */
2 : : /* M2Emit.mod issue errors to the GCC error reporting substructure.
3 : :
4 : : Copyright (C) 2019-2024 Free Software Foundation, Inc.
5 : : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 : :
7 : : This file is part of GNU Modula-2.
8 : :
9 : : GNU Modula-2 is free software; you can redistribute it and/or modify
10 : : it under the terms of the GNU General Public License as published by
11 : : the Free Software Foundation; either version 3, or (at your option)
12 : : any later version.
13 : :
14 : : GNU Modula-2 is distributed in the hope that it will be useful, but
15 : : WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : : General Public License for more details.
18 : :
19 : : You should have received a copy of the GNU General Public License
20 : : along with GNU Modula-2; see the file COPYING3. If not see
21 : : <http://www.gnu.org/licenses/>. */
22 : :
23 : : #include "config.h"
24 : : #include "system.h"
25 : : #include <stdbool.h>
26 : : # if !defined (PROC_D)
27 : : # define PROC_D
28 : : typedef void (*PROC_t) (void);
29 : : typedef struct { PROC_t proc; } PROC;
30 : : # endif
31 : :
32 : : #define _M2Emit_H
33 : : #define _M2Emit_C
34 : :
35 : : # include "Gm2linemap.h"
36 : : # include "GM2LexBuf.h"
37 : : # include "GDynamicStrings.h"
38 : : # include "GSYSTEM.h"
39 : :
40 : :
41 : : /*
42 : : EmitError - pass the error to GCC.
43 : : */
44 : :
45 : : extern "C" void M2Emit_EmitError (bool error, bool note, unsigned int token, DynamicStrings_String message);
46 : :
47 : : /*
48 : : InternalError - issue an internal error, message.
49 : : */
50 : :
51 : : extern "C" void M2Emit_InternalError (const char *message_, unsigned int _message_high);
52 : :
53 : : /*
54 : : UnknownLocation - return the unknown location (using GCC linemap for cc1gm2)
55 : : and constants for gm2l and gm2m.
56 : : */
57 : :
58 : : extern "C" m2linemap_location_t M2Emit_UnknownLocation (void);
59 : :
60 : : /*
61 : : BuiltinsLocation - return the builtins location (using GCC linemap for cc1gm2)
62 : : and constants for gm2l and gm2m.
63 : : */
64 : :
65 : : extern "C" m2linemap_location_t M2Emit_BuiltinsLocation (void);
66 : :
67 : :
68 : : /*
69 : : EmitError - pass the error to GCC.
70 : : */
71 : :
72 : 2058 : extern "C" void M2Emit_EmitError (bool error, bool note, unsigned int token, DynamicStrings_String message)
73 : : {
74 : 2058 : if (error)
75 : : {
76 : 1581 : m2linemap_ErrorAtf (M2LexBuf_TokenToLocation (token), DynamicStrings_string (message));
77 : : }
78 : 477 : else if (note)
79 : : {
80 : : /* avoid dangling else. */
81 : 3 : m2linemap_NoteAtf (M2LexBuf_TokenToLocation (token), DynamicStrings_string (message));
82 : : }
83 : : else
84 : : {
85 : : /* avoid dangling else. */
86 : 474 : m2linemap_WarningAtf (M2LexBuf_TokenToLocation (token), DynamicStrings_string (message));
87 : : }
88 : 2058 : }
89 : :
90 : :
91 : : /*
92 : : InternalError - issue an internal error, message.
93 : : */
94 : :
95 : 24 : extern "C" void M2Emit_InternalError (const char *message_, unsigned int _message_high)
96 : : {
97 : 24 : char message[_message_high+1];
98 : :
99 : : /* make a local copy of each unbounded array. */
100 : 24 : memcpy (message, message_, _message_high+1);
101 : :
102 : 24 : m2linemap_internal_error (&message);
103 : 24 : }
104 : :
105 : :
106 : : /*
107 : : UnknownLocation - return the unknown location (using GCC linemap for cc1gm2)
108 : : and constants for gm2l and gm2m.
109 : : */
110 : :
111 : 4202187 : extern "C" m2linemap_location_t M2Emit_UnknownLocation (void)
112 : : {
113 : 4202187 : return m2linemap_UnknownLocation ();
114 : : /* static analysis guarentees a RETURN statement will be used before here. */
115 : : __builtin_unreachable ();
116 : : }
117 : :
118 : :
119 : : /*
120 : : BuiltinsLocation - return the builtins location (using GCC linemap for cc1gm2)
121 : : and constants for gm2l and gm2m.
122 : : */
123 : :
124 : 271243 : extern "C" m2linemap_location_t M2Emit_BuiltinsLocation (void)
125 : : {
126 : 271243 : return m2linemap_BuiltinsLocation ();
127 : : /* static analysis guarentees a RETURN statement will be used before here. */
128 : : __builtin_unreachable ();
129 : : }
130 : :
131 : 0 : extern "C" void _M2_M2Emit_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
132 : : {
133 : 0 : }
134 : :
135 : 0 : extern "C" void _M2_M2Emit_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
136 : : {
137 : 0 : }
|