<div dir="ltr">C11 6.7.6.3p15: "In the determination of type compatibility and of a composite type, each parameter declared with function or array type is taken as having the adjusted type and each parameter declared with qualified type is taken as having the unqualified version of its declared type."<div class="gmail_extra"><br></div><div class="gmail_extra">So "int f(int p[restrict])" is compatible with "int f(int *restrict p)" and "int f(int *p)", so getCanonicalParamType should be stripping the qualifiers (if any) added by getArrayDecayedType -- or not adding them in the first place. Seems like the same bug exists for "int f(int p[const])" and "int f(int p[volatile])" too.</div><div class="gmail_extra"><br></div><div class="gmail_extra">An even more broken case along the same codepath is the bizarre construct "int f(int arr[_Nullable])". The canonical function type should not include the nullability attribute (it's not even part of the canonical parameter type), but currently it does! Our current handling for this case is clearly wrong: getCanonicalParamType returns a CanQualType wrapping an AttributedType, which is not a canonical type.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Maybe the easiest fix would be to make getCanonicalParamType just build the type "pointer to array element type" and not call getArrayDecayedType at all, since it doesn't want any of the other things that getArrayDecayedType does.</div><div class="gmail_extra"><br><div class="gmail_quote">On 17 April 2017 at 10:07, Aaron Ballman via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@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">I've run into a case where I am calling ASTContext::getFunctionType()<br>
and getting a failed assertion because a parameter we thought we<br>
canonicalized isn't actually canonical. The function is declared as:<br>
<br>
extern int regexec (int __pmatch[__restrict]);<br>
<br>
When we call getCanonicalParamType() on that parameter, it results in<br>
a type that is a decayed pointer that still has the restrict<br>
qualifier, because getArrayDecayedType() leaves on index type<br>
qualifiers. However, isCanonicalAsParam() checks for the presence of<br>
any local qualifiers and returns false if any are present. This<br>
results in the assertion failing.<br>
<br>
I believe this is a bug, but I'm not certain where. Should<br>
getCanonicalParamType() be stripping the restrict array index<br>
qualifier? Should isCanonicalAsParam() be modified? Or is something<br>
else going on that I'm not quite understanding?<br>
<br>
Thanks!<br>
<br>
~Aaron<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>