File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1473,7 +1473,7 @@ namespace simplecpp {
14731473
14741474 const Token *appendTokens (TokenList *tokens,
14751475 const Location &rawloc,
1476- const Token *lpar,
1476+ const Token * const lpar,
14771477 const std::map<TokenString,Macro> ¯os,
14781478 const std::set<TokenString> &expandedmacros,
14791479 const std::vector<const Token*> ¶metertokens) const {
@@ -1512,6 +1512,8 @@ namespace simplecpp {
15121512 tok = tok->next ;
15131513 }
15141514 }
1515+ for (Token *tok2 = tokens->front (); tok2; tok2 = tok2->next )
1516+ tok2->location = lpar->location ;
15151517 return sameline (lpar,tok) ? tok : NULL ;
15161518 }
15171519
Original file line number Diff line number Diff line change @@ -339,6 +339,19 @@ static void define10() // don't combine prefix with space in macro
339339 ASSERT_EQUALS (" \n u8 \" a b\" ;" , preprocess (code));
340340}
341341
342+ static void define11 () // location of expanded argument
343+ {
344+ const char code[] = " #line 4 \" version.h\"\n "
345+ " #define A(x) B(x)\n "
346+ " #define B(x) x\n "
347+ " #define VER A(1)\n "
348+ " \n "
349+ " #line 10 \" cppcheck.cpp\"\n "
350+ " VER;" ;
351+ ASSERT_EQUALS (" \n #line 10 \" cppcheck.cpp\"\n 1 ;" , preprocess (code));
352+ }
353+
354+
342355static void define_invalid_1 ()
343356{
344357 std::istringstream istr (" #define A(\n B\n " );
@@ -1911,6 +1924,7 @@ int main(int argc, char **argv)
19111924 TEST_CASE (define8);
19121925 TEST_CASE (define9);
19131926 TEST_CASE (define10);
1927+ TEST_CASE (define11);
19141928 TEST_CASE (define_invalid_1);
19151929 TEST_CASE (define_invalid_2);
19161930 TEST_CASE (define_define_1);
You can’t perform that action at this time.
0 commit comments