parseReturnType should start from the first non-brace token
authorFederico Fissore <[email protected]>
Wed, 4 Nov 2015 11:48:02 +0000 (4 12:48 +0100)
committerFederico Fissore <[email protected]>
Wed, 4 Nov 2015 12:02:03 +0000 (4 13:02 +0100)
c.c

diff --git a/c.c b/c.c
index ef81067..727d6bb 100644 (file)
--- a/c.c
+++ b/c.c
@@ -567,7 +567,6 @@ static const char *implementationString (const impType imp)
 /*
 *   Debugging functions
 */
-#define DEBUG
 #ifdef DEBUG
 
 #define boolString(c)   ((c) ? "TRUE" : "FALSE")
@@ -2120,6 +2119,7 @@ static void parseReturnType (statementInfo *const st)
 {
        int i;
        int lower_bound;
+       int upper_bound;
        tokenInfo * finding_tok;
        
        /* FIXME TODO: if java language must be supported then impement this here
@@ -2161,8 +2161,21 @@ static void parseReturnType (statementInfo *const st)
        }
        else
                lower_bound = 1;
-       
-       for (i = (unsigned int) NumTokens;  i > lower_bound;  i--)
+
+       upper_bound = -1;
+       for (i = 0; i < NumTokens; i++) {
+        tokenInfo *curr_tok;
+        curr_tok = prevToken (st, i);
+           if (curr_tok->type == TOKEN_BRACE_CLOSE || curr_tok->type == TOKEN_BRACE_OPEN) {
+               upper_bound = i - 1;
+               break;
+           }
+       }
+       if (upper_bound < 0) {
+           upper_bound = NumTokens - 1;
+       }
+
+       for (i = upper_bound;  i > lower_bound;  i--)
        {
                tokenInfo * curr_tok;
                curr_tok = prevToken (st, i);