File: go-diagnostics.h

package info (click to toggle)
gcc-arm-none-eabi 15%3A8-2019-q3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 571,828 kB
  • sloc: ansic: 2,937,651; cpp: 881,644; ada: 597,189; makefile: 65,528; asm: 56,499; xml: 46,621; exp: 24,747; sh: 19,684; python: 7,256; pascal: 4,370; awk: 3,497; perl: 2,695; yacc: 316; ml: 285; f90: 234; lex: 198; objc: 194; haskell: 119
file content (64 lines) | stat: -rw-r--r-- 2,735 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// go-diagnostics.h -- interface to diagnostic reporting   -*- C++ -*-

// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#ifndef GO_DIAGNOSTICS_H
#define GO_DIAGNOSTICS_H

#include "go-linemap.h"

#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
#define GO_ATTRIBUTE_GCC_DIAG(m, n) __attribute__ ((__format__ (__gcc_tdiag__, m, n))) __attribute__ ((__nonnull__ (m)))
#else
#define GO_ATTRIBUTE_GCC_DIAG(m,  n)
#endif

// These declarations define the interface through which the frontend
// reports errors and warnings. These functions accept printf-like
// format specifiers (e.g. %d, %f, %s, etc), with the following additional
// extensions:
//
//  1.  'q' qualifier may be applied to a specifier to add quoting, e.g.
//      %qd produces a quoted decimal output, %qs a quoted string output.
//      [This extension is supported only with single-character format
//      specifiers].
//
//  2.  %m specifier outputs value of "strerror(errno)" at time of call.
//
//  3.  %< outputs an opening quote, %> a closing quote.
//
// All other format specifiers are as defined by 'sprintf'. The final resulting
// message is then sent to the back end via go_be_error_at/go_be_warning_at.

extern void go_error_at(const Location, const char* fmt, ...)
    GO_ATTRIBUTE_GCC_DIAG(2,3);
extern void go_warning_at(const Location, int opt, const char* fmt, ...)
    GO_ATTRIBUTE_GCC_DIAG(3,4);
extern void go_fatal_error(const Location, const char* fmt, ...)
    GO_ATTRIBUTE_GCC_DIAG(2,3);
extern void go_inform(const Location, const char* fmt, ...)
    GO_ATTRIBUTE_GCC_DIAG(2,3);

// These interfaces provide a way for the front end to ask for
// the open/close quote characters it should use when formatting
// diagnostics (warnings, errors).
extern const char* go_open_quote();
extern const char* go_close_quote();

// These interfaces are used by utilities above to pass warnings and
// errors (once format specifiers have been expanded) to the back end,
// and to determine quoting style. Avoid calling these routines directly;
// instead use the equivalent routines above. The back end is required to
// implement these routines.

extern void go_be_error_at(const Location, const std::string& errmsg);
extern void go_be_warning_at(const Location, int opt,
                             const std::string& warningmsg);
extern void go_be_fatal_error(const Location, const std::string& errmsg);
extern void go_be_inform(const Location, const std::string& infomsg);
extern void go_be_get_quotechars(const char** open_quote,
                                 const char** close_quote);

#endif // !defined(GO_DIAGNOSTICS_H)