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

    <tr>
        <th>Summary</th>
        <td>
            clang doesn't drop the top level `_Atomic` qualifier when inferring an `__auto_type` from an initializer
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          ahatanak
      </td>
    </tr>
</table>

<pre>
    When the following code is compiled, the type of `b` is `_Atomic int` instead of `int`:

$ cat test.c
```
_Atomic int a;
int g;

void test() {
 __auto_type b = a;
   g = b;
}
```

$ clang -S -o - -emit-llvm test.c
```
define void @test() #0 {
entry:
  %b = alloca i32, align 4
  %atomic-load = load atomic i32, ptr @a seq_cst, align 4
 store i32 %atomic-load, ptr %b, align 4
  %atomic-load1 = load atomic i32, ptr %b seq_cst, align 4
  store i32 %atomic-load1, ptr @g, align 4
 ret void
}
```

This seems to differ from gcc's behavior if I understand its output in https://godbolt.org correctly. gcc drops `_Atomic` just like it drops `const` when it infers the type of `d` in the following code:

$ cat test.c
```
const int c = 100;

void test() {
    __auto_type d = c;
    d = 123;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVNGu4yYQ_Rr8MkpEILHjBz_s9ipSn1upjxGGsc0ugSyM71X69RXYvUnT3dutFDlmfJg5M4eDSsmOHrFjh8_s8FKpmaYQOzUpUl59rfpgbt0fE3qgCWEIzoU360fQwSDYBDpcrtahYeKXgqDbFSEMwGres5pnCKv5-ROFi9VgPZWgT4TKrLglyOQnxl8Y__sp9qAVAWGirV5jNV9_ZfmQFBSTn5doXo3vq-X5GqwpmZg4MtECa9bPcD6rmcK5sO6ByZeHTAAwllB_T9e8fJfKA2en_Aib32ATYAMbvFjaOPd6-agRg4P1CIUl2_NHokLyO1v0FG_vcwJg4rBydi5oBVaKLINydvSwf0CpMqiNC8oUfHlR6_SWTVeKubaChN_OOhN4TpQoRMzwp4zvu8Wh_8_yuw_r535-WP-HBHYP_Md_74tIZbQ_o-Dvk02QEC8JKICxw4ARhhguMGrNRJOgx0m92hDBDvArzN5gTKS8AUsJwkzXmcB6mIiuKUslTkycxmD64GgbYjZOjKjJ3bY5J5gYro8Wyfb4MicCZ78iWLoDdPCpuOctu9HmMgPG9Ow6sxjsO3b9_w4rJYu_dNFtx_lPOwvgH-ZaDp5-NNca2wn5gb8q00nTylZV2O3q43Ev5KHm1dShkW1T96pvjGxM3WOtj9oc9W4vtBK1rmwnuJC84VIIKfZ8K9sWEWXTt4hDqw3bc7wo67bZn1mbyqY0Y1fL-tBWTvXoUrkWhfD4BuUjEyLfkrHLezb9PCa2584mSvcsZMlht1wEJmDyTDSLjotW4QoOX9E9qf5tVs4OFuMqcFY3Zu2UL8j7MDO6HEqVYZascvZPjNUcXfd08CxNc7_V4cLEKRNc_zbXGL6gJiZOpa3ExKm0_VcAAAD__68byyk">