This patch corrects ambiguous partial specializations of
typelist::detail::append_. Previously, neither append_<chain<Hd, Tl>,
Typelist_Chain> nor append_<Typelist_Chain, null_type> was a better
match for append_<chain<Hd, Tl>, null_type>.
2019-02-22 Tom Honermann <tom@honermann.net>
* include/ext/typelist.h: Constrain a partial specialization of
typelist::detail::append_ to only match chain<T1,T2>.
From-SVN: r269088
Backport https://golang.org/cl/163237 from the master library:
Ensure that cmd/go consistently calls base.Exit rather than os.Exit,
so that we don't incorrectly leave the work directory around on exit.
Test this by modifying the testsuite to run all the tests with TMPDIR
set to a temporary directory, and then check that no files are left
behind in that temporary directory. Adjust a couple of tests to make
this approach work.
Updates https://gcc.gnu.org/PR89406
Reviewed-on: https://go-review.googlesource.com/c/163198
From-SVN: r269086
Here, we were trying to instantiate the default argument before setting
DECL_FRIEND_CONTEXT, so that the instantiated lambda ended up being treated
as part of the S template, which confused dwarf2out.
* pt.c (tsubst_function_decl): SET_DECL_FRIEND_CONTEXT sooner.
From-SVN: r269081
Just like in make_constrained_auto, we need to defer setting TYPE_CANONICAL
until we've set fields that will affect structural_comptypes.
* pt.c (make_template_placeholder): Set TYPE_CANONICAL after
CLASS_PLACEHOLDER_TEMPLATE.
From-SVN: r269080
PR c++/89285
* builtins.c (fold_builtin_arith_overflow): If first two args are
INTEGER_CSTs, set intres and ovfres to constants rather than calls
to ifn.
* constexpr.c (struct constexpr_fundef): Add parms and result members.
(retrieve_constexpr_fundef): Adjust for the above change.
(register_constexpr_fundef): Save constexpr body with copy_fn,
temporarily set DECL_CONTEXT on DECL_RESULT before that.
(get_fundef_copy): Change FUN argument to FUNDEF with
constexpr_fundef * type, grab body and parms/result out of
constexpr_fundef struct and temporarily change it for copy_fn calls
too.
(cxx_eval_builtin_function_call): For __builtin_FUNCTION temporarily
adjust current_function_decl from ctx->call context. Test
!potential_constant_expression instead of !is_constant_expression.
(cxx_bind_parameters_in_call): Grab parameters from new_call. Undo
convert_for_arg_passing changes for TREE_ADDRESSABLE type passing.
(cxx_eval_call_expression): Adjust get_fundef_copy caller.
(cxx_eval_conditional_expression): For IF_STMT, allow then or else
operands to be NULL.
(label_matches): Handle BREAK_STMT and CONTINUE_STMT.
(cxx_eval_loop_expr): Add support for FOR_STMT, WHILE_STMT and DO_STMT.
(cxx_eval_switch_expr): Add support for SWITCH_STMT.
(cxx_eval_constant_expression): Handle IF_STMT, FOR_STMT, WHILE_STMT,
DO_STMT, CONTINUE_STMT, SWITCH_STMT, BREAK_STMT and CONTINUE_STMT.
For SIZEOF_EXPR, recurse on the result of fold_sizeof_expr. Ignore
DECL_EXPR with USING_DECL operand.
* lambda.c (maybe_add_lambda_conv_op): Build thisarg using
build_int_cst to make it a valid constant expression.
* g++.dg/ubsan/vptr-4.C: Expect reinterpret_cast errors.
* g++.dg/cpp1y/constexpr-84192.C (f2): Adjust expected diagnostics.
* g++.dg/cpp1y/constexpr-70265-2.C (foo): Adjust expected line of
diagnostics.
* g++.dg/cpp1y/constexpr-89285.C: New test.
* g++.dg/cpp0x/constexpr-arith-overflow.C (add, sub, mul): Ifdef out
for C++11.
(TEST_ADD, TEST_SUB, TEST_MUL): Define to Assert (true) for C++11.
* g++.dg/cpp0x/constexpr-arith-overflow2.C: New test.
From-SVN: r269078
The common base class for __is_move_insertable and __is_copy_insertable
instantiates both the copy and move tests, when only one is needed. The
unneeded one might cause errors outside the immediate context.
The solution used in this patch is to replace them with alias templates,
which will only be instantiated as needed.
PR libstdc++/89416
* include/bits/alloc_traits.h (__is_alloc_insertable_impl): Replace
class template with class. Replace move and copy member types with
member alias templates, so they are only instantiated when needed.
(__is_copy_insertable, __is_move_insertable): Adjust base class.
* testsuite/23_containers/vector/modifiers/push_back/89130.cc: Enable
test for C++11/14/17 as well.
* testsuite/23_containers/vector/modifiers/push_back/89416.cc: New
test.
From-SVN: r269075
Base fields for empty bases appear in initialization order, which may not be
the same as layout order. If they also show up in a CONSTRUCTOR in that
order, output_constructor_regular_field aborts because it understandably
doesn't want to go backwards. I also considered making o_c_r_f more
tolerant of the case where the out-of-order field has fieldsize 0, and so no
actual data needs to be emitted, but we might as well avoid adding an
element to the CONSTRUCTOR in the first place.
* typeck2.c (process_init_constructor_record): Skip trivial
initialization of an empty base.
From-SVN: r269073
Like the pr88850.c test, also fix the pr88850-2.c testcase which
was failing in hardfp environments.
Committed as obvious.
gcc/testsuite/
* gcc.target/arm/pr88850-2.c: Block -mfloat-abi override.
* gcc.target/arm/pr88850.c: Use -mfloat-abi=softfp.
From-SVN: r269072
2019-02-21 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/86119
* class.c (gfc_get_len_component): Add argument k for kind.
If the kind of the resulting expression is not equal to k,
convert it.
* gfortran.h (gfc_len_component): Adjust prototype.
* simplify.c (gfc_simplify_len): Pass kind to
gfc_get_len_component.
2019-02-21 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/86119
* gfortran.dg/warn_conversion_11.f90: New test.
From-SVN: r269070
Issue an error when -mindirect-branch or -mfunction-return are used
with incompatible -fcf-protection.
gcc/
PR target/87412
* config/i386/i386.c (ix86_set_indirect_branch_type): Issue an
error for -mindirect-branch/-mfunction-return with incompatible
-fcf-protection.
gcc/testsuite/
PR target/87412
* gcc.target/i386/pr87412-1.c: New file.
* gcc.target/i386/pr87412-2.c: Likewise.
* gcc.target/i386/pr87412-3.c: Likewise.
* gcc.target/i386/pr87412-4.c: Likewise.
From-SVN: r269068
2019-02-21 Richard Biener <rguenther@suse.de>
PR middle-end/89392
cp/
* vtable-class-hierarchy.c (vtv_generate_init_routine): Do not
make symtab process new functions here.
From-SVN: r269065
c_parse_final_cleanups checks DECL_IN_AGGR_P to avoid trying to emit a
static data member that has not been defined. The inline variable patch
changed that to exempt inline variables. But in this case we haven't
instantiated the variable yet, so we really don't have a definition. This
patch changes inline variable handling such that DECL_IN_AGGR_P is not set
for a defined inline variable, so we can remove all the checks of
DECL_INLINE_VAR_P after DECL_IN_AGGR_P.
With that change we were failing on a static data member that had been
instantiated due to a use before we got around to processing it in
instantiate_class_template; we should detect that and avoid all the
finish_static_data_member_decl processing, which assumes that it is the
first time we're seeing the variable.
* decl2.c (finish_static_data_member_decl): Don't set DECL_IN_AGGR_P
for a non-template inline variable. Do nothing for an
already-instantiated variable.
(c_parse_final_cleanups): Check DECL_IN_AGGR_P without
DECL_INLINE_VAR_P.
* decl.c (check_initializer): Likewise.
(make_rtl_for_nonlocal_decl): Likewise.
* pt.c (instantiate_decl): Likewise.
* typeck2.c (store_init_value): Likewise.
From-SVN: r269064
PR c++/89405
* decl.c (maybe_commonize_var): When clearing TREE_PUBLIC and
DECL_COMMON, set DECL_INTERFACE_KNOWN.
* g++.dg/cpp1z/inline-var5.C: New test.
From-SVN: r269058
PR middle-end/89412
* expr.c (expand_assignment): If result is a MEM, use change_address
instead of simplify_gen_subreg.
* gcc.c-torture/compile/pr89412.c: New test.
From-SVN: r269057
PR middle-end/89091
* fold-const.c (decode_field_reference): Return NULL_TREE if
lang_hooks.types.type_for_size returns NULL. Check it before
overwriting *exp_. Use return NULL_TREE instead of return 0.
* gcc.dg/torture/pr89091.c: New test.
Co-Authored-By: David Malcolm <dmalcolm@redhat.com>
From-SVN: r269056
PR c++/89336
* constexpr.c (cxx_eval_store_expression): Diagnose changing of active
union member for -std=c++17 and earlier.
* g++.dg/cpp1y/constexpr-89336-3.C: New test.
From-SVN: r269052
PR c/89410 reports various issues with #line directives with very
large numbers; one of them is an ICE inside diagnostic-show-locus.c
when emitting a diagnostic at line 0xffffffff.
The issue is that the arithmetic in layout::calculate_line_spans to
determine if two line spans are sufficiently close to consolidate
was using the unsigned 32-bit linenum_type, which was overflowing
when comparing the line for the expanded location with those of
the location range (all on line 0xffffffff), leading to it
erroneously adding two spans for the same line, leading to an
assertion failure.
This patch fixes the ICE by generalizing the use of long long in
line-map.h's comparison function for linenum_type into a new
linenum_arith_t typedef, and using it here.
Doing so uncovered a second problem: the loop to print the lines
within the line_span for this case is infinite: looping from
0xfffffff upwards, overflowing to 0, and then never becoming
greater than 0xfffffff. The patch fixes this by using linenum_arith_t
there also.
gcc/ChangeLog:
PR c/89410
* diagnostic-show-locus.c (layout::calculate_line_spans): Use
linenum_arith_t when determining if two adjacent line spans are
close enough to merge.
(diagnostic_show_locus): Use linenum_arith_t when iterating over
lines within each line_span.
gcc/testsuite/ChangeLog:
PR c/89410
* gcc.dg/pr89410-1.c: New test.
* gcc.dg/pr89410-2.c: New test.
libcpp/ChangeLog:
PR c/89410
* include/line-map.h (linenum_arith_t): New typedef.
(compare): Use it.
From-SVN: r269050
Here build_offset_ref calls build_qualified_name to make a SCOPE_REF because
the dependent template arguments make type_dependent_expression_p (member)
true. We could probably work hard to prevent this, but it doesn't seem
necessary, and it's easy to fix write_expression to handle the result.
* mangle.c (write_expression): Handle SCOPE_REF to BASELINK.
From-SVN: r269048
Here 'skipped' was set to -1 to force an explicit initializer for 'uninit'
before the initializer for 'initialized', and so we also tried to emit an
explicit initializer for the flexible array, for which build_zero_init
returns error_mark_node. We should ignore flexarrays even when
skipped < 0.
* typeck2.c (process_init_constructor_record): Skip flexarrays.
From-SVN: r269046
Revert:
PR target/89397
* config/i386/i386.c (ix86_option_override_internal): Set
opts->x_ix86_fpmath to FPMATH_387 when SSE is disabled.
gcc/testsuite/
PR target/89397
* gcc.target/i386/pr89397.c: New test.
From-SVN: r269040
/cp
2019-02-20 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84536
* pt.c (tsubst_init): Diagnose an initializer expanding to an
empty list of expressions; tweak wrt dependent types.
(regenerate_decl_from_template): For VAR_DECLs call tsubst_init
instead of tsubst_expr.
/testsuite
2019-02-20 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84536
* g++.dg/cpp1y/var-templ60.C: New.
From-SVN: r269037
GCC revision 259524 implemented range check for the vec_splat_{su}{8,16,32}
builtins. However, as a consequence of the implementation, the range check
is not done correctly for the expected vspltis[bhw] instructions. The result
is that we may not get a valid error message if the valid range of the data
is exceeded.
Although the input of the function prototype of vec_splat_{su}{8,16,32} is
const int, the actual data usage range is limited to the data range of 5 bits
signed. We should limit the int_cst.val[0] data to the 5 bit signed data range
without any modification in the input arg0 parameter. However, the sext_hwi
function intercepts the data of TREE_INT_CST_LOW (arg0) as size bits in the
sext_hwi (TREE_INT_CST_LOW (arg0), size) statement. This will cause some of
the excess data to fall within the range of 5 bits signed, so that the correct
diagnostic information cannot be generated, we need to remove the sext_hwi to
ensure that the input data has not been modified.
This patch fix range check for the vec_splat_s[8,16,32] builtins. The argument
must be a 5-bit const int as specified for the vspltis[bhw] instructions.
for gcc/ChangeLog
PR target/88100
* gcc/config/rs6000/rs6000.c (rs6000_gimple_fold_builtin)
<case ALTIVEC_BUILTIN_VSPLTISB, ALTIVEC_BUILTIN_VSPLTISH,
ALTIVEC_BUILTIN_VSPLTISW>: Don't convert the operand before
range checking it.
for gcc/testsuite/ChangeLog
PR target/88100
* gcc/testsuite/gcc.target/powerpc/pr88100.c: New testcase.
From-SVN: r269033
Since my patch for 81359 allowed us to signal failure on return from
maybe_instantiate_noexcept, we no longer need to turn an error into
noexcept(false). We also need to handle NSDMI instantiation errors under
synthesized_method_walk. This change caused some instantiation context
notes to be lost in the testsuite, so I added push_tinst_level to
get_defaulted_eh_spec to restore that context.
* method.c (walk_field_subobs): Remember errors from get_nsdmi.
(get_defaulted_eh_spec): Call push_tinst_level.
* pt.c (maybe_instantiate_noexcept): Keep error_mark_node.
* typeck2.c (merge_exception_specifiers): Handle error_mark_node.
From-SVN: r269032