On Mon, May 13, 2013 at 9:49 AM, Hans Wennborg <span dir="ltr"><<a href="mailto:hans@chromium.org" target="_blank">hans@chromium.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
The attached patch fixes Clang's diagnostics concerning string<br>
initialization. Where it would previously say:<br>
<br>
  /tmp/a.c:3:9: error: array initializer must be an initializer list<br>
  wchar_t s[] = "Hi";<br>
          ^<br>
  /tmp/a.c:4:6: error: array initializer must be an initializer list<br>
or string literal<br>
  char t[] = L"Hi";<br>
       ^<br>
<br>
It will now say<br>
<br>
  /tmp/a.c:3:9: error: initializing wide char array with non-wide string literal<br>
  wchar_t s[] = "Hi";<br>
          ^<br>
  /tmp/a.c:4:6: error: initializing char array with wide string literal<br>
  char t[] = L"Hi";<br>
       ^<br>
<br>
As a bonus, it also fixes the fact that Clang would previously reject<br>
this valid C11 code:<br>
<br>
  char16_t s[] = u"hi";<br>
  char32_t t[] = U"hi";1<br>
<br>
because it would only recognize the built-in types for char16_t and<br>
char32_t, which do not exist in C.<br>
<br>
Please take a look.</blockquote><div><br></div><div>Looks good, but how about changing IsStringInit to return a StringInitFailureKind value? I think the two places which use its return value rather than just using the same Expr* they passed in are actually wrong (they pass the IgnoreParens'd version of the return value to CheckStringInit rather than passing in the original expression, and thus may fail to update the type on the parens).</div>
</div>