no more multi-line errors/warnings
[cparser] / diagnostic.h
1 /*
2  * This file is part of cparser.
3  * Copyright (C) 2007-2008 Matthias Braun <matze@braunis.de>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18  * 02111-1307, USA.
19  */
20 #ifndef DIAGNOSTIC_H
21 #define DIAGNOSTIC_H
22
23 #include <stdbool.h>
24 #include "token_t.h"
25
26 /* define a NORETURN attribute */
27 #ifndef NORETURN
28 # if defined(__GNUC__)
29 #  if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 70)
30 #   define NORETURN void __attribute__ ((noreturn))
31 #  endif /* __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 70) */
32 # endif /* defined(__GNUC__) */
33
34 # if defined(_MSC_VER)
35 #  define NORETURN void __declspec(noreturn)
36 # endif /* defined(_MSC_VER) */
37
38 /* If not set above, use "void" for DOES_NOT_RETURN. */
39 # ifndef NORETURN
40 # define NORETURN void
41 # endif /* ifndef NORETURN */
42 #endif /* ifndef NORETURN */
43
44 /**
45  * Issue a diagnostic message.
46  * Format types:
47  *  %Y  symbol_t
48  *  %E  expression_t
49  *  %Q  unsigned  (qualifier)
50  *  %T  type_t
51  *  %K  token_t
52  *  %k  token_kind_t
53  *  %P  source_position_t
54  *
55  */
56 void diagnosticf(const char *fmt, ...);
57 void errorf(source_position_t pos, const char *fmt, ...);
58 void warningf(source_position_t pos, const char *fmt, ...);
59 NORETURN internal_errorf(source_position_t pos, const char *fmt, ...);
60
61 extern unsigned diagnostic_count;
62 extern unsigned error_count;
63 extern unsigned warning_count;
64
65 /* true if warnings should be inhibited */
66 extern bool inhibit_all_warnings;
67
68 #endif