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