diff mbox

Silence class vs. struct warnings (vec)

Message ID 1386234010.14008.18.camel@yam-132-YW-E178-FTW
State New
Headers show

Commit Message

Oleg Endo Dec. 5, 2013, 9 a.m. UTC
Hi,

When building GCC on OSX with its native XCode/Clang tools, it outputs
quite some "struct X was previously declared as a class" or similar
warnings (-Wmismatched-tags is enabled by default).

The attached patch fixes a mismatch in struct vec_prefix when referring
to struct vec.

Tested with make all-gcc.
OK for trunk?

Cheers,
Oleg

gcc/ChangeLog:
        * vec.h (struct vec_prefix): Use struct vec instead of class 
	vec.

Comments

Andrew Pinski Dec. 5, 2013, 9:11 a.m. UTC | #1
> On Dec 5, 2013, at 1:00 AM, Oleg Endo <oleg.endo@t-online.de> wrote:
> 
> Hi,
> 
> When building GCC on OSX with its native XCode/Clang tools, it outputs
> quite some "struct X was previously declared as a class" or similar
> warnings (-Wmismatched-tags is enabled by default).
> 
> The attached patch fixes a mismatch in struct vec_prefix when referring
> to struct vec.
> 
> Tested with make all-gcc.
> OK for trunk?

What is this warning trying to do really?  I think this is a very bad warning as points out standard code for no reason. 

Thanks,
Andrew


> 
> Cheers,
> Oleg
> 
> gcc/ChangeLog:
>        * vec.h (struct vec_prefix): Use struct vec instead of class 
>    vec.
> <class_vec.patch>
Oleg Endo Dec. 5, 2013, 9:33 a.m. UTC | #2
On Thu, 2013-12-05 at 01:11 -0800, pinskia@gmail.com wrote:
> 
> > On Dec 5, 2013, at 1:00 AM, Oleg Endo <oleg.endo@t-online.de> wrote:
> > 
> > Hi,
> > 
> > When building GCC on OSX with its native XCode/Clang tools, it outputs
> > quite some "struct X was previously declared as a class" or similar
> > warnings (-Wmismatched-tags is enabled by default).
> > 
> > The attached patch fixes a mismatch in struct vec_prefix when referring
> > to struct vec.
> > 
> > Tested with make all-gcc.
> > OK for trunk?
> 
> What is this warning trying to do really?  I think this is a very bad warning as points out standard code for no reason. 

I think the answer is here:
http://llvm.org/bugs/show_bug.cgi?id=11632

Cheers,
Oleg
Andrew Pinski Dec. 5, 2013, 9:45 a.m. UTC | #3
> On Dec 5, 2013, at 1:33 AM, Oleg Endo <oleg.endo@t-online.de> wrote:
> 
>> On Thu, 2013-12-05 at 01:11 -0800, pinskia@gmail.com wrote:
>> 
>>> On Dec 5, 2013, at 1:00 AM, Oleg Endo <oleg.endo@t-online.de> wrote:
>>> 
>>> Hi,
>>> 
>>> When building GCC on OSX with its native XCode/Clang tools, it outputs
>>> quite some "struct X was previously declared as a class" or similar
>>> warnings (-Wmismatched-tags is enabled by default).
>>> 
>>> The attached patch fixes a mismatch in struct vec_prefix when referring
>>> to struct vec.
>>> 
>>> Tested with make all-gcc.
>>> OK for trunk?
>> 
>> What is this warning trying to do really?  I think this is a very bad warning as points out standard code for no reason. 
> 
> I think the answer is here:
> http://llvm.org/bugs/show_bug.cgi?id=11632

Except we don't support compiling GCC with microsoft's broken compiler. So again why make this change for broken compilers that is hard to support in the first place?

> 
> Cheers,
> Oleg
>
Florian Weimer Dec. 5, 2013, 12:09 p.m. UTC | #4
On 12/05/2013 10:45 AM, pinskia@gmail.com wrote:
>
>
>> On Dec 5, 2013, at 1:33 AM, Oleg Endo <oleg.endo@t-online.de> wrote:
>>
>>> On Thu, 2013-12-05 at 01:11 -0800, pinskia@gmail.com wrote:
>>>
>>>> On Dec 5, 2013, at 1:00 AM, Oleg Endo <oleg.endo@t-online.de> wrote:
>>>>
>>>> Hi,
>>>>
>>>> When building GCC on OSX with its native XCode/Clang tools, it outputs
>>>> quite some "struct X was previously declared as a class" or similar
>>>> warnings (-Wmismatched-tags is enabled by default).
>>>>
>>>> The attached patch fixes a mismatch in struct vec_prefix when referring
>>>> to struct vec.
>>>>
>>>> Tested with make all-gcc.
>>>> OK for trunk?
>>>
>>> What is this warning trying to do really?  I think this is a very bad warning as points out standard code for no reason.
>>
>> I think the answer is here:
>> http://llvm.org/bugs/show_bug.cgi?id=11632
>
> Except we don't support compiling GCC with microsoft's broken compiler. So again why make this change for broken compilers that is hard to support in the first place?

I'm not even sure the Microsoft compiler is broken in this regard.

They have class forward declarations which change the representation of 
pointers to such classes, and those have to match with the definition. 
But I'm not sure that the C++ compiler actually errors out on 
class/struct mismatches (unless explicitly told to).
diff mbox

Patch

Index: gcc/vec.h
===================================================================
--- gcc/vec.h	(revision 205573)
+++ gcc/vec.h	(working copy)
@@ -1216,7 +1216,7 @@ 
   }
 
 private:
-  friend class vec<T, va_heap, vl_ptr>;
+  friend struct vec<T, va_heap, vl_ptr>;
 
   vec_prefix m_header;
   T m_data[N];