File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1612,14 +1612,14 @@ namespace simplecpp {
16121612 hashToken = hashToken->next ;
16131613 ++numberOfHash;
16141614 }
1615- if (numberOfHash == 4 ) {
1615+ if (numberOfHash == 4 && tok-> next -> location . col + 1 == tok-> next -> next -> location . col ) {
16161616 // # ## # => ##
16171617 output->push_back (newMacroToken (" ##" , loc, isReplaced (expandedmacros)));
16181618 tok = hashToken;
16191619 continue ;
16201620 }
16211621
1622- if (numberOfHash = = 2 && tok->location .col + 1 < tok->next ->location .col ) {
1622+ if (numberOfHash > = 2 && tok->location .col + 1 < tok->next ->location .col ) {
16231623 output->push_back (new Token (*tok));
16241624 tok = tok->next ;
16251625 continue ;
Original file line number Diff line number Diff line change @@ -766,6 +766,13 @@ static void hashhash10()
766766 ASSERT_EQUALS (" # #" , preprocess (code));
767767}
768768
769+ static void hashhash11 ()
770+ {
771+ const char code[] = " #define x # # #\n "
772+ " x" ;
773+ ASSERT_EQUALS (" # # #" , preprocess (code));
774+ }
775+
769776static void hashhash_invalid_1 ()
770777{
771778 std::istringstream istr (" #define f(a) (##x)\n f(1)" );
@@ -1930,7 +1937,8 @@ int main(int argc, char **argv)
19301937 TEST_CASE (hashhash7); // # ## # (C standard; 6.10.3.3.p4)
19311938 TEST_CASE (hashhash8);
19321939 TEST_CASE (hashhash9);
1933- TEST_CASE (hashhash10);
1940+ TEST_CASE (hashhash10); // #108 : #define x # #
1941+ TEST_CASE (hashhash11); // #60: #define x # # #
19341942 TEST_CASE (hashhash_invalid_1);
19351943 TEST_CASE (hashhash_invalid_2);
19361944
You can’t perform that action at this time.
0 commit comments