Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/compiler/preprocessor/DiagnosticsBase.cpp
1693 views
1
//
2
// Copyright 2012 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
7
#include "compiler/preprocessor/DiagnosticsBase.h"
8
9
#include "common/debug.h"
10
11
namespace angle
12
{
13
14
namespace pp
15
{
16
17
Diagnostics::~Diagnostics() {}
18
19
void Diagnostics::report(ID id, const SourceLocation &loc, const std::string &text)
20
{
21
print(id, loc, text);
22
}
23
24
bool Diagnostics::isError(ID id)
25
{
26
if ((id > PP_ERROR_BEGIN) && (id < PP_ERROR_END))
27
return true;
28
29
if ((id > PP_WARNING_BEGIN) && (id < PP_WARNING_END))
30
return false;
31
32
UNREACHABLE();
33
return true;
34
}
35
36
const char *Diagnostics::message(ID id)
37
{
38
switch (id)
39
{
40
// Errors begin.
41
case PP_INTERNAL_ERROR:
42
return "internal error";
43
case PP_OUT_OF_MEMORY:
44
return "out of memory";
45
case PP_INVALID_CHARACTER:
46
return "invalid character";
47
case PP_INVALID_NUMBER:
48
return "invalid number";
49
case PP_INTEGER_OVERFLOW:
50
return "integer overflow";
51
case PP_FLOAT_OVERFLOW:
52
return "float overflow";
53
case PP_TOKEN_TOO_LONG:
54
return "token too long";
55
case PP_INVALID_EXPRESSION:
56
return "invalid expression";
57
case PP_DIVISION_BY_ZERO:
58
return "division by zero";
59
case PP_EOF_IN_COMMENT:
60
return "unexpected end of file found in comment";
61
case PP_UNEXPECTED_TOKEN:
62
return "unexpected token";
63
case PP_DIRECTIVE_INVALID_NAME:
64
return "invalid directive name";
65
case PP_MACRO_NAME_RESERVED:
66
return "macro name is reserved";
67
case PP_MACRO_REDEFINED:
68
return "macro redefined";
69
case PP_MACRO_PREDEFINED_REDEFINED:
70
return "predefined macro redefined";
71
case PP_MACRO_PREDEFINED_UNDEFINED:
72
return "predefined macro undefined";
73
case PP_MACRO_UNTERMINATED_INVOCATION:
74
return "unterminated macro invocation";
75
case PP_MACRO_UNDEFINED_WHILE_INVOKED:
76
return "macro undefined while being invoked";
77
case PP_MACRO_TOO_FEW_ARGS:
78
return "Not enough arguments for macro";
79
case PP_MACRO_TOO_MANY_ARGS:
80
return "Too many arguments for macro";
81
case PP_MACRO_DUPLICATE_PARAMETER_NAMES:
82
return "duplicate macro parameter name";
83
case PP_MACRO_INVOCATION_CHAIN_TOO_DEEP:
84
return "macro invocation chain too deep";
85
case PP_CONDITIONAL_ENDIF_WITHOUT_IF:
86
return "unexpected #endif found without a matching #if";
87
case PP_CONDITIONAL_ELSE_WITHOUT_IF:
88
return "unexpected #else found without a matching #if";
89
case PP_CONDITIONAL_ELSE_AFTER_ELSE:
90
return "unexpected #else found after another #else";
91
case PP_CONDITIONAL_ELIF_WITHOUT_IF:
92
return "unexpected #elif found without a matching #if";
93
case PP_CONDITIONAL_ELIF_AFTER_ELSE:
94
return "unexpected #elif found after #else";
95
case PP_CONDITIONAL_UNTERMINATED:
96
return "unexpected end of file found in conditional block";
97
case PP_INVALID_EXTENSION_NAME:
98
return "invalid extension name";
99
case PP_INVALID_EXTENSION_BEHAVIOR:
100
return "invalid extension behavior";
101
case PP_INVALID_EXTENSION_DIRECTIVE:
102
return "invalid extension directive";
103
case PP_INVALID_VERSION_NUMBER:
104
return "invalid version number";
105
case PP_INVALID_VERSION_DIRECTIVE:
106
return "invalid version directive";
107
case PP_VERSION_NOT_FIRST_STATEMENT:
108
return "#version directive must occur before anything else, "
109
"except for comments and white space";
110
case PP_VERSION_NOT_FIRST_LINE_ESSL3:
111
return "#version directive must occur on the first line of the shader";
112
case PP_INVALID_LINE_NUMBER:
113
return "invalid line number";
114
case PP_INVALID_FILE_NUMBER:
115
return "invalid file number";
116
case PP_INVALID_LINE_DIRECTIVE:
117
return "invalid line directive";
118
case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1:
119
return "extension directive must occur before any non-preprocessor tokens in ESSL1";
120
case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3:
121
return "extension directive must occur before any non-preprocessor tokens in ESSL3";
122
case PP_UNDEFINED_SHIFT:
123
return "shift exponent is negative or undefined";
124
case PP_TOKENIZER_ERROR:
125
return "internal tokenizer error";
126
// Errors end.
127
// Warnings begin.
128
case PP_EOF_IN_DIRECTIVE:
129
return "unexpected end of file found in directive";
130
case PP_CONDITIONAL_UNEXPECTED_TOKEN:
131
return "unexpected token after conditional expression";
132
case PP_UNRECOGNIZED_PRAGMA:
133
return "unrecognized pragma";
134
case PP_NON_PP_TOKEN_BEFORE_EXTENSION_WEBGL:
135
return "extension directive should occur before any non-preprocessor tokens";
136
case PP_WARNING_MACRO_NAME_RESERVED:
137
return "macro name with a double underscore is reserved - unintented behavior is "
138
"possible";
139
// Warnings end.
140
default:
141
UNREACHABLE();
142
return "";
143
}
144
}
145
146
} // namespace pp
147
148
} // namespace angle
149
150