From: David Engster Date: Sun, 27 Oct 2013 21:13:46 +0000 (+0100) Subject: Expand preprocessor to handle macros which open or close scope. X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6945c33baa7934a7a1a79735399f7e34b0ece627;p=emacs.git Expand preprocessor to handle macros which open or close scope. * semantic/lex-spp.el (semantic-c-end-of-macro): Declare. (semantic-lex-spp-token-macro-to-macro-stream): Deal with macros which open/close a scope. For this, leave an overlay if we encounter a single open paren and return a semantic-list in the lexer. When this list gets expanded, retrieve the old position from the overlay. See the comments in the function for further details. (semantic-lex-spp-find-closing-macro): New function to find the next macro which closes scope (i.e., has a closing paren). (semantic-lex-spp-replace-or-symbol-or-keyword): Go to end of closing macro if necessary. (semantic-lex-spp-paren-or-list): New lexer to specially deal with parens in macro definitions. * bovine/c.el (semantic-cpp-lexer): Use new `semantic-lex-spp-paren-or-list'. * tests/cedet/semantic/test/manual/cedet/testsppreplace.c: * tests/cedet/semantic/test/manual/cedet/testsppreplaced.c: Add tests for the above. --- diff --git a/test/manual/cedet/cedet/semantic/tests/testsppreplaced.c b/test/manual/cedet/cedet/semantic/tests/testsppreplaced.c index 105d6ac9cff..ca8703024c7 100644 --- a/test/manual/cedet/cedet/semantic/tests/testsppreplaced.c +++ b/test/manual/cedet/cedet/semantic/tests/testsppreplaced.c @@ -99,6 +99,24 @@ int MACROA () { /* TEST: Fancy concat/recursive macros */ int ABtest; +/* TEST: Macros which open a scope which is closed by another macro */ +namespace foo { + struct inside_foo {}; + struct inside_foo_as_well {}; +} + +namespace foo { + namespace bar { + struct inside_foo_bar {}; + } +} + +namespace one { + namespace two { + struct inside_one_two (); + } +} + /* TEST: Macro Recursion limits in arguments to a macro. * This code is from ALSA, noticed by Yupeng. */ /* See commentary in testsppreplace.c. This test is broken.