d: Merge dmd, druntime d8e3976a58, phobos 7a6e95688
[official-gcc.git] / gcc / d / dmd / errors.h
blob308e81e30ba0f2074b7926cd74b67758e03c7ca2
2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved
4 * written by Walter Bright
5 * https://www.digitalmars.com
6 * Distributed under the Boost Software License, Version 1.0.
7 * https://www.boost.org/LICENSE_1_0.txt
8 * https://github.com/dlang/dmd/blob/master/src/dmd/errors.h
9 */
11 #pragma once
13 #include "root/dsystem.h"
15 struct Loc;
17 // Constants used to discriminate kinds of error messages.
18 enum class ErrorKind
20 warning = 0,
21 deprecation = 1,
22 error = 2,
23 tip = 3,
24 message = 4,
27 bool isConsoleColorSupported();
29 #if defined(__GNUC__)
30 #define D_ATTRIBUTE_FORMAT(m, n) __attribute__((format(printf, m, n))) __attribute__((nonnull (m)))
31 #else
32 #define D_ATTRIBUTE_FORMAT(m, n)
33 #endif
35 // Print a warning, deprecation, or error, accepts printf-like format specifiers.
36 D_ATTRIBUTE_FORMAT(2, 3) void warning(const Loc& loc, const char *format, ...);
37 D_ATTRIBUTE_FORMAT(2, 3) void warningSupplemental(const Loc& loc, const char *format, ...);
38 D_ATTRIBUTE_FORMAT(2, 3) void deprecation(const Loc& loc, const char *format, ...);
39 D_ATTRIBUTE_FORMAT(2, 3) void deprecationSupplemental(const Loc& loc, const char *format, ...);
40 D_ATTRIBUTE_FORMAT(2, 3) void error(const Loc& loc, const char *format, ...);
41 D_ATTRIBUTE_FORMAT(4, 5) void error(const char *filename, unsigned linnum, unsigned charnum, const char *format, ...);
42 D_ATTRIBUTE_FORMAT(2, 3) void errorSupplemental(const Loc& loc, const char *format, ...);
43 D_ATTRIBUTE_FORMAT(1, 2) void message(const char *format, ...);
44 D_ATTRIBUTE_FORMAT(2, 3) void message(const Loc& loc, const char *format, ...);
45 D_ATTRIBUTE_FORMAT(1, 2) void tip(const char *format, ...);
47 D_ATTRIBUTE_FORMAT(2, 0) void verrorReport(const Loc& loc, const char *format, va_list ap, ErrorKind kind, const char *p1 = NULL, const char *p2 = NULL);
48 D_ATTRIBUTE_FORMAT(2, 0) void verrorReportSupplemental(const Loc& loc, const char* format, va_list ap, ErrorKind kind);
50 #if defined(__GNUC__) || defined(__clang__)
51 #define D_ATTRIBUTE_NORETURN __attribute__((noreturn))
52 #elif _MSC_VER
53 #define D_ATTRIBUTE_NORETURN __declspec(noreturn)
54 #else
55 #define D_ATTRIBUTE_NORETURN
56 #endif
58 // Called after printing out fatal error messages.
59 D_ATTRIBUTE_NORETURN void fatal();
60 D_ATTRIBUTE_NORETURN void halt();