This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR63300 'const volatile' sometimes stripped in debug info.
- From: Andreas Arnez <arnez at linux dot vnet dot ibm dot com>
- To: Mark Wielaard <mjw at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, jason at redhat dot com
- Date: Tue, 23 Sep 2014 17:17:47 +0200
- Subject: Re: [PATCH] PR63300 'const volatile' sometimes stripped in debug info.
- Authentication-results: sourceware.org; auth=none
- References: <1411249535-2193-1-git-send-email-mjw at redhat dot com> <87oau8kp39 dot fsf at br87z6lw dot de dot ibm dot com> <20140923114440 dot GA19566 at blokker dot redhat dot com>
On Tue, Sep 23 2014, Mark Wielaard wrote:
> On Mon, Sep 22, 2014 at 10:59:38AM +0200, Andreas Arnez wrote:
>> > + sub_qual = TYPE_QUAL_RESTRICT;
>> > + if ((sub_quals & ~sub_qual) != TYPE_UNQUALIFIED
>> > + && get_qualified_type (type, sub_quals & ~sub_qual) != NULL_TREE)
>> > + return true;
>> > +
>> > + sub_qual = TYPE_QUAL_CONST & TYPE_QUAL_VOLATILE;
>>
>> You probably mean '|' instead of '&' here.
>
> Eep. Yes (3x).
>
> But then I tried to write a testcase to show the cases that fail
> because of this typo. And failed, everything works fine. That is
> because these checks are bogus. sub_quals contains at most 2 qualifiers.
> const, volatile and restrict, minus the qual we are interested in.
> And subtracting two always results in the empty set. So I removed
> those 3 cases.
Right, the checks were bogus. But from looking at the code before
adding restrict, I guess it was intended to *minimze* the number of
generated DIEs. If we keep that goal, maybe the function should
actually return the "rank" of the found sub-qualified type (i.e., the
number of matching sub-qualifiers) and the caller should follow the path
with the highest rank. Then the checks would be needed again, and they
would even have to be doubled for 'atomic'. Without such handling there
are cases where more DIEs than necessary are created, e.g. if we have
the following types:
some_base_t *const
some_base_t *volatile restrict
some_base_t *const volatile restrict
Then the latter is based on the first instead of the second, although
this requires one more DIE.