@@ -2256,7 +2256,9 @@ namespace simplecpp {
22562256 * Parameters are substituted before the rescan, so the parentheses are
22572257 * counted in the substituted tokens: parameters that expand to nothing are
22582258 * skipped, and the '(' and the ')' of the call can each come from the
2259- * replacement list or from a parameter. Returns the replacement-list token
2259+ * replacement list or from a parameter. A parameter that is followed by
2260+ * ## is not macro-expanded: the search stops at it when it comes before
2261+ * the '('. Returns the replacement-list token
22602262 * that supplied the ')', or nullptr when there is no complete call. When
22612263 * that token is a parameter, its expansion is copied whole since it may
22622264 * hold more than the end of the call. When the first parameter that does
@@ -2276,7 +2278,17 @@ namespace simplecpp {
22762278 continue ;
22772279 }
22782280 const Token * const end = callArgs.cback ();
2279- if (!expandArg (callArgs, after, loc, macros, expandedmacros, parametertokens, outputList)) {
2281+ bool isParameter;
2282+ if (sameline (after, after->next ) && after->next ->op == ' #' && sameline (after, after->next ->next ) && after->next ->next ->op == ' #' ) {
2283+ // the left operand of ## is substituted without macro expansion
2284+ isParameter = expandArg (callArgs, after, parametertokens);
2285+ // the paste can change what follows the macro name
2286+ if (isParameter && par == 0U )
2287+ return nullptr ;
2288+ } else {
2289+ isParameter = expandArg (callArgs, after, loc, macros, expandedmacros, parametertokens, outputList);
2290+ }
2291+ if (!isParameter) {
22802292 // only parameters, which can expand to nothing, can come between
22812293 // the macro name and its '('
22822294 if (par == 0U && after->op != ' (' )
0 commit comments