Preprocessor: Let the Tokenizer handle NULL
This commit is contained in:
parent
dc0ecb1082
commit
f0ce26a2aa
|
@ -2765,7 +2765,7 @@ std::string Preprocessor::expandMacros(const std::string &code, std::string file
|
||||||
// defining a macro..
|
// defining a macro..
|
||||||
if (line.compare(0, 8, "#define ") == 0) {
|
if (line.compare(0, 8, "#define ") == 0) {
|
||||||
PreprocessorMacro *macro = new PreprocessorMacro(line.substr(8));
|
PreprocessorMacro *macro = new PreprocessorMacro(line.substr(8));
|
||||||
if (macro->name().empty()) {
|
if (macro->name().empty() || macro->name() == "NULL") {
|
||||||
delete macro;
|
delete macro;
|
||||||
} else if (macro->name() == "BOOST_FOREACH") {
|
} else if (macro->name() == "BOOST_FOREACH") {
|
||||||
// BOOST_FOREACH is currently too complex to parse, so skip it.
|
// BOOST_FOREACH is currently too complex to parse, so skip it.
|
||||||
|
|
|
@ -182,6 +182,7 @@ private:
|
||||||
TEST_CASE(macro_linenumbers);
|
TEST_CASE(macro_linenumbers);
|
||||||
TEST_CASE(macro_nopar);
|
TEST_CASE(macro_nopar);
|
||||||
TEST_CASE(macro_switchCase);
|
TEST_CASE(macro_switchCase);
|
||||||
|
TEST_CASE(macro_NULL); // skip #define NULL .. it is replaced in the tokenizer
|
||||||
TEST_CASE(string1);
|
TEST_CASE(string1);
|
||||||
TEST_CASE(string2);
|
TEST_CASE(string2);
|
||||||
TEST_CASE(string3);
|
TEST_CASE(string3);
|
||||||
|
@ -2084,6 +2085,11 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void macro_NULL() {
|
||||||
|
ASSERT_EQUALS("\n$0", OurPreprocessor::expandMacros("#define null 0\nnull"));
|
||||||
|
ASSERT_EQUALS("\nNULL", OurPreprocessor::expandMacros("#define NULL 0\nNULL"));
|
||||||
|
}
|
||||||
|
|
||||||
void string1() {
|
void string1() {
|
||||||
const char filedata[] = "int main()"
|
const char filedata[] = "int main()"
|
||||||
"{"
|
"{"
|
||||||
|
|
Loading…
Reference in New Issue