1 
2 /* Compiler implementation of the D programming language
3  * Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved
4  * written by Walter Bright
5  * http://www.digitalmars.com
6  * Distributed under the Boost Software License, Version 1.0.
7  * http://www.boost.org/LICENSE_1_0.txt
8  * https://github.com/dlang/dmd/blob/master/src/dmd/errors.h
9  */
10 
11 #pragma once
12 
13 #include "root/dsystem.h"
14 #include "globals.h"
15 
16 bool isConsoleColorSupported();
17 
18 #if defined(__GNUC__)
19 #define D_ATTRIBUTE_FORMAT(m, n) __attribute__((format(printf, m, n))) __attribute__((nonnull (m)))
20 #else
21 #define D_ATTRIBUTE_FORMAT(m, n)
22 #endif
23 
24 // Print a warning, deprecation, or error, accepts printf-like format specifiers.
25 D_ATTRIBUTE_FORMAT(2, 3) void warning(const Loc& loc, const char *format, ...);
26 D_ATTRIBUTE_FORMAT(2, 3) void warningSupplemental(const Loc& loc, const char *format, ...);
27 D_ATTRIBUTE_FORMAT(2, 3) void deprecation(const Loc& loc, const char *format, ...);
28 D_ATTRIBUTE_FORMAT(2, 3) void deprecationSupplemental(const Loc& loc, const char *format, ...);
29 D_ATTRIBUTE_FORMAT(2, 3) void error(const Loc& loc, const char *format, ...);
30 D_ATTRIBUTE_FORMAT(2, 3) void errorSupplemental(const Loc& loc, const char *format, ...);
31 D_ATTRIBUTE_FORMAT(2, 0) void verror(const Loc& loc, const char *format, va_list ap, const char *p1 = NULL, const char *p2 = NULL, const char *header = "Error: ");
32 D_ATTRIBUTE_FORMAT(2, 0) void verrorSupplemental(const Loc& loc, const char *format, va_list ap);
33 D_ATTRIBUTE_FORMAT(2, 0) void vwarning(const Loc& loc, const char *format, va_list);
34 D_ATTRIBUTE_FORMAT(2, 0) void vwarningSupplemental(const Loc& loc, const char *format, va_list ap);
35 D_ATTRIBUTE_FORMAT(2, 0) void vdeprecation(const Loc& loc, const char *format, va_list ap, const char *p1 = NULL, const char *p2 = NULL);
36 D_ATTRIBUTE_FORMAT(2, 0) void vdeprecationSupplemental(const Loc& loc, const char *format, va_list ap);
37 D_ATTRIBUTE_FORMAT(1, 2) void message(const char *format, ...);
38 D_ATTRIBUTE_FORMAT(2, 3) void message(const Loc& loc, const char *format, ...);
39 D_ATTRIBUTE_FORMAT(2, 0) void vmessage(const Loc& loc, const char *format, va_list);
40 
41 #if defined(__GNUC__) || defined(__clang__)
42 #define D_ATTRIBUTE_NORETURN __attribute__((noreturn))
43 #elif _MSC_VER
44 #define D_ATTRIBUTE_NORETURN __declspec(noreturn)
45 #else
46 #define D_ATTRIBUTE_NORETURN
47 #endif
48 
49 // Called after printing out fatal error messages.
50 D_ATTRIBUTE_NORETURN void fatal();
51 D_ATTRIBUTE_NORETURN void halt();
52