From 0afecd8feed8b48f452f256874272c73bed969b9 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sat, 16 Jul 2016 10:43:28 +0200 Subject: [PATCH] Do not simplify name "CALLBACK" away on non-windows platforms (#7554) --- lib/tokenize.cpp | 4 +++- test/testsimplifytokens.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index b6c2908fe..ed544ae0d 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8471,8 +8471,10 @@ void Tokenizer::simplifyStructDecl() void Tokenizer::simplifyCallingConvention() { + bool windows = _settings->isWindowsPlatform(); + for (Token *tok = list.front(); tok; tok = tok->next()) { - while (Token::Match(tok, "__cdecl|__stdcall|__fastcall|__thiscall|__clrcall|__syscall|__pascal|__fortran|__far|__near|WINAPI|APIENTRY|CALLBACK")) { + while (Token::Match(tok, "__cdecl|__stdcall|__fastcall|__thiscall|__clrcall|__syscall|__pascal|__fortran|__far|__near") || (windows && Token::Match(tok, "WINAPI|APIENTRY|CALLBACK"))) { tok->deleteThis(); } } diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 8b4b75e86..5878f4cbb 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -3258,9 +3258,12 @@ private: ASSERT_EQUALS("int f ( ) ;", tok("int __far __syscall f();", true)); ASSERT_EQUALS("int f ( ) ;", tok("int __far __pascal f();", true)); ASSERT_EQUALS("int f ( ) ;", tok("int __far __fortran f();", true)); - ASSERT_EQUALS("int f ( ) ;", tok("int WINAPI f();", true)); - ASSERT_EQUALS("int f ( ) ;", tok("int APIENTRY f();", true)); - ASSERT_EQUALS("int f ( ) ;", tok("int CALLBACK f();", true)); + ASSERT_EQUALS("int f ( ) ;", tok("int WINAPI f();", true, Settings::Win32A)); + ASSERT_EQUALS("int f ( ) ;", tok("int APIENTRY f();", true, Settings::Win32A)); + ASSERT_EQUALS("int f ( ) ;", tok("int CALLBACK f();", true, Settings::Win32A)); + + // don't simplify Microsoft defines in unix code (#7554) + ASSERT_EQUALS("enum E { CALLBACK } ;", tok("enum E { CALLBACK } ;", true, Settings::Unix32)); } void simplifyFunctorCall() {