Commit 7bd3d395 by Nicolas Capens

Fix treating undefined preprocessor identifiers as error.

Change-Id: Ifa9db4ab541d9421dddfe6b09571d8b5d38a479d Reviewed-on: https://swiftshader-review.googlesource.com/5011Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 4df0c65b
......@@ -109,6 +109,8 @@ std::string Diagnostics::message(ID id)
return "invalid file number";
case INVALID_LINE_DIRECTIVE:
return "invalid line directive";
case UNDEFINED_IDENTIFIER:
return "undefined identifier";
// Errors end.
// Warnings begin.
case EOF_IN_DIRECTIVE:
......
......@@ -61,6 +61,7 @@ class Diagnostics
INVALID_LINE_NUMBER,
INVALID_FILE_NUMBER,
INVALID_LINE_DIRECTIVE,
UNDEFINED_IDENTIFIER,
ERROR_END,
WARNING_BEGIN,
......
......@@ -1762,6 +1762,16 @@ int yylex(YYSTYPE* lvalp, Context* context)
type = TOK_CONST_INT;
break;
}
case pp::Token::IDENTIFIER:
// Defined identifiers should have been expanded already.
// Unlike the C/C++ preprocessor, it does not default to 0.
// Use of such identifiers causes an error.
context->diagnostics->report(pp::Diagnostics::UNDEFINED_IDENTIFIER,
token->location, token->text);
*lvalp = 0;
type = TOK_CONST_INT;
break;
case pp::Token::OP_OR: type = TOK_OP_OR; break;
case pp::Token::OP_AND: type = TOK_OP_AND; break;
case pp::Token::OP_NE: type = TOK_OP_NE; break;
......
......@@ -194,6 +194,16 @@ int yylex(YYSTYPE* lvalp, Context* context)
type = TOK_CONST_INT;
break;
}
case pp::Token::IDENTIFIER:
// Defined identifiers should have been expanded already.
// Unlike the C/C++ preprocessor, it does not default to 0.
// Use of such identifiers causes an error.
context->diagnostics->report(pp::Diagnostics::UNDEFINED_IDENTIFIER,
token->location, token->text);
*lvalp = 0;
type = TOK_CONST_INT;
break;
case pp::Token::OP_OR: type = TOK_OP_OR; break;
case pp::Token::OP_AND: type = TOK_OP_AND; break;
case pp::Token::OP_NE: type = TOK_OP_NE; break;
......
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