<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/160474>160474</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang] C mode -Wincompatible-function-pointer-types diag disappears in case of other function type differences
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          brunodf-snps
      </td>
    </tr>
</table>

<pre>
    This is explored in the following test cases. All lines marked "OK??" are cases where a diagnostic is logically missing (and gcc has a diagnostic if it understand the involved attributes).

Godbolt demo: https://godbolt.org/z/f3o8KoqGo

```
#ifdef __clang__
// Comment-in pragma to enable strict mode
//#pragma clang diagnostic warning "-Wincompatible-function-pointer-types-strict"
#endif

enum E { A = -1, B };

// Case 1: assignment adding noreturn

int     f1    (int);
int (*fp1a)(int) __attribute__((noreturn)) = &f1; // NOK
enum E (*fp1b)(int) __attribute__((noreturn)) = &f1; // OK??
int    (*fp1c)() __attribute__((noreturn)) = &f1; // OK??

#ifdef __clang__

// Case 2: assignment adding noescape on arg

int   f2   (int* ) __attribute__((noreturn));
int (*fp2a)(int* __attribute__((noescape))) __attribute__((noreturn)) = &f2; // NOK
int (*fp2b)(int* __attribute__((noescape)))                           = &f2; // OK??

// Case 3: assignment adding cfi_unchecked_callee

int   f3   (int* );
int (*fp3a)(int*                          ) __attribute__((noreturn                     )) = &f3; // NOK
int (*fp3b)(int* __attribute__((noescape))) = &f3; // NOK
int (*fp3c)(int*                          ) __attribute__((noreturn,cfi_unchecked_callee)) = &f3; // OK??
int (*fp3d)(int* __attribute__((noescape))) __attribute__(( cfi_unchecked_callee)) = &f3; // OK??
int (*fp3e)(int* __attribute__((noescape))) __attribute__((noreturn,cfi_unchecked_callee)) = &f3; // OK??

#endif

// Case 4: assignment to function with no prototype

int   f4   (int);
int (*fp4a)(int) = &f4; // OK
int (*fp4b)() = &f4; // NOK for strict?
```

This issue was previously reported as https://bugs.llvm.org/show_bug.cgi?id=42120

A stricter diagnostic -Wincompatible-function-pointer-types-strict was added, this catches all the cases, but this also diagnoses differences in argument and result types that are allowed in C.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVk1vqzgU_TXO5ioRGMjHggVtJm9R6b3NSLNExr6A5xmbsU0znV8_MtA0SZOndqYIJRK-H-eea_se5pxsNGJOsgeS7Rds8K2xeWUHbUS9dLp3i8qIl_z3VjqQDvDvXhmLAqQG3yLURilzlLoBj84DZw7dCgqlQEmNDjpmf6IAQumPJ5IcwkspMIuTKRxbtAgMhGSNNs5LHrIo00jOlHqBTjoXohO6ZVpAwzm0zF051CA9DFqgdT5YBWBSPxv1jAKY91ZWg0dH6G5FooJExTcjKqM8COwMSQpove8dSQpCD4Qemml1ZWxD6OEfQg91YrZP5q9vZnIn62h-o4LQRNYCayhLrphuynL8GOLAo-k61H4pNfSWNR0DbwA1qxSC81ZyD50ReHIgNJntxlDnNR6Z1RMPdPmH1Nx0PfOyUrisB829NHrZG6k92qV_6dEtp_iE0gkjaiHrCT3qoYPfgGweoACS7GEZE_oID0A2e5I8zCXOFTCHEAeKpp0SygEmRICijUU_WD05SO0hPHUcfgndSu0J3U0BwyKhW0KLuo9Z-Py6DmV5alBZjjbbU-BgtxshErquY5I8wIzr-4-ns0peI1dfEPm0TU8lncLzKfyXxL67cy6pp_eoR8dZj2A0MNucd6CmZ_QX8CGw75tEz5tU3I4wQZgjfIoT-q6TF7mrz-e-_9zKed2HN76T23zzWpaD5i3ynyjKcDMhXpCeXJP-ntLkktL7gH9N5T2fc36TX_Kb_Ad-PxiZf0mJhD7eJPw-lKtDe8IjvmQX327_59HgF5-p_8HSu6FwfgjSq0PgDbwOGThK34I20FvjTZg0F8cg_fXVn15e_a8Y00uMVz7V2617y-H7jyeojZ3n6Vzd-XyOilm7uAHhyBz0Fp-lGZx6AYu9sT6IBHelAaqhcSulnrtZBbjWHMt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