diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index e826f560f..138612c02 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3916,8 +3916,6 @@ void Tokenizer::removeMacrosInGlobalScope() void Tokenizer::removeMacroInClassDef() { - if (!isCPP()) - return; for (Token *tok = list.front(); tok; tok = tok->next()) { if (Token::Match(tok, "class|struct %name% %name% {|:") && (tok->next()->isUpperCaseName() || tok->tokAt(2)->isUpperCaseName())) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 9558306cf..a153186e6 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8708,6 +8708,8 @@ private: void removeMacroInClassDef() { // #6058 ASSERT_EQUALS("class Fred { } ;", tokenizeAndStringify("class DLLEXPORT Fred { } ;")); ASSERT_EQUALS("class Fred : Base { } ;", tokenizeAndStringify("class Fred FINAL : Base { } ;")); + // Regression for C code: + ASSERT_EQUALS("struct Fred { } ;", tokenizeAndStringify("struct DLLEXPORT Fred { } ;", false, true, Settings::Unspecified, "test.c")); } void sizeofAddParentheses() {