diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 59ac29680..0c08176e2 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7570,10 +7570,14 @@ void Tokenizer::syntaxError(const Token *tok) const void Tokenizer::syntaxError(const Token *tok, char c) const { printDebugOutput(0); - throw InternalError(tok, - std::string("Invalid number of character '") + c + "' " + - "when these macros are defined: '" + _configuration + "'.", - InternalError::SYNTAX); + if (_configuration.empty()) + throw InternalError(tok, + std::string("Invalid number of character '") + c + "' when no macros are defined.", + InternalError::SYNTAX); + else + throw InternalError(tok, + std::string("Invalid number of character '") + c + "' when these macros are defined: '" + _configuration + "'.", + InternalError::SYNTAX); } void Tokenizer::unhandled_macro_class_x_y(const Token *tok) const diff --git a/samples/syntaxError/out.txt b/samples/syntaxError/out.txt index 059c1c86c..8f0626044 100644 --- a/samples/syntaxError/out.txt +++ b/samples/syntaxError/out.txt @@ -1 +1 @@ -[samples\syntaxError\bad.c:2]: (error) Invalid number of character '{' when these macros are defined: ''. +[samples\syntaxError\bad.c:2]: (error) Invalid number of character '{' when no macros are defined. diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index 4a1b10432..4f7087ad9 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -1073,7 +1073,7 @@ private: tokenizer.tokenize(istr, "test.cpp"); assertThrowFail(__FILE__, __LINE__); } catch (InternalError& e) { - ASSERT_EQUALS("Invalid number of character '(' when these macros are defined: ''.", e.errorMessage); + ASSERT_EQUALS("Invalid number of character '(' when no macros are defined.", e.errorMessage); ASSERT_EQUALS("syntaxError", e.id); ASSERT_EQUALS(2, e.token->linenr()); }