From 1901adbab796e27e7ed862e850a2171ffc4dde90 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 12 Oct 2015 10:41:21 +0200 Subject: Split two error cases so they get reported distinctly. If a macro is used with too few parameters, complaining about its definition using '#' followed by something other than a macro parameter name is apt to be confusing - reading the definition will reveal that the name in fact is a macro parameter after all. The reader needs attention directed to the invocation, not the definition. Split the test in two: one to test the prior error message does in fact get produced for an invalid macro definition, the other to test the invalid invocation case. Task-number: QTBUG-46210 Change-Id: Ie177a56d346e553bf9d67e2008a4352633afa1ae Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/preprocessor.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/tools/moc/preprocessor.cpp') diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index d036c40f35..a2a1a958cf 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -658,9 +658,12 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym expansion += s; } } else if (mode == Hash) { - if (index < 0 || index >= arguments.size()) { + if (index < 0) { that->error("'#' is not followed by a macro parameter"); continue; + } else if (index >= arguments.size()) { + that->error("Macro invoked with too few parameters for a use of '#'"); + continue; } const Symbols &arg = arguments.at(index); -- cgit v1.2.3