Commit 0685fbde by Ehsan Akhgari

Rename the Diagnostics enum values to have a PP_ prefix

This will make it possible to build angle in unified mode for Mozilla. Change-Id: Iba4b971392b8abae8b5ff8f96e9172582f43de90
parent 0dd3b3ff
...@@ -30,11 +30,11 @@ void TDiagnostics::writeInfo(Severity severity, ...@@ -30,11 +30,11 @@ void TDiagnostics::writeInfo(Severity severity,
TPrefixType prefix = EPrefixNone; TPrefixType prefix = EPrefixNone;
switch (severity) switch (severity)
{ {
case ERROR: case PP_ERROR:
++mNumErrors; ++mNumErrors;
prefix = EPrefixError; prefix = EPrefixError;
break; break;
case WARNING: case PP_WARNING:
++mNumWarnings; ++mNumWarnings;
prefix = EPrefixWarning; prefix = EPrefixWarning;
break; break;
......
...@@ -39,7 +39,7 @@ TDirectiveHandler::~TDirectiveHandler() ...@@ -39,7 +39,7 @@ TDirectiveHandler::~TDirectiveHandler()
void TDirectiveHandler::handleError(const pp::SourceLocation& loc, void TDirectiveHandler::handleError(const pp::SourceLocation& loc,
const std::string& msg) const std::string& msg)
{ {
mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc, msg, "", ""); mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, msg, "", "");
} }
void TDirectiveHandler::handlePragma(const pp::SourceLocation& loc, void TDirectiveHandler::handlePragma(const pp::SourceLocation& loc,
...@@ -73,12 +73,12 @@ void TDirectiveHandler::handlePragma(const pp::SourceLocation& loc, ...@@ -73,12 +73,12 @@ void TDirectiveHandler::handlePragma(const pp::SourceLocation& loc,
} }
else else
{ {
mDiagnostics.report(pp::Diagnostics::UNRECOGNIZED_PRAGMA, loc, name); mDiagnostics.report(pp::Diagnostics::PP_UNRECOGNIZED_PRAGMA, loc, name);
return; return;
} }
if (invalidValue) if (invalidValue)
mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc, mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
"invalid pragma value", value, "invalid pragma value", value,
"'on' or 'off' expected"); "'on' or 'off' expected");
} }
...@@ -92,7 +92,7 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc, ...@@ -92,7 +92,7 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc,
TBehavior behaviorVal = getBehavior(behavior); TBehavior behaviorVal = getBehavior(behavior);
if (behaviorVal == EBhUndefined) if (behaviorVal == EBhUndefined)
{ {
mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc, mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
"behavior", name, "invalid"); "behavior", name, "invalid");
return; return;
} }
...@@ -101,13 +101,13 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc, ...@@ -101,13 +101,13 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc,
{ {
if (behaviorVal == EBhRequire) if (behaviorVal == EBhRequire)
{ {
mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc, mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
"extension", name, "extension", name,
"cannot have 'require' behavior"); "cannot have 'require' behavior");
} }
else if (behaviorVal == EBhEnable) else if (behaviorVal == EBhEnable)
{ {
mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc, mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
"extension", name, "extension", name,
"cannot have 'enable' behavior"); "cannot have 'enable' behavior");
} }
...@@ -127,15 +127,15 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc, ...@@ -127,15 +127,15 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc,
return; return;
} }
pp::Diagnostics::Severity severity = pp::Diagnostics::ERROR; pp::Diagnostics::Severity severity = pp::Diagnostics::PP_ERROR;
switch (behaviorVal) { switch (behaviorVal) {
case EBhRequire: case EBhRequire:
severity = pp::Diagnostics::ERROR; severity = pp::Diagnostics::PP_ERROR;
break; break;
case EBhEnable: case EBhEnable:
case EBhWarn: case EBhWarn:
case EBhDisable: case EBhDisable:
severity = pp::Diagnostics::WARNING; severity = pp::Diagnostics::PP_WARNING;
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
...@@ -155,7 +155,7 @@ void TDirectiveHandler::handleVersion(const pp::SourceLocation& loc, ...@@ -155,7 +155,7 @@ void TDirectiveHandler::handleVersion(const pp::SourceLocation& loc,
std::stringstream stream; std::stringstream stream;
stream << version; stream << version;
std::string str = stream.str(); std::string str = stream.str();
mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc, mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
"version number", str, "not supported"); "version number", str, "not supported");
} }
} }
...@@ -182,7 +182,7 @@ void TParseContext::error(const TSourceLoc& loc, ...@@ -182,7 +182,7 @@ void TParseContext::error(const TSourceLoc& loc,
pp::SourceLocation srcLoc; pp::SourceLocation srcLoc;
srcLoc.file = loc.first_file; srcLoc.file = loc.first_file;
srcLoc.line = loc.first_line; srcLoc.line = loc.first_line;
diagnostics.writeInfo(pp::Diagnostics::ERROR, diagnostics.writeInfo(pp::Diagnostics::PP_ERROR,
srcLoc, reason, token, extraInfo); srcLoc, reason, token, extraInfo);
} }
...@@ -193,7 +193,7 @@ void TParseContext::warning(const TSourceLoc& loc, ...@@ -193,7 +193,7 @@ void TParseContext::warning(const TSourceLoc& loc,
pp::SourceLocation srcLoc; pp::SourceLocation srcLoc;
srcLoc.file = loc.first_file; srcLoc.file = loc.first_file;
srcLoc.line = loc.first_line; srcLoc.line = loc.first_line;
diagnostics.writeInfo(pp::Diagnostics::WARNING, diagnostics.writeInfo(pp::Diagnostics::PP_WARNING,
srcLoc, reason, token, extraInfo); srcLoc, reason, token, extraInfo);
} }
......
...@@ -25,14 +25,14 @@ void Diagnostics::report(ID id, ...@@ -25,14 +25,14 @@ void Diagnostics::report(ID id,
Diagnostics::Severity Diagnostics::severity(ID id) Diagnostics::Severity Diagnostics::severity(ID id)
{ {
if ((id > ERROR_BEGIN) && (id < ERROR_END)) if ((id > PP_ERROR_BEGIN) && (id < PP_ERROR_END))
return ERROR; return PP_ERROR;
if ((id > WARNING_BEGIN) && (id < WARNING_END)) if ((id > PP_WARNING_BEGIN) && (id < PP_WARNING_END))
return WARNING; return PP_WARNING;
assert(false); assert(false);
return ERROR; return PP_ERROR;
} }
std::string Diagnostics::message(ID id) std::string Diagnostics::message(ID id)
...@@ -40,82 +40,82 @@ std::string Diagnostics::message(ID id) ...@@ -40,82 +40,82 @@ std::string Diagnostics::message(ID id)
switch (id) switch (id)
{ {
// Errors begin. // Errors begin.
case INTERNAL_ERROR: case PP_INTERNAL_ERROR:
return "internal error"; return "internal error";
case OUT_OF_MEMORY: case PP_OUT_OF_MEMORY:
return "out of memory"; return "out of memory";
case INVALID_CHARACTER: case PP_INVALID_CHARACTER:
return "invalid character"; return "invalid character";
case INVALID_NUMBER: case PP_INVALID_NUMBER:
return "invalid number"; return "invalid number";
case INTEGER_OVERFLOW: case PP_INTEGER_OVERFLOW:
return "integer overflow"; return "integer overflow";
case FLOAT_OVERFLOW: case PP_FLOAT_OVERFLOW:
return "float overflow"; return "float overflow";
case TOKEN_TOO_LONG: case PP_TOKEN_TOO_LONG:
return "token too long"; return "token too long";
case INVALID_EXPRESSION: case PP_INVALID_EXPRESSION:
return "invalid expression"; return "invalid expression";
case DIVISION_BY_ZERO: case PP_DIVISION_BY_ZERO:
return "division by zero"; return "division by zero";
case EOF_IN_COMMENT: case PP_EOF_IN_COMMENT:
return "unexpected end of file found in comment"; return "unexpected end of file found in comment";
case UNEXPECTED_TOKEN: case PP_UNEXPECTED_TOKEN:
return "unexpected token"; return "unexpected token";
case DIRECTIVE_INVALID_NAME: case PP_DIRECTIVE_INVALID_NAME:
return "invalid directive name"; return "invalid directive name";
case MACRO_NAME_RESERVED: case PP_MACRO_NAME_RESERVED:
return "macro name is reserved"; return "macro name is reserved";
case MACRO_REDEFINED: case PP_MACRO_REDEFINED:
return "macro redefined"; return "macro redefined";
case MACRO_PREDEFINED_REDEFINED: case PP_MACRO_PREDEFINED_REDEFINED:
return "predefined macro redefined"; return "predefined macro redefined";
case MACRO_PREDEFINED_UNDEFINED: case PP_MACRO_PREDEFINED_UNDEFINED:
return "predefined macro undefined"; return "predefined macro undefined";
case MACRO_UNTERMINATED_INVOCATION: case PP_MACRO_UNTERMINATED_INVOCATION:
return "unterminated macro invocation"; return "unterminated macro invocation";
case MACRO_TOO_FEW_ARGS: case PP_MACRO_TOO_FEW_ARGS:
return "Not enough arguments for macro"; return "Not enough arguments for macro";
case MACRO_TOO_MANY_ARGS: case PP_MACRO_TOO_MANY_ARGS:
return "Too many arguments for macro"; return "Too many arguments for macro";
case CONDITIONAL_ENDIF_WITHOUT_IF: case PP_CONDITIONAL_ENDIF_WITHOUT_IF:
return "unexpected #endif found without a matching #if"; return "unexpected #endif found without a matching #if";
case CONDITIONAL_ELSE_WITHOUT_IF: case PP_CONDITIONAL_ELSE_WITHOUT_IF:
return "unexpected #else found without a matching #if"; return "unexpected #else found without a matching #if";
case CONDITIONAL_ELSE_AFTER_ELSE: case PP_CONDITIONAL_ELSE_AFTER_ELSE:
return "unexpected #else found after another #else"; return "unexpected #else found after another #else";
case CONDITIONAL_ELIF_WITHOUT_IF: case PP_CONDITIONAL_ELIF_WITHOUT_IF:
return "unexpected #elif found without a matching #if"; return "unexpected #elif found without a matching #if";
case CONDITIONAL_ELIF_AFTER_ELSE: case PP_CONDITIONAL_ELIF_AFTER_ELSE:
return "unexpected #elif found after #else"; return "unexpected #elif found after #else";
case CONDITIONAL_UNTERMINATED: case PP_CONDITIONAL_UNTERMINATED:
return "unexpected end of file found in conditional block"; return "unexpected end of file found in conditional block";
case INVALID_EXTENSION_NAME: case PP_INVALID_EXTENSION_NAME:
return "invalid extension name"; return "invalid extension name";
case INVALID_EXTENSION_BEHAVIOR: case PP_INVALID_EXTENSION_BEHAVIOR:
return "invalid extension behavior"; return "invalid extension behavior";
case INVALID_EXTENSION_DIRECTIVE: case PP_INVALID_EXTENSION_DIRECTIVE:
return "invalid extension directive"; return "invalid extension directive";
case INVALID_VERSION_NUMBER: case PP_INVALID_VERSION_NUMBER:
return "invalid version number"; return "invalid version number";
case INVALID_VERSION_DIRECTIVE: case PP_INVALID_VERSION_DIRECTIVE:
return "invalid version directive"; return "invalid version directive";
case VERSION_NOT_FIRST_STATEMENT: case PP_VERSION_NOT_FIRST_STATEMENT:
return "#version directive must occur before anything else, " return "#version directive must occur before anything else, "
"except for comments and white space"; "except for comments and white space";
case INVALID_LINE_NUMBER: case PP_INVALID_LINE_NUMBER:
return "invalid line number"; return "invalid line number";
case INVALID_FILE_NUMBER: case PP_INVALID_FILE_NUMBER:
return "invalid file number"; return "invalid file number";
case INVALID_LINE_DIRECTIVE: case PP_INVALID_LINE_DIRECTIVE:
return "invalid line directive"; return "invalid line directive";
// Errors end. // Errors end.
// Warnings begin. // Warnings begin.
case EOF_IN_DIRECTIVE: case PP_EOF_IN_DIRECTIVE:
return "unexpected end of file found in directive"; return "unexpected end of file found in directive";
case CONDITIONAL_UNEXPECTED_TOKEN: case PP_CONDITIONAL_UNEXPECTED_TOKEN:
return "unexpected token after conditional expression"; return "unexpected token after conditional expression";
case UNRECOGNIZED_PRAGMA: case PP_UNRECOGNIZED_PRAGMA:
return "unrecognized pragma"; return "unrecognized pragma";
// Warnings end. // Warnings end.
default: default:
......
...@@ -21,53 +21,53 @@ class Diagnostics ...@@ -21,53 +21,53 @@ class Diagnostics
public: public:
enum Severity enum Severity
{ {
ERROR, PP_ERROR,
WARNING PP_WARNING
}; };
enum ID enum ID
{ {
ERROR_BEGIN, PP_ERROR_BEGIN,
INTERNAL_ERROR, PP_INTERNAL_ERROR,
OUT_OF_MEMORY, PP_OUT_OF_MEMORY,
INVALID_CHARACTER, PP_INVALID_CHARACTER,
INVALID_NUMBER, PP_INVALID_NUMBER,
INTEGER_OVERFLOW, PP_INTEGER_OVERFLOW,
FLOAT_OVERFLOW, PP_FLOAT_OVERFLOW,
TOKEN_TOO_LONG, PP_TOKEN_TOO_LONG,
INVALID_EXPRESSION, PP_INVALID_EXPRESSION,
DIVISION_BY_ZERO, PP_DIVISION_BY_ZERO,
EOF_IN_COMMENT, PP_EOF_IN_COMMENT,
UNEXPECTED_TOKEN, PP_UNEXPECTED_TOKEN,
DIRECTIVE_INVALID_NAME, PP_DIRECTIVE_INVALID_NAME,
MACRO_NAME_RESERVED, PP_MACRO_NAME_RESERVED,
MACRO_REDEFINED, PP_MACRO_REDEFINED,
MACRO_PREDEFINED_REDEFINED, PP_MACRO_PREDEFINED_REDEFINED,
MACRO_PREDEFINED_UNDEFINED, PP_MACRO_PREDEFINED_UNDEFINED,
MACRO_UNTERMINATED_INVOCATION, PP_MACRO_UNTERMINATED_INVOCATION,
MACRO_TOO_FEW_ARGS, PP_MACRO_TOO_FEW_ARGS,
MACRO_TOO_MANY_ARGS, PP_MACRO_TOO_MANY_ARGS,
CONDITIONAL_ENDIF_WITHOUT_IF, PP_CONDITIONAL_ENDIF_WITHOUT_IF,
CONDITIONAL_ELSE_WITHOUT_IF, PP_CONDITIONAL_ELSE_WITHOUT_IF,
CONDITIONAL_ELSE_AFTER_ELSE, PP_CONDITIONAL_ELSE_AFTER_ELSE,
CONDITIONAL_ELIF_WITHOUT_IF, PP_CONDITIONAL_ELIF_WITHOUT_IF,
CONDITIONAL_ELIF_AFTER_ELSE, PP_CONDITIONAL_ELIF_AFTER_ELSE,
CONDITIONAL_UNTERMINATED, PP_CONDITIONAL_UNTERMINATED,
INVALID_EXTENSION_NAME, PP_INVALID_EXTENSION_NAME,
INVALID_EXTENSION_BEHAVIOR, PP_INVALID_EXTENSION_BEHAVIOR,
INVALID_EXTENSION_DIRECTIVE, PP_INVALID_EXTENSION_DIRECTIVE,
INVALID_VERSION_NUMBER, PP_INVALID_VERSION_NUMBER,
INVALID_VERSION_DIRECTIVE, PP_INVALID_VERSION_DIRECTIVE,
VERSION_NOT_FIRST_STATEMENT, PP_VERSION_NOT_FIRST_STATEMENT,
INVALID_LINE_NUMBER, PP_INVALID_LINE_NUMBER,
INVALID_FILE_NUMBER, PP_INVALID_FILE_NUMBER,
INVALID_LINE_DIRECTIVE, PP_INVALID_LINE_DIRECTIVE,
ERROR_END, PP_ERROR_END,
WARNING_BEGIN, PP_WARNING_BEGIN,
EOF_IN_DIRECTIVE, PP_EOF_IN_DIRECTIVE,
CONDITIONAL_UNEXPECTED_TOKEN, PP_CONDITIONAL_UNEXPECTED_TOKEN,
UNRECOGNIZED_PRAGMA, PP_UNRECOGNIZED_PRAGMA,
WARNING_END PP_WARNING_END
}; };
virtual ~Diagnostics(); virtual ~Diagnostics();
......
...@@ -172,7 +172,7 @@ class DefinedParser : public Lexer ...@@ -172,7 +172,7 @@ class DefinedParser : public Lexer
if (token->type != Token::IDENTIFIER) if (token->type != Token::IDENTIFIER)
{ {
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text); token->location, token->text);
skipUntilEOD(mLexer, token); skipUntilEOD(mLexer, token);
return; return;
...@@ -185,7 +185,7 @@ class DefinedParser : public Lexer ...@@ -185,7 +185,7 @@ class DefinedParser : public Lexer
mLexer->lex(token); mLexer->lex(token);
if (token->type != ')') if (token->type != ')')
{ {
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text); token->location, token->text);
skipUntilEOD(mLexer, token); skipUntilEOD(mLexer, token);
return; return;
...@@ -233,7 +233,7 @@ void DirectiveParser::lex(Token* token) ...@@ -233,7 +233,7 @@ void DirectiveParser::lex(Token* token)
if (!mConditionalStack.empty()) if (!mConditionalStack.empty())
{ {
const ConditionalBlock& block = mConditionalStack.back(); const ConditionalBlock& block = mConditionalStack.back();
mDiagnostics->report(Diagnostics::CONDITIONAL_UNTERMINATED, mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNTERMINATED,
block.location, block.type); block.location, block.type);
} }
break; break;
...@@ -268,7 +268,7 @@ void DirectiveParser::parseDirective(Token* token) ...@@ -268,7 +268,7 @@ void DirectiveParser::parseDirective(Token* token)
switch(directive) switch(directive)
{ {
case DIRECTIVE_NONE: case DIRECTIVE_NONE:
mDiagnostics->report(Diagnostics::DIRECTIVE_INVALID_NAME, mDiagnostics->report(Diagnostics::PP_DIRECTIVE_INVALID_NAME,
token->location, token->text); token->location, token->text);
skipUntilEOD(mTokenizer, token); skipUntilEOD(mTokenizer, token);
break; break;
...@@ -319,7 +319,7 @@ void DirectiveParser::parseDirective(Token* token) ...@@ -319,7 +319,7 @@ void DirectiveParser::parseDirective(Token* token)
skipUntilEOD(mTokenizer, token); skipUntilEOD(mTokenizer, token);
if (token->type == Token::LAST) if (token->type == Token::LAST)
{ {
mDiagnostics->report(Diagnostics::EOF_IN_DIRECTIVE, mDiagnostics->report(Diagnostics::PP_EOF_IN_DIRECTIVE,
token->location, token->text); token->location, token->text);
} }
} }
...@@ -331,19 +331,19 @@ void DirectiveParser::parseDefine(Token* token) ...@@ -331,19 +331,19 @@ void DirectiveParser::parseDefine(Token* token)
mTokenizer->lex(token); mTokenizer->lex(token);
if (token->type != Token::IDENTIFIER) if (token->type != Token::IDENTIFIER)
{ {
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text); token->location, token->text);
return; return;
} }
if (isMacroPredefined(token->text, *mMacroSet)) if (isMacroPredefined(token->text, *mMacroSet))
{ {
mDiagnostics->report(Diagnostics::MACRO_PREDEFINED_REDEFINED, mDiagnostics->report(Diagnostics::PP_MACRO_PREDEFINED_REDEFINED,
token->location, token->text); token->location, token->text);
return; return;
} }
if (isMacroNameReserved(token->text)) if (isMacroNameReserved(token->text))
{ {
mDiagnostics->report(Diagnostics::MACRO_NAME_RESERVED, mDiagnostics->report(Diagnostics::PP_MACRO_NAME_RESERVED,
token->location, token->text); token->location, token->text);
return; return;
} }
...@@ -368,7 +368,7 @@ void DirectiveParser::parseDefine(Token* token) ...@@ -368,7 +368,7 @@ void DirectiveParser::parseDefine(Token* token)
if (token->type != ')') if (token->type != ')')
{ {
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->location,
token->text); token->text);
return; return;
...@@ -396,7 +396,7 @@ void DirectiveParser::parseDefine(Token* token) ...@@ -396,7 +396,7 @@ void DirectiveParser::parseDefine(Token* token)
MacroSet::const_iterator iter = mMacroSet->find(macro.name); MacroSet::const_iterator iter = mMacroSet->find(macro.name);
if (iter != mMacroSet->end() && !macro.equals(iter->second)) if (iter != mMacroSet->end() && !macro.equals(iter->second))
{ {
mDiagnostics->report(Diagnostics::MACRO_REDEFINED, mDiagnostics->report(Diagnostics::PP_MACRO_REDEFINED,
token->location, token->location,
macro.name); macro.name);
return; return;
...@@ -411,7 +411,7 @@ void DirectiveParser::parseUndef(Token* token) ...@@ -411,7 +411,7 @@ void DirectiveParser::parseUndef(Token* token)
mTokenizer->lex(token); mTokenizer->lex(token);
if (token->type != Token::IDENTIFIER) if (token->type != Token::IDENTIFIER)
{ {
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text); token->location, token->text);
return; return;
} }
...@@ -421,7 +421,7 @@ void DirectiveParser::parseUndef(Token* token) ...@@ -421,7 +421,7 @@ void DirectiveParser::parseUndef(Token* token)
{ {
if (iter->second.predefined) if (iter->second.predefined)
{ {
mDiagnostics->report(Diagnostics::MACRO_PREDEFINED_UNDEFINED, mDiagnostics->report(Diagnostics::PP_MACRO_PREDEFINED_UNDEFINED,
token->location, token->text); token->location, token->text);
} }
else else
...@@ -457,7 +457,7 @@ void DirectiveParser::parseElse(Token* token) ...@@ -457,7 +457,7 @@ void DirectiveParser::parseElse(Token* token)
if (mConditionalStack.empty()) if (mConditionalStack.empty())
{ {
mDiagnostics->report(Diagnostics::CONDITIONAL_ELSE_WITHOUT_IF, mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELSE_WITHOUT_IF,
token->location, token->text); token->location, token->text);
skipUntilEOD(mTokenizer, token); skipUntilEOD(mTokenizer, token);
return; return;
...@@ -472,7 +472,7 @@ void DirectiveParser::parseElse(Token* token) ...@@ -472,7 +472,7 @@ void DirectiveParser::parseElse(Token* token)
} }
if (block.foundElseGroup) if (block.foundElseGroup)
{ {
mDiagnostics->report(Diagnostics::CONDITIONAL_ELSE_AFTER_ELSE, mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELSE_AFTER_ELSE,
token->location, token->text); token->location, token->text);
skipUntilEOD(mTokenizer, token); skipUntilEOD(mTokenizer, token);
return; return;
...@@ -486,7 +486,7 @@ void DirectiveParser::parseElse(Token* token) ...@@ -486,7 +486,7 @@ void DirectiveParser::parseElse(Token* token)
mTokenizer->lex(token); mTokenizer->lex(token);
if (!isEOD(token)) if (!isEOD(token))
{ {
mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN, mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN,
token->location, token->text); token->location, token->text);
skipUntilEOD(mTokenizer, token); skipUntilEOD(mTokenizer, token);
} }
...@@ -498,7 +498,7 @@ void DirectiveParser::parseElif(Token* token) ...@@ -498,7 +498,7 @@ void DirectiveParser::parseElif(Token* token)
if (mConditionalStack.empty()) if (mConditionalStack.empty())
{ {
mDiagnostics->report(Diagnostics::CONDITIONAL_ELIF_WITHOUT_IF, mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELIF_WITHOUT_IF,
token->location, token->text); token->location, token->text);
skipUntilEOD(mTokenizer, token); skipUntilEOD(mTokenizer, token);
return; return;
...@@ -513,7 +513,7 @@ void DirectiveParser::parseElif(Token* token) ...@@ -513,7 +513,7 @@ void DirectiveParser::parseElif(Token* token)
} }
if (block.foundElseGroup) if (block.foundElseGroup)
{ {
mDiagnostics->report(Diagnostics::CONDITIONAL_ELIF_AFTER_ELSE, mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELIF_AFTER_ELSE,
token->location, token->text); token->location, token->text);
skipUntilEOD(mTokenizer, token); skipUntilEOD(mTokenizer, token);
return; return;
...@@ -538,7 +538,7 @@ void DirectiveParser::parseEndif(Token* token) ...@@ -538,7 +538,7 @@ void DirectiveParser::parseEndif(Token* token)
if (mConditionalStack.empty()) if (mConditionalStack.empty())
{ {
mDiagnostics->report(Diagnostics::CONDITIONAL_ENDIF_WITHOUT_IF, mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ENDIF_WITHOUT_IF,
token->location, token->text); token->location, token->text);
skipUntilEOD(mTokenizer, token); skipUntilEOD(mTokenizer, token);
return; return;
...@@ -550,7 +550,7 @@ void DirectiveParser::parseEndif(Token* token) ...@@ -550,7 +550,7 @@ void DirectiveParser::parseEndif(Token* token)
mTokenizer->lex(token); mTokenizer->lex(token);
if (!isEOD(token)) if (!isEOD(token))
{ {
mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN, mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN,
token->location, token->text); token->location, token->text);
skipUntilEOD(mTokenizer, token); skipUntilEOD(mTokenizer, token);
} }
...@@ -618,7 +618,7 @@ void DirectiveParser::parsePragma(Token* token) ...@@ -618,7 +618,7 @@ void DirectiveParser::parsePragma(Token* token)
(state == RIGHT_PAREN + 1)); // With value. (state == RIGHT_PAREN + 1)); // With value.
if (!valid) if (!valid)
{ {
mDiagnostics->report(Diagnostics::UNRECOGNIZED_PRAGMA, mDiagnostics->report(Diagnostics::PP_UNRECOGNIZED_PRAGMA,
token->location, name); token->location, name);
} }
else if (state > PRAGMA_NAME) // Do not notify for empty pragma. else if (state > PRAGMA_NAME) // Do not notify for empty pragma.
...@@ -650,7 +650,7 @@ void DirectiveParser::parseExtension(Token* token) ...@@ -650,7 +650,7 @@ void DirectiveParser::parseExtension(Token* token)
case EXT_NAME: case EXT_NAME:
if (valid && (token->type != Token::IDENTIFIER)) if (valid && (token->type != Token::IDENTIFIER))
{ {
mDiagnostics->report(Diagnostics::INVALID_EXTENSION_NAME, mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_NAME,
token->location, token->text); token->location, token->text);
valid = false; valid = false;
} }
...@@ -659,7 +659,7 @@ void DirectiveParser::parseExtension(Token* token) ...@@ -659,7 +659,7 @@ void DirectiveParser::parseExtension(Token* token)
case COLON: case COLON:
if (valid && (token->type != ':')) if (valid && (token->type != ':'))
{ {
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text); token->location, token->text);
valid = false; valid = false;
} }
...@@ -667,7 +667,7 @@ void DirectiveParser::parseExtension(Token* token) ...@@ -667,7 +667,7 @@ void DirectiveParser::parseExtension(Token* token)
case EXT_BEHAVIOR: case EXT_BEHAVIOR:
if (valid && (token->type != Token::IDENTIFIER)) if (valid && (token->type != Token::IDENTIFIER))
{ {
mDiagnostics->report(Diagnostics::INVALID_EXTENSION_BEHAVIOR, mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_BEHAVIOR,
token->location, token->text); token->location, token->text);
valid = false; valid = false;
} }
...@@ -676,7 +676,7 @@ void DirectiveParser::parseExtension(Token* token) ...@@ -676,7 +676,7 @@ void DirectiveParser::parseExtension(Token* token)
default: default:
if (valid) if (valid)
{ {
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text); token->location, token->text);
valid = false; valid = false;
} }
...@@ -686,7 +686,7 @@ void DirectiveParser::parseExtension(Token* token) ...@@ -686,7 +686,7 @@ void DirectiveParser::parseExtension(Token* token)
} }
if (valid && (state != EXT_BEHAVIOR + 1)) if (valid && (state != EXT_BEHAVIOR + 1))
{ {
mDiagnostics->report(Diagnostics::INVALID_EXTENSION_DIRECTIVE, mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_DIRECTIVE,
token->location, token->text); token->location, token->text);
valid = false; valid = false;
} }
...@@ -700,7 +700,7 @@ void DirectiveParser::parseVersion(Token* token) ...@@ -700,7 +700,7 @@ void DirectiveParser::parseVersion(Token* token)
if (mPastFirstStatement) if (mPastFirstStatement)
{ {
mDiagnostics->report(Diagnostics::VERSION_NOT_FIRST_STATEMENT, mDiagnostics->report(Diagnostics::PP_VERSION_NOT_FIRST_STATEMENT,
token->location, token->text); token->location, token->text);
skipUntilEOD(mTokenizer, token); skipUntilEOD(mTokenizer, token);
return; return;
...@@ -723,13 +723,13 @@ void DirectiveParser::parseVersion(Token* token) ...@@ -723,13 +723,13 @@ void DirectiveParser::parseVersion(Token* token)
case VERSION_NUMBER: case VERSION_NUMBER:
if (valid && (token->type != Token::CONST_INT)) if (valid && (token->type != Token::CONST_INT))
{ {
mDiagnostics->report(Diagnostics::INVALID_VERSION_NUMBER, mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_NUMBER,
token->location, token->text); token->location, token->text);
valid = false; valid = false;
} }
if (valid && !token->iValue(&version)) if (valid && !token->iValue(&version))
{ {
mDiagnostics->report(Diagnostics::INTEGER_OVERFLOW, mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW,
token->location, token->text); token->location, token->text);
valid = false; valid = false;
} }
...@@ -737,7 +737,7 @@ void DirectiveParser::parseVersion(Token* token) ...@@ -737,7 +737,7 @@ void DirectiveParser::parseVersion(Token* token)
default: default:
if (valid) if (valid)
{ {
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text); token->location, token->text);
valid = false; valid = false;
} }
...@@ -747,7 +747,7 @@ void DirectiveParser::parseVersion(Token* token) ...@@ -747,7 +747,7 @@ void DirectiveParser::parseVersion(Token* token)
} }
if (valid && (state != VERSION_NUMBER + 1)) if (valid && (state != VERSION_NUMBER + 1))
{ {
mDiagnostics->report(Diagnostics::INVALID_VERSION_DIRECTIVE, mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_DIRECTIVE,
token->location, token->text); token->location, token->text);
valid = false; valid = false;
} }
...@@ -778,13 +778,13 @@ void DirectiveParser::parseLine(Token* token) ...@@ -778,13 +778,13 @@ void DirectiveParser::parseLine(Token* token)
case LINE_NUMBER: case LINE_NUMBER:
if (valid && (token->type != Token::CONST_INT)) if (valid && (token->type != Token::CONST_INT))
{ {
mDiagnostics->report(Diagnostics::INVALID_LINE_NUMBER, mDiagnostics->report(Diagnostics::PP_INVALID_LINE_NUMBER,
token->location, token->text); token->location, token->text);
valid = false; valid = false;
} }
if (valid && !token->iValue(&line)) if (valid && !token->iValue(&line))
{ {
mDiagnostics->report(Diagnostics::INTEGER_OVERFLOW, mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW,
token->location, token->text); token->location, token->text);
valid = false; valid = false;
} }
...@@ -792,13 +792,13 @@ void DirectiveParser::parseLine(Token* token) ...@@ -792,13 +792,13 @@ void DirectiveParser::parseLine(Token* token)
case FILE_NUMBER: case FILE_NUMBER:
if (valid && (token->type != Token::CONST_INT)) if (valid && (token->type != Token::CONST_INT))
{ {
mDiagnostics->report(Diagnostics::INVALID_FILE_NUMBER, mDiagnostics->report(Diagnostics::PP_INVALID_FILE_NUMBER,
token->location, token->text); token->location, token->text);
valid = false; valid = false;
} }
if (valid && !token->iValue(&file)) if (valid && !token->iValue(&file))
{ {
mDiagnostics->report(Diagnostics::INTEGER_OVERFLOW, mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW,
token->location, token->text); token->location, token->text);
valid = false; valid = false;
} }
...@@ -806,7 +806,7 @@ void DirectiveParser::parseLine(Token* token) ...@@ -806,7 +806,7 @@ void DirectiveParser::parseLine(Token* token)
default: default:
if (valid) if (valid)
{ {
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text); token->location, token->text);
valid = false; valid = false;
} }
...@@ -817,7 +817,7 @@ void DirectiveParser::parseLine(Token* token) ...@@ -817,7 +817,7 @@ void DirectiveParser::parseLine(Token* token)
if (valid && (state != FILE_NUMBER) && (state != FILE_NUMBER + 1)) if (valid && (state != FILE_NUMBER) && (state != FILE_NUMBER + 1))
{ {
mDiagnostics->report(Diagnostics::INVALID_LINE_DIRECTIVE, mDiagnostics->report(Diagnostics::PP_INVALID_LINE_DIRECTIVE,
token->location, token->text); token->location, token->text);
valid = false; valid = false;
} }
...@@ -893,7 +893,7 @@ int DirectiveParser::parseExpressionIf(Token* token) ...@@ -893,7 +893,7 @@ int DirectiveParser::parseExpressionIf(Token* token)
// Warn if there are tokens after #if expression. // Warn if there are tokens after #if expression.
if (!isEOD(token)) if (!isEOD(token))
{ {
mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN, mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN,
token->location, token->text); token->location, token->text);
skipUntilEOD(mTokenizer, token); skipUntilEOD(mTokenizer, token);
} }
...@@ -909,7 +909,7 @@ int DirectiveParser::parseExpressionIfdef(Token* token) ...@@ -909,7 +909,7 @@ int DirectiveParser::parseExpressionIfdef(Token* token)
mTokenizer->lex(token); mTokenizer->lex(token);
if (token->type != Token::IDENTIFIER) if (token->type != Token::IDENTIFIER)
{ {
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN, mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text); token->location, token->text);
skipUntilEOD(mTokenizer, token); skipUntilEOD(mTokenizer, token);
return 0; return 0;
...@@ -922,7 +922,7 @@ int DirectiveParser::parseExpressionIfdef(Token* token) ...@@ -922,7 +922,7 @@ int DirectiveParser::parseExpressionIfdef(Token* token)
mTokenizer->lex(token); mTokenizer->lex(token);
if (!isEOD(token)) if (!isEOD(token))
{ {
mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN, mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN,
token->location, token->text); token->location, token->text);
skipUntilEOD(mTokenizer, token); skipUntilEOD(mTokenizer, token);
} }
......
...@@ -1587,7 +1587,7 @@ yyreduce: ...@@ -1587,7 +1587,7 @@ yyreduce:
std::ostringstream stream; std::ostringstream stream;
stream << (yyvsp[(1) - (3)]) << " % " << (yyvsp[(3) - (3)]); stream << (yyvsp[(1) - (3)]) << " % " << (yyvsp[(3) - (3)]);
std::string text = stream.str(); std::string text = stream.str();
context->diagnostics->report(pp::Diagnostics::DIVISION_BY_ZERO, context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
context->token->location, context->token->location,
text.c_str()); text.c_str());
YYABORT; YYABORT;
...@@ -1604,7 +1604,7 @@ yyreduce: ...@@ -1604,7 +1604,7 @@ yyreduce:
std::ostringstream stream; std::ostringstream stream;
stream << (yyvsp[(1) - (3)]) << " / " << (yyvsp[(3) - (3)]); stream << (yyvsp[(1) - (3)]) << " / " << (yyvsp[(3) - (3)]);
std::string text = stream.str(); std::string text = stream.str();
context->diagnostics->report(pp::Diagnostics::DIVISION_BY_ZERO, context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
context->token->location, context->token->location,
text.c_str()); text.c_str());
YYABORT; YYABORT;
...@@ -1903,7 +1903,7 @@ int yylex(YYSTYPE* lvalp, Context* context) ...@@ -1903,7 +1903,7 @@ int yylex(YYSTYPE* lvalp, Context* context)
unsigned int val = 0; unsigned int val = 0;
if (!token->uValue(&val)) if (!token->uValue(&val))
{ {
context->diagnostics->report(pp::Diagnostics::INTEGER_OVERFLOW, context->diagnostics->report(pp::Diagnostics::PP_INTEGER_OVERFLOW,
token->location, token->text); token->location, token->text);
} }
*lvalp = static_cast<YYSTYPE>(val); *lvalp = static_cast<YYSTYPE>(val);
...@@ -1944,7 +1944,7 @@ int yylex(YYSTYPE* lvalp, Context* context) ...@@ -1944,7 +1944,7 @@ int yylex(YYSTYPE* lvalp, Context* context)
void yyerror(Context* context, const char* reason) void yyerror(Context* context, const char* reason)
{ {
context->diagnostics->report(pp::Diagnostics::INVALID_EXPRESSION, context->diagnostics->report(pp::Diagnostics::PP_INVALID_EXPRESSION,
context->token->location, context->token->location,
reason); reason);
} }
...@@ -1972,12 +1972,12 @@ bool ExpressionParser::parse(Token* token, int* result) ...@@ -1972,12 +1972,12 @@ bool ExpressionParser::parse(Token* token, int* result)
break; break;
case 2: case 2:
mDiagnostics->report(Diagnostics::OUT_OF_MEMORY, token->location, ""); mDiagnostics->report(Diagnostics::PP_OUT_OF_MEMORY, token->location, "");
break; break;
default: default:
assert(false); assert(false);
mDiagnostics->report(Diagnostics::INTERNAL_ERROR, token->location, ""); mDiagnostics->report(Diagnostics::PP_INTERNAL_ERROR, token->location, "");
break; break;
} }
......
...@@ -254,7 +254,7 @@ bool MacroExpander::collectMacroArgs(const Macro& macro, ...@@ -254,7 +254,7 @@ bool MacroExpander::collectMacroArgs(const Macro& macro,
if (token.type == Token::LAST) if (token.type == Token::LAST)
{ {
mDiagnostics->report(Diagnostics::MACRO_UNTERMINATED_INVOCATION, mDiagnostics->report(Diagnostics::PP_MACRO_UNTERMINATED_INVOCATION,
identifier.location, identifier.text); identifier.location, identifier.text);
// Do not lose EOF token. // Do not lose EOF token.
ungetToken(token); ungetToken(token);
...@@ -302,8 +302,8 @@ bool MacroExpander::collectMacroArgs(const Macro& macro, ...@@ -302,8 +302,8 @@ bool MacroExpander::collectMacroArgs(const Macro& macro,
if (args->size() != params.size()) if (args->size() != params.size())
{ {
Diagnostics::ID id = args->size() < macro.parameters.size() ? Diagnostics::ID id = args->size() < macro.parameters.size() ?
Diagnostics::MACRO_TOO_FEW_ARGS : Diagnostics::PP_MACRO_TOO_FEW_ARGS :
Diagnostics::MACRO_TOO_MANY_ARGS; Diagnostics::PP_MACRO_TOO_MANY_ARGS;
mDiagnostics->report(id, identifier.location, identifier.text); mDiagnostics->report(id, identifier.location, identifier.text);
return false; return false;
} }
......
...@@ -101,11 +101,11 @@ void Preprocessor::lex(Token* token) ...@@ -101,11 +101,11 @@ void Preprocessor::lex(Token* token)
assert(false); assert(false);
break; break;
case Token::PP_NUMBER: case Token::PP_NUMBER:
mImpl->diagnostics->report(Diagnostics::INVALID_NUMBER, mImpl->diagnostics->report(Diagnostics::PP_INVALID_NUMBER,
token->location, token->text); token->location, token->text);
break; break;
case Token::PP_OTHER: case Token::PP_OTHER:
mImpl->diagnostics->report(Diagnostics::INVALID_CHARACTER, mImpl->diagnostics->report(Diagnostics::PP_INVALID_CHARACTER,
token->location, token->text); token->location, token->text);
break; break;
default: default:
......
...@@ -1143,7 +1143,7 @@ case YY_STATE_EOF(COMMENT): ...@@ -1143,7 +1143,7 @@ case YY_STATE_EOF(COMMENT):
if (YY_START == COMMENT) if (YY_START == COMMENT)
{ {
yyextra->diagnostics->report(pp::Diagnostics::EOF_IN_COMMENT, yyextra->diagnostics->report(pp::Diagnostics::PP_EOF_IN_COMMENT,
pp::SourceLocation(yyfileno, yylineno), pp::SourceLocation(yyfileno, yylineno),
""); "");
} }
...@@ -2327,7 +2327,7 @@ void Tokenizer::lex(Token* token) ...@@ -2327,7 +2327,7 @@ void Tokenizer::lex(Token* token)
token->type = pplex(&token->text,&token->location,mHandle); token->type = pplex(&token->text,&token->location,mHandle);
if (token->text.size() > mMaxTokenLength) if (token->text.size() > mMaxTokenLength)
{ {
mContext.diagnostics->report(Diagnostics::TOKEN_TOO_LONG, mContext.diagnostics->report(Diagnostics::PP_TOKEN_TOO_LONG,
token->location, token->text); token->location, token->text);
token->text.erase(mMaxTokenLength); token->text.erase(mMaxTokenLength);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment