diff mbox

C++ PATCH for c++/54325 (wrong error initializing abstract base class)

Message ID 50C1B327.9060006@ubuntu.com
State New
Headers show

Commit Message

Matthias Klose Dec. 7, 2012, 9:13 a.m. UTC
Am 07.12.2012 06:05, schrieb Jason Merrill:
> It's perfectly OK to initialize a base class of abstract type; it's only an
> error to create a full object of such a type.  So this patch moves the check
> from more generic initialization code out into a function that's definitely
> creating a new object.
> 
> Tested x86_64-pc-linux-gnu, applying to trunk and 4.7.

this doesn't build on the branch:

../gcc/cp/tree.c: In function 'build_aggr_init_expr':
../gcc/cp/tree.c:399:1: error: parameter name omitted

this fixes the bootstrap, currently running the testsuite.

Comments

Jakub Jelinek Dec. 7, 2012, 9:17 a.m. UTC | #1
On Fri, Dec 07, 2012 at 10:13:11AM +0100, Matthias Klose wrote:
> Am 07.12.2012 06:05, schrieb Jason Merrill:
> > It's perfectly OK to initialize a base class of abstract type; it's only an
> > error to create a full object of such a type.  So this patch moves the check
> > from more generic initialization code out into a function that's definitely
> > creating a new object.
> > 
> > Tested x86_64-pc-linux-gnu, applying to trunk and 4.7.
> 
> this doesn't build on the branch:
> 
> ../gcc/cp/tree.c: In function 'build_aggr_init_expr':
> ../gcc/cp/tree.c:399:1: error: parameter name omitted
> 
> this fixes the bootstrap, currently running the testsuite.

Please commit as obvious with appropriate ChangeLog entry.

> --- cp/tree.c~	2012-12-07 10:01:16.665415647 +0100
> +++ cp/tree.c	2012-12-07 10:11:01.373410862 +0100
> @@ -396,7 +396,8 @@
>     callable.  */
> 
>  tree
> -build_aggr_init_expr (tree type, tree init, tsubst_flags_t /*complain*/)
> +build_aggr_init_expr (tree type, tree init,
> +		      tsubst_flags_t complain ATTRIBUTE_UNUSED)
>  {
>    tree fn;
>    tree slot;

	Jakub
Matthias Klose Dec. 7, 2012, 9:24 a.m. UTC | #2
Am 07.12.2012 10:17, schrieb Jakub Jelinek:
> On Fri, Dec 07, 2012 at 10:13:11AM +0100, Matthias Klose wrote:
>> Am 07.12.2012 06:05, schrieb Jason Merrill:
>>> It's perfectly OK to initialize a base class of abstract type; it's only an
>>> error to create a full object of such a type.  So this patch moves the check
>>> from more generic initialization code out into a function that's definitely
>>> creating a new object.
>>>
>>> Tested x86_64-pc-linux-gnu, applying to trunk and 4.7.
>>
>> this doesn't build on the branch:
>>
>> ../gcc/cp/tree.c: In function 'build_aggr_init_expr':
>> ../gcc/cp/tree.c:399:1: error: parameter name omitted
>>
>> this fixes the bootstrap, currently running the testsuite.
> 
> Please commit as obvious with appropriate ChangeLog entry.
> 
>> --- cp/tree.c~	2012-12-07 10:01:16.665415647 +0100
>> +++ cp/tree.c	2012-12-07 10:11:01.373410862 +0100
>> @@ -396,7 +396,8 @@
>>     callable.  */
>>
>>  tree
>> -build_aggr_init_expr (tree type, tree init, tsubst_flags_t /*complain*/)
>> +build_aggr_init_expr (tree type, tree init,
>> +		      tsubst_flags_t complain ATTRIBUTE_UNUSED)
>>  {
>>    tree fn;
>>    tree slot;
> 
> 	Jakub
> 

comitted.

  Matthias

2012-12-07  Matthias Klose  <doko@ubuntu.com>

        * tree.c (build_aggr_init_expr): Add parameter name, mark as unused.
Gabriel Dos Reis Dec. 7, 2012, 1:34 p.m. UTC | #3
On Fri, Dec 7, 2012 at 3:13 AM, Matthias Klose <doko@ubuntu.com> wrote:
> Am 07.12.2012 06:05, schrieb Jason Merrill:
>> It's perfectly OK to initialize a base class of abstract type; it's only an
>> error to create a full object of such a type.  So this patch moves the check
>> from more generic initialization code out into a function that's definitely
>> creating a new object.
>>
>> Tested x86_64-pc-linux-gnu, applying to trunk and 4.7.
>
> this doesn't build on the branch:
>
> ../gcc/cp/tree.c: In function 'build_aggr_init_expr':
> ../gcc/cp/tree.c:399:1: error: parameter name omitted
>
> this fixes the bootstrap, currently running the testsuite.
>
> --- cp/tree.c~  2012-12-07 10:01:16.665415647 +0100
> +++ cp/tree.c   2012-12-07 10:11:01.373410862 +0100
> @@ -396,7 +396,8 @@
>     callable.  */
>
>  tree
> -build_aggr_init_expr (tree type, tree init, tsubst_flags_t /*complain*/)
> +build_aggr_init_expr (tree type, tree init,
> +                     tsubst_flags_t complain ATTRIBUTE_UNUSED)
>  {
>    tree fn;
>    tree slot;
>

We should definitely teach the compiler to accept the former and not
be silly in requiring the latter when C++.

-- Gaby
Jakub Jelinek Dec. 7, 2012, 1:39 p.m. UTC | #4
On Fri, Dec 07, 2012 at 07:34:30AM -0600, Gabriel Dos Reis wrote:
> On Fri, Dec 7, 2012 at 3:13 AM, Matthias Klose <doko@ubuntu.com> wrote:
> > Am 07.12.2012 06:05, schrieb Jason Merrill:
> >> It's perfectly OK to initialize a base class of abstract type; it's only an
> >> error to create a full object of such a type.  So this patch moves the check
> >> from more generic initialization code out into a function that's definitely
> >> creating a new object.
> >>
> >> Tested x86_64-pc-linux-gnu, applying to trunk and 4.7.
> >
> > this doesn't build on the branch:
> >
> > ../gcc/cp/tree.c: In function 'build_aggr_init_expr':
> > ../gcc/cp/tree.c:399:1: error: parameter name omitted
> >
> > this fixes the bootstrap, currently running the testsuite.
> >
> > --- cp/tree.c~  2012-12-07 10:01:16.665415647 +0100
> > +++ cp/tree.c   2012-12-07 10:11:01.373410862 +0100
> > @@ -396,7 +396,8 @@
> >     callable.  */
> >
> >  tree
> > -build_aggr_init_expr (tree type, tree init, tsubst_flags_t /*complain*/)
> > +build_aggr_init_expr (tree type, tree init,
> > +                     tsubst_flags_t complain ATTRIBUTE_UNUSED)
> >  {
> >    tree fn;
> >    tree slot;
> >
> 
> We should definitely teach the compiler to accept the former and not
> be silly in requiring the latter when C++.

Except that GCC 4.7 doesn't mandate building with C++, so the sources must
be valid C.

	Jakub
Gabriel Dos Reis Dec. 7, 2012, 1:43 p.m. UTC | #5
On Fri, Dec 7, 2012 at 7:39 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Dec 07, 2012 at 07:34:30AM -0600, Gabriel Dos Reis wrote:
>> On Fri, Dec 7, 2012 at 3:13 AM, Matthias Klose <doko@ubuntu.com> wrote:
>> > Am 07.12.2012 06:05, schrieb Jason Merrill:
>> >> It's perfectly OK to initialize a base class of abstract type; it's only an
>> >> error to create a full object of such a type.  So this patch moves the check
>> >> from more generic initialization code out into a function that's definitely
>> >> creating a new object.
>> >>
>> >> Tested x86_64-pc-linux-gnu, applying to trunk and 4.7.
>> >
>> > this doesn't build on the branch:
>> >
>> > ../gcc/cp/tree.c: In function 'build_aggr_init_expr':
>> > ../gcc/cp/tree.c:399:1: error: parameter name omitted
>> >
>> > this fixes the bootstrap, currently running the testsuite.
>> >
>> > --- cp/tree.c~  2012-12-07 10:01:16.665415647 +0100
>> > +++ cp/tree.c   2012-12-07 10:11:01.373410862 +0100
>> > @@ -396,7 +396,8 @@
>> >     callable.  */
>> >
>> >  tree
>> > -build_aggr_init_expr (tree type, tree init, tsubst_flags_t /*complain*/)
>> > +build_aggr_init_expr (tree type, tree init,
>> > +                     tsubst_flags_t complain ATTRIBUTE_UNUSED)
>> >  {
>> >    tree fn;
>> >    tree slot;
>> >
>>
>> We should definitely teach the compiler to accept the former and not
>> be silly in requiring the latter when C++.
>
> Except that GCC 4.7 doesn't mandate building with C++, so the sources must
> be valid C.
>
>         Jakub

Right you are!

Thanks,

-- Gaby
diff mbox

Patch

--- cp/tree.c~	2012-12-07 10:01:16.665415647 +0100
+++ cp/tree.c	2012-12-07 10:11:01.373410862 +0100
@@ -396,7 +396,8 @@ 
    callable.  */

 tree
-build_aggr_init_expr (tree type, tree init, tsubst_flags_t /*complain*/)
+build_aggr_init_expr (tree type, tree init,
+		      tsubst_flags_t complain ATTRIBUTE_UNUSED)
 {
   tree fn;
   tree slot;