diff mbox

[C] improve missing initializers diagnostics

Message ID CAESRpQBwmm+H4hNtodnJP0MYApx22NVY9Jp4MCr4y0+pEE3xVg@mail.gmail.com
State New
Headers show

Commit Message

Manuel López-Ibáñez April 25, 2012, 4:08 p.m. UTC
On 25 April 2012 16:46, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sat, Apr 21, 2012 at 4:58 AM, Manuel López-Ibáñez
> <lopezibanez@gmail.com> wrote:
>> This patch improves missing initializers diagnostics. From:
>>
>> pr36446.c:13:3: warning: missing initializer [-Wmissing-field-initializers]
>>   .h = {1},
>>   ^
>> pr36446.c:13:3: warning: (near initialization for ‘m0.h.b’)
>> [-Wmissing-field-initializers]
>>   .h = {1},
>>   ^
>>
>> to:
>>
>> pr36446.c:13:3: warning: missing initializer for field ‘b’ of ‘struct
>> h’ [-Wmissing-field-initializers]
>>   .h = {1},
>>   ^
>> pr36446.c:3:7: note: ‘b’ declared here
>>   int b;
>>       ^
>>
>> Bootstrapped/regression tested.
>>
>> OK?
>>
>>
>> 2012-04-19  Manuel López-Ibáñez  <manu@gcc.gnu.org>
>>
>>        * c-typeck.c (pop_init_level): Improve diagnostics.
>> testsuite/
>>        * gcc.dg/m-un-2.c: Update.
>>        * gcc.dg/20011021-1.c: Update.
>
> On Linux/x86, revision 186808 gave me:
>
> FAIL: gcc.dg/20011021-1.c  (test for warnings, line 34)
> FAIL: gcc.dg/20011021-1.c  (test for warnings, line 41)
> FAIL: gcc.dg/20011021-1.c  (test for warnings, line 44)
> FAIL: gcc.dg/20011021-1.c (test for excess errors)
> FAIL: gcc.dg/20011021-1.c near init (test for warnings, line 27)
> FAIL: gcc.dg/20011021-1.c near init (test for warnings, line 30)
> FAIL: gcc.dg/m-un-2.c (test for excess errors)
> FAIL: gcc.dg/m-un-2.c warning regression 2 (test for warnings, line 12)
> FAIL: gcc.dg/missing-field-init-2.c  (test for warnings, line 14)
> FAIL: gcc.dg/missing-field-init-2.c  (test for warnings, line 7)
> FAIL: gcc.dg/missing-field-init-2.c  (test for warnings, line 8)
> FAIL: gcc.dg/missing-field-init-2.c (test for excess errors)
>
> Revision 186806 is OK.

Somehow I committed a broken version of the patch. It should have been this:



Sorry for the mistake,

Manuel.

Comments

Manuel López-Ibáñez April 27, 2012, 8:24 a.m. UTC | #1
On 25 April 2012 18:08, Manuel López-Ibáñez <lopezibanez@gmail.com> wrote:
> On 25 April 2012 16:46, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Sat, Apr 21, 2012 at 4:58 AM, Manuel López-Ibáñez
>> <lopezibanez@gmail.com> wrote:
>>> This patch improves missing initializers diagnostics. From:
>>>
>>> pr36446.c:13:3: warning: missing initializer [-Wmissing-field-initializers]
>>>   .h = {1},
>>>   ^
>>> pr36446.c:13:3: warning: (near initialization for ‘m0.h.b’)
>>> [-Wmissing-field-initializers]
>>>   .h = {1},
>>>   ^
>>>
>>> to:
>>>
>>> pr36446.c:13:3: warning: missing initializer for field ‘b’ of ‘struct
>>> h’ [-Wmissing-field-initializers]
>>>   .h = {1},
>>>   ^
>>> pr36446.c:3:7: note: ‘b’ declared here
>>>   int b;
>>>       ^
>>>
>>> Bootstrapped/regression tested.
>>>
>>> OK?
>>>
>>>
>>> 2012-04-19  Manuel López-Ibáñez  <manu@gcc.gnu.org>
>>>
>>>        * c-typeck.c (pop_init_level): Improve diagnostics.
>>> testsuite/
>>>        * gcc.dg/m-un-2.c: Update.
>>>        * gcc.dg/20011021-1.c: Update.
>>
>> On Linux/x86, revision 186808 gave me:
>>
>> FAIL: gcc.dg/20011021-1.c  (test for warnings, line 34)
>> FAIL: gcc.dg/20011021-1.c  (test for warnings, line 41)
>> FAIL: gcc.dg/20011021-1.c  (test for warnings, line 44)
>> FAIL: gcc.dg/20011021-1.c (test for excess errors)
>> FAIL: gcc.dg/20011021-1.c near init (test for warnings, line 27)
>> FAIL: gcc.dg/20011021-1.c near init (test for warnings, line 30)
>> FAIL: gcc.dg/m-un-2.c (test for excess errors)
>> FAIL: gcc.dg/m-un-2.c warning regression 2 (test for warnings, line 12)
>> FAIL: gcc.dg/missing-field-init-2.c  (test for warnings, line 14)
>> FAIL: gcc.dg/missing-field-init-2.c  (test for warnings, line 7)
>> FAIL: gcc.dg/missing-field-init-2.c  (test for warnings, line 8)
>> FAIL: gcc.dg/missing-field-init-2.c (test for excess errors)
>>
>> Revision 186806 is OK.
>
> Somehow I committed a broken version of the patch. It should have been this:
>
>
> --- gcc/c-typeck.c      (revision 186821)
> +++ gcc/c-typeck.c      (working copy)
> @@ -7063,11 +7063,11 @@ pop_init_level (int implicit, struct obs
>            if (warning_at (input_location, OPT_Wmissing_field_initializers,
>                            "missing initializer for field %qD of %qT",
>                            constructor_unfilled_fields,
>                            constructor_type))
>              inform (DECL_SOURCE_LOCATION (constructor_unfilled_fields),
> -                     "%qT declared here", constructor_unfilled_fields);
> +                     "%qD declared here", constructor_unfilled_fields);
>          }
>     }
>
>
> I'll commit as soon as it finishes bootstrapping+testing.

Committed as revision 186896.

Cheers,

Manuel.
diff mbox

Patch

--- gcc/c-typeck.c      (revision 186821)
+++ gcc/c-typeck.c      (working copy)
@@ -7063,11 +7063,11 @@  pop_init_level (int implicit, struct obs
            if (warning_at (input_location, OPT_Wmissing_field_initializers,
                            "missing initializer for field %qD of %qT",
                            constructor_unfilled_fields,
                            constructor_type))
              inform (DECL_SOURCE_LOCATION (constructor_unfilled_fields),
-                     "%qT declared here", constructor_unfilled_fields);
+                     "%qD declared here", constructor_unfilled_fields);
          }
     }


I'll commit as soon as it finishes bootstrapping+testing.