Skip to content
Snippets Groups Projects
Forked from Glasgow Haskell Compiler / GHC
5312 commits behind the upstream repository.
  • Duncan Coutts's avatar
    f70b8108
    Take a simpler approach to gcc warnings in IOManager.c · f70b8108
    Duncan Coutts authored and Marge Bot's avatar Marge Bot committed
    We have lots of functions with conditional implementations for
    different I/O managers. Some functions, for some I/O managers,
    naturally have implementations that do nothing or barf. When only one
    such I/O manager is enabled then the whole function implementation will
    have an implementation that does nothing or barfs. This then results in
    warnings from gcc that parameters are unused, or that the function
    should be marked with attribute noreturn (since barf does not return).
    The USED_IF_THREADS trick for fine-grained warning supression is fine
    for just two cases, but an equivalent here would need
    USED_IF_THE_ONLY_ENABLED_IOMGR_IS_X_OR_Y which would have combinitorial
    blowup. So we take a coarse grained approach and simply disable these
    two warnings for the whole file.
    
    So we use a GCC pragma, with its handy push/pop support:
    
     #pragma GCC diagnostic push
     #pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn"
     #pragma GCC diagnostic ignored "-Wunused-parameter"
    
    ...
    
     #pragma GCC diagnostic pop
    f70b8108
    History
    Take a simpler approach to gcc warnings in IOManager.c
    Duncan Coutts authored and Marge Bot's avatar Marge Bot committed
    We have lots of functions with conditional implementations for
    different I/O managers. Some functions, for some I/O managers,
    naturally have implementations that do nothing or barf. When only one
    such I/O manager is enabled then the whole function implementation will
    have an implementation that does nothing or barfs. This then results in
    warnings from gcc that parameters are unused, or that the function
    should be marked with attribute noreturn (since barf does not return).
    The USED_IF_THREADS trick for fine-grained warning supression is fine
    for just two cases, but an equivalent here would need
    USED_IF_THE_ONLY_ENABLED_IOMGR_IS_X_OR_Y which would have combinitorial
    blowup. So we take a coarse grained approach and simply disable these
    two warnings for the whole file.
    
    So we use a GCC pragma, with its handy push/pop support:
    
     #pragma GCC diagnostic push
     #pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn"
     #pragma GCC diagnostic ignored "-Wunused-parameter"
    
    ...
    
     #pragma GCC diagnostic pop
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
IOManager.h 10.73 KiB