Less strict unknownMacro
This commit is contained in:
parent
547d1b158e
commit
9eda399323
|
@ -5123,7 +5123,7 @@ void Tokenizer::removeMacrosInGlobalScope()
|
|||
while (Token::Match(tok2, "%type% (") && tok2->isUpperCaseName())
|
||||
tok2 = tok2->linkAt(1)->next();
|
||||
|
||||
if (Token::Match(tok, "%name% (") && Token::Match(tok2, "%name% *|&|::|<| %name%") && !Token::Match(tok2, "namespace|class|struct|union"))
|
||||
if (Token::Match(tok, "%name% (") && Token::Match(tok2, "%name% *|&|::|<| %name%") && !Token::Match(tok2, "namespace|class|struct|union|private:|protected:|public:"))
|
||||
unknownMacroError(tok);
|
||||
|
||||
if (Token::Match(tok, "%type% (") && Token::Match(tok2, "%type% (") && !Token::Match(tok2, "noexcept|throw") && isFunctionHead(tok2->next(), ":;{"))
|
||||
|
|
|
@ -75,6 +75,7 @@ private:
|
|||
TEST_CASE(noConstructor7); // ticket #4391
|
||||
TEST_CASE(noConstructor8); // ticket #4404
|
||||
TEST_CASE(noConstructor9); // ticket #4419
|
||||
TEST_CASE(noConstructor10); // ticket #6614
|
||||
TEST_CASE(noConstructor11); // ticket #3552
|
||||
TEST_CASE(noConstructor12); // #8951 - member initialization
|
||||
|
||||
|
@ -553,6 +554,27 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void noConstructor10() {
|
||||
// ticket #6614
|
||||
check("class A : public wxDialog\n"
|
||||
"{\n"
|
||||
"private:\n"
|
||||
" DECLARE_EVENT_TABLE()\n"
|
||||
"public:\n"
|
||||
" A(wxWindow *parent,\n"
|
||||
" wxWindowID id = 1,\n"
|
||||
" const wxString &title = wxT(""),\n"
|
||||
" const wxPoint& pos = wxDefaultPosition,\n"
|
||||
" const wxSize& size = wxDefaultSize,\n"
|
||||
" long style = wxDIALOG_NO_PARENT | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxCLOSE_BOX);\n"
|
||||
" virtual ~A();\n"
|
||||
"private:\n"
|
||||
" wxTimer *WxTimer1;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
void noConstructor11() { // #3552
|
||||
check("class Fred { int x; };\n"
|
||||
"union U { int y; Fred fred; };");
|
||||
|
|
|
@ -6633,11 +6633,11 @@ private:
|
|||
ASSERT_EQUALS("; CONST struct ABC abc ;",
|
||||
tokenizeAndStringify("; CONST struct ABC abc ;"));
|
||||
|
||||
ASSERT_THROW(tokenizeAndStringify("class A {\n"
|
||||
" UNKNOWN_MACRO(A)\n"
|
||||
"private:\n"
|
||||
" int x;\n"
|
||||
"};"), InternalError);
|
||||
ASSERT_NO_THROW(tokenizeAndStringify("class A {\n"
|
||||
" UNKNOWN_MACRO(A)\n" // <- this macro is ignored
|
||||
"private:\n"
|
||||
" int x;\n"
|
||||
"};"));
|
||||
|
||||
ASSERT_THROW(tokenizeAndStringify("MACRO(test) void test() { }"), InternalError); // #7931
|
||||
|
||||
|
|
|
@ -117,6 +117,7 @@ private:
|
|||
TEST_CASE(varid_in_class5); // #3584 - std::vector<::FOO::B> b;
|
||||
TEST_CASE(varid_in_class6); // #3755
|
||||
TEST_CASE(varid_in_class7); // set variable id for struct members
|
||||
TEST_CASE(varid_in_class8); // unknown macro in class
|
||||
TEST_CASE(varid_in_class9); // #4291 - id for variables accessed through 'this'
|
||||
TEST_CASE(varid_in_class10);
|
||||
TEST_CASE(varid_in_class11); // #4277 - anonymous union
|
||||
|
@ -1535,6 +1536,20 @@ private:
|
|||
tokenize(code));
|
||||
}
|
||||
|
||||
void varid_in_class8() { // #3776 - unknown macro
|
||||
const char code[] = "class A {\n"
|
||||
" UNKNOWN_MACRO(A)\n"
|
||||
"private:\n"
|
||||
" int x;\n"
|
||||
"};";
|
||||
ASSERT_EQUALS("1: class A {\n"
|
||||
"2: UNKNOWN_MACRO ( A )\n"
|
||||
"3: private:\n"
|
||||
"4: int x@1 ;\n"
|
||||
"5: } ;\n",
|
||||
tokenize(code));
|
||||
}
|
||||
|
||||
void varid_in_class9() { // #4291 - id for variables accessed through 'this'
|
||||
const char code1[] = "class A {\n"
|
||||
" int var;\n"
|
||||
|
|
Loading…
Reference in New Issue