In SDCC.y, we have a rule

file
   : /* empty */
     {
       werror(W_EMPTY_SOURCE_FILE);
     }
   | translation_unit
   ;

So if there is further input, which can't be lexed, we get the empty source file error even for nonempty files.

In [r13845], I improved the situation a bit (sdcc now behaves like gcc), the error message now mentions an "empty translation unit", which at least fixes the related case of a source file containing only preprocessing directives.

 

Related

Commit: [r13845]