<div dir="ltr">On Sun, May 5, 2013 at 2:53 AM, Abramo Bagnara <span dir="ltr"><<a href="mailto:abramo.bagnara@bugseng.com" target="_blank">abramo.bagnara@bugseng.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Il 26/04/2013 16:36, Richard Smith ha scritto:<br>
<div class="im">> Modified: cfe/trunk/lib/Sema/SemaInit.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=180603&r1=180602&r2=180603&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=180603&r1=180602&r2=180603&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/lib/Sema/SemaInit.cpp (original)<br>
> +++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Apr 26 09:36:30 2013<br>
> @@ -97,6 +97,7 @@ static void CheckStringInit(Expr *Str, Q<br>
>      DeclT = S.Context.getConstantArrayType(IAT->getElementType(),<br>
>                                             ConstVal,<br>
>                                             ArrayType::Normal, 0);<br>
> +    Str->setType(DeclT);<br>
>      return;<br>
>    }<br>
<br>
</div>Is this change deliberate? It seems to introduce a regression:<br>
<br>
$ cat z.c<br>
<br>
void f() {<br>
  signed char s[] = "a";<br>
  unsigned char u[] = "a";<br>
}<br>
$ _clang -cc1 -ast-dump z.c<br>
TranslationUnitDecl 0x67d96e0 <<invalid sloc>><br>
|-TypedefDecl 0x67d9bc0 <<invalid sloc>> __int128_t '__int128'<br>
|-TypedefDecl 0x67d9c20 <<invalid sloc>> __uint128_t 'unsigned __int128'<br>
|-TypedefDecl 0x67d9f70 <<invalid sloc>> __builtin_va_list<br>
'__va_list_tag [1]'<br>
`-FunctionDecl 0x67da010 <z.c:2:1, line:5:1> f 'void ()'<br>
  `-CompoundStmt 0x67da350 <line:2:10, line:5:1><br>
    |-DeclStmt 0x67da208 <line:3:3, col:24><br>
    | `-VarDecl 0x67da100 <col:3, col:21> s 'signed char [2]'<br>
    |   `-StringLiteral 0x67da198 <col:21> 'signed char [2]' lvalue "a"<br>
    `-DeclStmt 0x67da338 <line:4:3, col:26><br>
      `-VarDecl 0x67da270 <col:3, col:23> u 'unsigned char [2]'<br>
        `-StringLiteral 0x67da2c8 <col:23> 'unsigned char [2]' lvalue "a"<br>
<br>
Type of string literal should be plain char.<br>
</blockquote></div><br></div><div class="gmail_extra" style>Yes, this is deliberate; we intended to set the string literal's type to the type of the initialized variable (otherwise we would be initializing an array of 'unsigned char' from an array of 'char'), but accidentally only updated it in either the array bound or the type, but not both.</div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>  unsigned char a[] = "foo", b[4] = "bar";<br></div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>... used to produce ...</div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style><div class="gmail_extra">|-VarDecl 0x6222ad0 <<stdin>:1:1, col:21> a 'unsigned char [4]'</div><div class="gmail_extra">| `-StringLiteral 0x6222ba8 <col:21> 'const char [4]' lvalue "foo"</div>
<div class="gmail_extra">`-VarDecl 0x6222c60 <col:1, col:35> b 'unsigned char [4]'</div><div class="gmail_extra">  `-StringLiteral 0x6222cb8 <col:35> 'unsigned char [4]' lvalue "bar"</div>
</div></div>