Menu

#4078 SDCC accepts storage class on return type

open
nobody
None
Front-end
5
5 days ago
2026-09-13
No

It seems that SDCC accepts the following IMHO stupid definition. It ignores the storage class, but I think it would be better to reject it.

__xdata int foo (void)
{
  return 0;
}

Discussion

  • Philipp Klaus Krause

    No. Per the embedded C standard, __xdata is a named address space qualifier. C allows qualifiers on return types (but they re meaningless), so I think we need to allow this.

    IMO, the bug here is a just missing W_QUALIFIED_RETURN warning.

    P.S.: actually, there is already a comment about this in SDCCsymt.c:

    // TODO: we probably should remove named address space qualifiers
    // for intrinsic named address spaces, too.
    
     

    Last edit: Maarten Brock 2026-09-13
  • Maarten Brock

    Maarten Brock - 2026-09-13

    OK, I can accept that. How about this patch?

    I'm a bit uncertain about the DECL case. It's been a while since I worked with storage class for declarators. I seem to remember it is stored in the etype.

     
    • Philipp Klaus Krause

      Looks good to me. Should probably get a test in support/valdiag/tests. Maybe add it to support/valdiag/tests/bug-3964.c? Or introduce a new support/valdiag/tests/bug-4078.c?

       
      • Maarten Brock

        Maarten Brock - 5 days ago

        Before creating a new valdiag test, I first dug a little deeper in the valdiag testing. In [r16877] I have updated valdiag.py so it now differentiates between errors and warnings. This brought several misconfigured tests to the surface which were also updated.

        This also brought to light a bug in SDCCicode.c for pre-/post-inc/dec of pointers to incomplete structs which is now fixed.

         

        Related

        Commit: [r16877]


Log in to post a comment.