Menu

#3351 pagma callee_saves sensitive to spaces

open
nobody
pragma 8051 (1)
other
5
2025-08-10
2022-03-09
No

sdcc 4.2.0
sdcc -mmcs51 --opt-code-size --fverbose-asm test.c

#pragma callee_saves foo,bar

static void foo() {}
static void bar() {}

int main() {
    unsigned char cnt=123;

    do {
        foo();
        bar();
    } while(--cnt);

    return 0;
}

got expected result

00101$:
;   test.c:10: foo();
    lcall   _foo
;   test.c:11: bar();
    lcall   _bar
;   test.c:12: } while(--cnt);
    djnz    r7,00101$

Issue is that following pragmas (with spaces) silently ignored/selectively used:

#pragma callee_saves foo, bar
#pragma callee_saves foo ,bar
#pragma callee_saves foo , bar

Discussion

  • Philipp Klaus Krause

     
  • Philipp Klaus Krause

    This is due to setParseWithComma not ignoring white spaces next to the comma, i.e. #pragma callee_saves foo , bar is parsed as applying to "foo " and " bar". I'm not sure if for the other uses of setParseWithComma there would be a problem if white space near the comma was skipped (it is also used in parsing options), but guess not.

     
    👍
    1

Log in to post a comment.

MongoDB Logo MongoDB