This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ patch] for C++/52369


2014-02-27 19:25 GMT+01:00 Jason Merrill <jason@redhat.com>:
> On 02/23/2014 02:36 PM, Fabien Chêne wrote:
>>
>>          * cp/method.c (walk_field_subobs): improve the diagnostic
>>      locations for both REFERENCE_TYPEs and non-static const members.
>
>
> It's important to have the error location be the place where the actual
> problem is, namely the constructor definition.  Instead of changing it,
> please add an inform pointing out the location of the member in question.

Well, I am not very happy with the c++11 diagnostic compared to the c++98 one.
Below is the original c++11 diagnostic for pr44086.C:

struct A
{
    int const i : 2;
};

void f()
{
    A a;              // { dg-error "deleted|uninitialized const" }
    new A;              // { dg-error "deleted|uninitialized const" }
    A();              // { dg-error "deleted" "" { target c++11 } }
    new A();              // { dg-error "deleted" "" { target c++11 } }
}

testsuite/g++.dg/init/uninitialized1.C:10:3: error: use of deleted
function 'A::A()'
testsuite/g++.dg/init/uninitialized1.C:3:8: note: 'A::A()' is
implicitly deleted because the default definition would be ill-formed:
testsuite/g++.dg/init/uninitialized1.C:3:8: error: uninitialized
non-static const member 'const int A::value1'

The first two lines are fine in my opinion. The third line should
actually be split into an error + an inform. By doing that, I think we
also need to reformulate the error message like this:
testsuite/g++.dg/init/pr44086.C:4:8: error: 'struct A' needs its
non-static const members to be initialized
testsuite/g++.dg/init/pr44086.C:6:19: note: 'A::i' should be initialized

What do you think ? (before I bother adjusting the testsuite)

Incidentally, while moving the diagnostic concerning the uninitialized
field from an error to an inform, I realized that the syntactic sugar
%q#D is no longer honored an is treated as %qD, is it expected ?


-- 
Fabien


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]