<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 9 June 2017 at 00:21, Puneetha K via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Hi, <div dir="auto">I am trying to compile the following:</div><div dir="auto"><br></div><div dir="auto">char * _Atomic restrict h;</div><div dir="auto"><br><div dir="auto">When compiled with -std=c11,clang gives error:<br><div dir="auto"><div dir="auto">         "restrict requires a pointer or reference (_Atomic(char*) is invalid)"</div></div></div></div></div></blockquote><div><br></div><div><div>C11 6.7.3/5: "If other qualifiers appear along with the _Atomic qualifier in a specifier-qualifier-list, the resulting type is the so-qualified atomic type."<br></div></div><div><br></div><div>So the type of 'h' is 'restrict _Atomic(char*)', not '_Atomic(char *restrict)'.</div><div><br></div><div>C11 6.7.3/2: "Types other than pointer types whose referenced type is an object type shall not be restrict-qualified."</div><div><br></div><div>The type being restrict-qualified is _Atomic(char*), which is an atomic type, not a pointer type, and thus this is ill-formed. (As it happens, '_Atomic(char *restrict)' would also be ill-formed, due to <a href="http://6.7.2.4/3">6.7.2.4/3</a>: "The type name in an atomic type specifier shall not refer to [...] a qualified type.")</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="auto"><div dir="auto"><div dir="auto"><div dir="auto">while gcc compiles it successfully.</div><div dir="auto"><br></div><div dir="auto">Similarly, while trying to compile this</div><div dir="auto"><br></div><div dir="auto">extern int i;</div><div dir="auto">extern int _Atomic const ci;</div><div dir="auto">extern __typeof(ci) i;</div><div dir="auto"><br></div><div dir="auto">Clang gives error:</div><div dir="auto"><br></div><div dir="auto">          "Redeclaration of 'i' with a different type: 'typeof (ci)' (aka 'typeof _Atomic(int)') vs 'int' "</div><div dir="auto"><br></div><div dir="auto"><span style="font-family:sans-serif">while gcc compiles it successfully.</span><br></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">This seems to be because clang probably considers Atomic int differently than int while gcc disregards these.</span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto">Please suggest what should be the right behaviour in such cases. </div></div></div></div></div></blockquote></div></div></div>