def adjust_error_on_warning_flag(flag, allow_error_on_warning):
    """
    Adjust a given compiler flag according to whether we want to allow any flags that turn warnings
    into errors. We disable these flags during the configure step.
    """
    if flag == '-Werror':
        # Skip this flag altogether, whether these are the flags for configure or make. PostgreSQL
        # code is not warning-free.
        return None

    if allow_error_on_warning:
        # No changes.
        return flag

    if flag.startswith('-Werror='):
        # Convert e.g. -Werror=implicit-function-declaration to -Wimplicit-function-declaration.
        return '-W' + flag[8:]

    return flag