parent
d4fa8c6e95
commit
16e1e1d8f9
|
@ -1254,7 +1254,7 @@ void Tokenizer::simplifyTypedef()
|
|||
structRemoved = true;
|
||||
typeStart = typeStart->next();
|
||||
}
|
||||
if (typeStart->str() == "struct" && Token::Match(tok2, "%name% ::"))
|
||||
if (Token::Match(typeStart, "struct|class") && Token::Match(tok2, "%name% ::"))
|
||||
typeStart = typeStart->next();
|
||||
|
||||
if (sameStartEnd)
|
||||
|
|
|
@ -75,6 +75,7 @@ private:
|
|||
TEST_CASE(tokenize34); // #8031
|
||||
TEST_CASE(tokenize35); // #8361
|
||||
TEST_CASE(tokenize36); // #8436
|
||||
TEST_CASE(tokenize37); // #8550
|
||||
|
||||
TEST_CASE(validate);
|
||||
|
||||
|
@ -857,6 +858,21 @@ private:
|
|||
ASSERT_EQUALS(code, tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void tokenize37() { // #8550
|
||||
const char codeC[] = "class name { public: static void init ( ) {} } ; "
|
||||
"typedef class name N; "
|
||||
"void foo ( ) { return N :: init ( ) ; }";
|
||||
const char expC [] = "class name { public: static void init ( ) { } } ; "
|
||||
"void foo ( ) { return name :: init ( ) ; }";
|
||||
ASSERT_EQUALS(expC, tokenizeAndStringify(codeC));
|
||||
const char codeS[] = "class name { public: static void init ( ) {} } ; "
|
||||
"typedef struct name N; "
|
||||
"void foo ( ) { return N :: init ( ) ; }";
|
||||
const char expS [] = "class name { public: static void init ( ) { } } ; "
|
||||
"void foo ( ) { return name :: init ( ) ; }";
|
||||
ASSERT_EQUALS(expS, tokenizeAndStringify(codeS));
|
||||
}
|
||||
|
||||
void validate() {
|
||||
// C++ code in C file
|
||||
ASSERT_THROW(tokenizeAndStringify(";using namespace std;",false,false,Settings::Native,"test.c"), InternalError);
|
||||
|
|
Loading…
Reference in New Issue