It did you try to disable the common code optimization with -onf?
What it means is that the stackpointer has different values in a single location in a function depending on how the code gets to this location. With the common code optimization (to disable use -onf) this may happen in legal code.
Conceptually this happens for a setup like this:
void fun(void) {
....
CC;
...
PSHA
...
CC;
...
PULA
...
RTS
}
CC is a list of identical assembly instructions.
In this setup, the compiler moves the common code part CC to a new location and replaces the two old locations with JSR to the shared place for CC. As the two JSR's are located at different SP levels, the compiler issues the warning for the new location of the CC code.
optimized function:
void fun(void) {
....
JSR CC_Label
...
PSHA
...
JSR CC_Label
...
PULA
...
RTS
CC_Label:
CC
RTS
}
Daniel