Commit 4c8cae60 by Geoff Lang

Revert "Don't mark all macros with double underscores as reserved."

Fails a WebGL CTS test. BUG=angleproject:989 This reverts commit 942e3625. Change-Id: I9f833366d5b69535ef74e358ac21efaccb1f1a3d Reviewed-on: https://chromium-review.googlesource.com/268751Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 942e3625
...@@ -118,28 +118,13 @@ void skipUntilEOD(pp::Lexer *lexer, pp::Token *token) ...@@ -118,28 +118,13 @@ void skipUntilEOD(pp::Lexer *lexer, pp::Token *token)
bool isMacroNameReserved(const std::string &name) bool isMacroNameReserved(const std::string &name)
{ {
const char *kPredefinedMacros[] =
{
"__LINE__",
"__FILE__",
"__VERSION__",
"GL_ES",
};
const size_t kPredefinedMacrosCount = sizeof(kPredefinedMacros) / sizeof(*kPredefinedMacros);
for (size_t i = 0; i < kPredefinedMacrosCount; i++)
{
if (name == kPredefinedMacros[i])
{
return true;
}
}
// Names prefixed with "GL_" are reserved. // Names prefixed with "GL_" are reserved.
if (name.compare(0, 3, "GL_") == 0) if (name.substr(0, 3) == "GL_")
{ return true;
// Names containing two consecutive underscores are reserved.
if (name.find("__") != std::string::npos)
return true; return true;
}
return false; return false;
} }
......
...@@ -65,24 +65,32 @@ TEST_F(DefineTest, RedefinePredefined) ...@@ -65,24 +65,32 @@ TEST_F(DefineTest, RedefinePredefined)
preprocess(input, expected); preprocess(input, expected);
} }
TEST_F(DefineTest, UnderScore1) TEST_F(DefineTest, ReservedUnderScore1)
{ {
const char* input = "#define __foo bar\n"; const char* input = "#define __foo bar\n"
const char* expected = "\n"; "__foo\n";
const char* expected = "\n"
"__foo\n";
using testing::_; EXPECT_CALL(mDiagnostics,
EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); print(pp::Diagnostics::PP_MACRO_NAME_RESERVED,
pp::SourceLocation(0, 1),
"__foo"));
preprocess(input, expected); preprocess(input, expected);
} }
TEST_F(DefineTest, UnderScore2) TEST_F(DefineTest, ReservedUnderScore2)
{ {
const char* input = "#define foo__bar baz\n"; const char* input = "#define foo__bar baz\n"
const char* expected = "\n"; "foo__bar\n";
const char* expected = "\n"
"foo__bar\n";
using testing::_; EXPECT_CALL(mDiagnostics,
EXPECT_CALL(mDiagnostics, print(_, _, _)).Times(0); print(pp::Diagnostics::PP_MACRO_NAME_RESERVED,
pp::SourceLocation(0, 1),
"foo__bar"));
preprocess(input, expected); preprocess(input, expected);
} }
......
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