Ticket #9569: Do not substitute type aliases within enum definitions. (#2504)

This commit is contained in:
Simon Martin 2020-01-25 10:18:37 +01:00 committed by Daniel Marjamäki
parent 224a41361d
commit 2840173a72
2 changed files with 11 additions and 0 deletions

View File

@ -2040,6 +2040,10 @@ bool Tokenizer::simplifyUsing()
continue;
}
// skip enum definitions
if (tok1->str() == "enum")
skipEnumBody(&tok1);
// check for member function and adjust scope
if (isMemberFunction(tok1)) {
if (!scope1.empty())

View File

@ -75,6 +75,7 @@ private:
TEST_CASE(tokenize35); // #8361
TEST_CASE(tokenize36); // #8436
TEST_CASE(tokenize37); // #8550
TEST_CASE(tokenize38); // #9569
TEST_CASE(validate);
@ -882,6 +883,12 @@ private:
ASSERT_EQUALS(expS, tokenizeAndStringify(codeS));
}
void tokenize38() { // #9569
const char code[] = "using Binary = std::vector<char>; enum Type { Binary };";
const char exp[] = "enum Type { Binary } ;";
ASSERT_EQUALS(exp, tokenizeAndStringify(code));
}
void validate() {
// C++ code in C file
ASSERT_THROW(tokenizeAndStringify(";using namespace std;",false,false,Settings::Native,"test.c"), InternalError);