On 11/20/2015 01:52 PM, H.J. Lu wrote:
On Tue, Nov 17, 2015 at 4:22 AM, Richard Biener
<richard.guent...@gmail.com> wrote:
On Tue, Nov 17, 2015 at 12:01 PM, H.J. Lu <hjl.to...@gmail.com> wrote:
Empty record should be returned and passed the same way in C and C++.
This patch adds LANG_HOOKS_EMPTY_RECORD_P for C++ empty class, which
defaults to return false.  For C++, LANG_HOOKS_EMPTY_RECORD_P is defined
to is_really_empty_class, which returns true for C++ empty classes.  For
LTO, we stream out a bit to indicate if a record is empty and we store
it in TYPE_LANG_FLAG_0 when streaming in.  get_ref_base_and_extent is
changed to set bitsize to 0 for empty records.  Middle-end and x86
backend are updated to ignore empty records for parameter passing and
function value return.  Other targets may need similar changes.

Please avoid a new langhook for this and instead claim a bit in tree_type_common
like for example restrict_flag (double-check it is unused for non-pointers).

There is no bit in tree_type_common I can overload.  restrict_flag is
checked for non-pointers to issue an error when it is used on non-pointers:

/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/template/qualttp20.C:19:38:
error: ‘__restrict__’ qualifiers cannot be applied to ‘AS::L’
    typedef typename T::L __restrict__ r;// { dg-error "'__restrict__'
qualifiers cannot" "" }

The C++ front end only needs to check TYPE_RESTRICT for this purpose on front-end-specific type codes like TEMPLATE_TYPE_PARM; cp_type_quals could handle that specifically if you change TYPE_RESTRICT to only apply to pointers.

Jason


Reply via email to