diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index e97ebcaa1..9bde7e1c8 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -665,7 +665,7 @@ namespace { } for (Token* type = start; Token::Match(type, "%name%|*|&"); type = type->next()) { - if (Token::Match(type, "%name% ;")) { + if (Token::Match(type, "%name% ;") && !type->isStandardType()) { mRangeType.first = start; mRangeType.second = type; mNameToken = type; diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index fc33210c6..88b4f1355 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -3277,7 +3277,8 @@ private: ASSERT_EQUALS("struct X { } ; std :: vector < X > v ;", tok(code)); } - void simplifyTypedef145() { // #11634 + void simplifyTypedef145() { + // #11634 const char* code{}; code = "int typedef i;\n" "i main() {}\n"; @@ -3292,6 +3293,11 @@ private: code = "struct {} typedef S;\n" // don't crash "S();\n"; ASSERT_EQUALS("struct S { } ; struct S ( ) ;", tok(code)); + + // #11693 + code = "typedef unsigned char unsigned char;\n" // don't hang + "void f(char);\n"; + ASSERT_EQUALS("void f ( char ) ;", tok(code)); } void simplifyTypedefFunction1() {