Re: [patch, fortran] PR 47359 - warnings for constant conversion
Am 01.06.2015 um 22:10 schrieb Steve Kargl: c) Warn for print *,3.1415926535 with -Wconversion-extra and don't warn for print *,3.141592653589_4 This would be my first choice. If a user actually specifies a suffix, I assume that the user has given some thought to the preceding digits. d) Like now: Warn with -Wconversion-extra for both print *,3.1415926535 and print *,3.14159265358979_4 This would be my second choice. I would actually prefer d). -Wconversion-extra is about warning for things that are often correct. I would like to have a chance to warn about this kind of construct. Any other comments? OK to commit? Thomas
genmatch: guess the type of a?b:c as b instead of a
Hello, as discussed around https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00041.html we are currently guessing the type of a?b:c incorrectly. This does not affect current simplifications, because the only 'cond' in output patterns are at the outermost level, so their type is forced to 'type' and never guessed. Indeed, the patch does not change the generated *-match.c. It would allow removing an explicit cond:itype in a patch posted by Jeff. I tested it on a dummy .pd file containing: (simplify (plus @0 (plus @1 @2)) (negate (cond @0 @1 @2))) and the generated files differ by: - res = fold_build3_loc (loc, COND_EXPR, TREE_TYPE (ops1[0]), ops1[0], ops1[1], ops1[2]); + res = fold_build3_loc (loc, COND_EXPR, TREE_TYPE (ops1[1]), ops1[0], ops1[1], ops1[2]); (and something similar for gimple) I wondered about using something like VOID_TYPE_P (TREE_TYPE (ops1[1])) ? TREE_TYPE (ops1[2]) : TREE_TYPE (ops1[1]) but I don't think that will be necessary. Bootstrap is currently broken on many platforms with comparison failures, but since it went that far and generated the same *-match.c files, that seems sufficient testing. 2015-06-08 Marc Glisse marc.gli...@inria.fr * genmatch.c (expr::gen_transform): For conditions, guess the type from the second operand. -- Marc GlisseIndex: gcc/genmatch.c === --- gcc/genmatch.c (revision 224186) +++ gcc/genmatch.c (working copy) @@ -1702,20 +1702,27 @@ expr::gen_transform (FILE *f, const char type = optype; } else if (is_a operator_id * (operation) !strcmp (as_a operator_id * (operation)-tcc, tcc_comparison)) { /* comparisons use boolean_type_node (or what gets in), but their operands need to figure out the types themselves. */ sprintf (optype, boolean_type_node); type = optype; } + else if (*operation == COND_EXPR + || *operation == VEC_COND_EXPR) +{ + /* Conditions are of the same type as their first alternative. */ + sprintf (optype, TREE_TYPE (ops%d[1]), depth); + type = optype; +} else { /* Other operations are of the same type as their first operand. */ sprintf (optype, TREE_TYPE (ops%d[0]), depth); type = optype; } if (!type) fatal (two conversions in a row); fprintf (f, {\n);
[committed] Tighten some rtx-based variable and return types
These are the main rtx-related changes found by the -Wupcast-* warnings that I posted last week. Bootstrapped regression-tested on x86_64-linux-gnu. Also tested on config-list.mk, checking that all build failures were unrelated. Applied as obvious. Thanks, Richard gcc/ * emit-rtl.c, expr.c, gcse.c, optabs.c, optabs.h, print-rtl.c, rtl.h, bb-reorder.c, builtins.c, calls.c, cfgbuild.c, cfgexpand.c, cfgrtl.c, cilk-common.c, config/i386/i386.md, cse.c, dwarf2cfi.c, except.c, final.c, function.c, gcse-common.c, genemit.c, haifa-sched.c, ifcvt.c, jump.c, loop-invariant.c, loop-iv.c, lra-constraints.c, lra.c, reload1.c, resource.c, rtlanal.c, sched-deps.c, sched-ebb.c, sel-sched-ir.c, sel-sched.c, shrink-wrap.c, stmt.c, store-motion.c: Replace rtx base types with more derived ones. Index: gcc/emit-rtl.c === --- gcc/emit-rtl.c 2015-06-06 11:33:59.788667360 +0100 +++ gcc/emit-rtl.c 2015-06-06 11:33:59.756667734 +0100 @@ -3662,7 +3662,7 @@ try_split (rtx pat, rtx_insn *trial, int int probability; rtx_insn *insn_last, *insn; int njumps = 0; - rtx call_insn = NULL_RTX; + rtx_insn *call_insn = NULL; /* We're not good at redistributing frame information. */ if (RTX_FRAME_RELATED_P (trial)) @@ -4684,10 +4684,10 @@ emit_pattern_after_setloc (rtx pattern, rtx_insn *(*make_raw) (rtx)) { rtx_insn *after = safe_as_a rtx_insn * (uncast_after); - rtx last = emit_pattern_after_noloc (pattern, after, NULL, make_raw); + rtx_insn *last = emit_pattern_after_noloc (pattern, after, NULL, make_raw); if (pattern == NULL_RTX || !loc) -return safe_as_a rtx_insn * (last); +return last; after = NEXT_INSN (after); while (1) @@ -4700,7 +4700,7 @@ emit_pattern_after_setloc (rtx pattern, break; after = NEXT_INSN (after); } - return safe_as_a rtx_insn * (last); + return last; } /* Insert PATTERN after AFTER. MAKE_RAW indicates how to turn PATTERN Index: gcc/expr.c === --- gcc/expr.c 2015-06-06 11:33:59.788667360 +0100 +++ gcc/expr.c 2015-06-06 11:33:59.760667688 +0100 @@ -10559,7 +10559,7 @@ expand_expr_real_1 (tree exp, rtx target if ((icode = optab_handler (movmisalign_optab, mode)) != CODE_FOR_nothing) { - rtx reg, insn; + rtx reg; op0 = adjust_address (op0, mode, 0); /* We've already validated the memory, and we're creating a @@ -10568,7 +10568,7 @@ expand_expr_real_1 (tree exp, rtx target reg = gen_reg_rtx (mode); /* Nor can the insn generator. */ - insn = GEN_FCN (icode) (reg, op0); + rtx_insn *insn = GEN_FCN (icode) (reg, op0); emit_insn (insn); return reg; } Index: gcc/gcse.c === --- gcc/gcse.c 2015-06-06 11:33:59.788667360 +0100 +++ gcc/gcse.c 2015-06-06 11:33:59.760667688 +0100 @@ -540,7 +540,6 @@ static void trim_ld_motion_mems (void); static void update_ld_motion_stores (struct gcse_expr *); static void clear_modify_mem_tables (void); static void free_modify_mem_tables (void); -static rtx gcse_emit_move_after (rtx, rtx, rtx_insn *); static bool is_too_expensive (const char *); #define GNEW(T)((T *) gmalloc (sizeof (T))) @@ -2434,7 +2433,7 @@ single_set_gcse (rtx_insn *insn) /* Emit move from SRC to DEST noting the equivalence with expression computed in INSN. */ -static rtx +static rtx_insn * gcse_emit_move_after (rtx dest, rtx src, rtx_insn *insn) { rtx_insn *new_rtx; @@ -3960,7 +3959,6 @@ update_ld_motion_stores (struct gcse_exp rtx pat = PATTERN (insn); rtx src = SET_SRC (pat); rtx reg = expr-reaching_reg; - rtx copy; /* If we've already copied it, continue. */ if (expr-reaching_reg == src) @@ -3975,7 +3973,7 @@ update_ld_motion_stores (struct gcse_exp fprintf (dump_file, \n); } - copy = gen_move_insn (reg, copy_rtx (SET_SRC (pat))); + rtx_insn *copy = gen_move_insn (reg, copy_rtx (SET_SRC (pat))); emit_insn_before (copy, insn); SET_SRC (pat) = reg; df_insn_rescan (insn); Index: gcc/optabs.c === --- gcc/optabs.c2015-06-06 11:33:59.788667360 +0100 +++ gcc/optabs.c2015-06-06 11:33:59.764667641 +0100 @@ -2048,7 +2048,7 @@ expand_binop (machine_mode mode, optab b if (optab_handler (mov_optab, mode) != CODE_FOR_nothing || ! rtx_equal_p (target, xtarget)) { - rtx temp = emit_move_insn (target, xtarget); +
Re: [patch, fortran] PR 47359 - warnings for constant conversion
On Sat, Jun 06, 2015 at 12:22:56PM +0200, Thomas Koenig wrote: Any other comments? OK to commit? No. Yes. -- Steve
[C++/58583] ICE instantiating NSDMIs
This patch fixes 58582, a set of ICEs that happen instantiating NSDMIs. There are a couple of causes, both fixed. 1) instantiating the template while parsing an NSDMI of the template itself. We see a DEFAULT_ARG in get_nsdmi. Fixed by jumping to the existing error handling for the non-template case. 2) recursive instantiation of the NSDMI itself. As we instantiate lazily, we end up running out of stack. Fixed by creating a temporary DEFAULT_ARG and then detecting it on a subsequent recursion. I did contemplate having this direct to the same error as above, but decided against it, because this really is an instantiation problem not a parsing problem. built tested on x86_64-linux, ok? nathan 2015-06-05 Nathan Sidwell nat...@acm.org cp/ PR c++/58583 * init.c (get_nsdmi): Check for DEFAULT_ARG in template case and protect it from recursive instantiation. testsuite/ PR c++/58583 * g++.dg/cpp0x/nsdmi-template14.C: New test. Index: cp/init.c === --- cp/init.c (revision 224152) +++ cp/init.c (working copy) @@ -544,6 +544,7 @@ get_nsdmi (tree member, bool in_ctor) tree init; tree save_ccp = current_class_ptr; tree save_ccr = current_class_ref; + if (!in_ctor) { /* Use a PLACEHOLDER_EXPR when we don't have a 'this' parameter to @@ -551,22 +552,41 @@ get_nsdmi (tree member, bool in_ctor) current_class_ref = build0 (PLACEHOLDER_EXPR, DECL_CONTEXT (member)); current_class_ptr = build_address (current_class_ref); } + if (DECL_LANG_SPECIFIC (member) DECL_TEMPLATE_INFO (member)) { - /* Do deferred instantiation of the NSDMI. */ - init = (tsubst_copy_and_build - (DECL_INITIAL (DECL_TI_TEMPLATE (member)), - DECL_TI_ARGS (member), - tf_warning_or_error, member, /*function_p=*/false, - /*integral_constant_expression_p=*/false)); + init = DECL_INITIAL (DECL_TI_TEMPLATE (member)); + if (TREE_CODE (init) == DEFAULT_ARG) + goto unparsed; - init = digest_nsdmi_init (member, init); + /* Check recursive instantiation. */ + if (TREE_CODE (DECL_INITIAL (member)) == DEFAULT_ARG) + { + error (recursive instantiation of non-static data member + initializer for %qD, member); + init = error_mark_node; + } + else + { + DECL_INITIAL (member) = make_node (DEFAULT_ARG); + + /* Do deferred instantiation of the NSDMI. */ + init = (tsubst_copy_and_build + (init, DECL_TI_ARGS (member), + tf_warning_or_error, member, /*function_p=*/false, + /*integral_constant_expression_p=*/false)); + init = digest_nsdmi_init (member, init); + + if (TREE_CODE (DECL_INITIAL (member)) == DEFAULT_ARG) + DECL_INITIAL (member) = void_node; + } } else { init = DECL_INITIAL (member); if (init TREE_CODE (init) == DEFAULT_ARG) { + unparsed: error (constructor required before non-static data member for %qD has been parsed, member); DECL_INITIAL (member) = error_mark_node; Index: testsuite/g++.dg/cpp0x/nsdmi-template14.C === --- testsuite/g++.dg/cpp0x/nsdmi-template14.C (revision 0) +++ testsuite/g++.dg/cpp0x/nsdmi-template14.C (working copy) @@ -0,0 +1,23 @@ +// PR c++/58583 +// { dg-do compile { target c++11 } } + +templateint struct A // {dg-error non-static data member initializer } +{ + int i = (A0(), 0); // { dg-error non-static data member initializer required before parsing } { dg-error synthesized method } +}; + +templateint N struct B +{ + B* p = new BN; +}; + +B1 x; // { dg-error constructor required before non-static data member } + +struct C +{ + templateint N struct D + { +D* p = new D0; + }; +}; +
[v3 PATCH] Implement N4387 and LWG 2367
This patch implements the so-called conditionally-explicit constructors for tuple and pair, and also constrains the default constructors of tuple and pair. The patch does not try to implement the part in N4387 that allows constructing tuples from shorter packs than the tuple's element count, I suggest we look at that separately. The constraints involve fair amounts of evil black magic, but they do the job. Chances are they can be simplified, but I again suggest we look at that separately. Tested on Linux-PPC64. Patch gzipped since it's 50kB otherwise. :) 2015-06-07 Ville Voutilainen ville.voutilai...@gmail.com Implement N4387, improving pair and tuple and LWG 2367, pair and tuple are not correctly implemented for is_constructible with no args. * include/bits/stl_pair.h (_ConstructiblePair, _ImplicitlyConvertiblePair, _MoveConstructiblePair, _ImplicitlyMoveConvertiblePair): New. * include/bits/stl_pair.h (pair()): Constrain it. * include/bits/stl_pair.h (pair(const _T1, const _T2), pair(const pair_U1, _U2), pair(_U1, const _T2), pair(const _T1, _U2), pair(_U1, _U2), pair(pair_U1, _U2)): Make conditionally explicit. * include/std/tuple (_TC, _TC2): New. * include/std/tuple (tuple()): Constrain it. * include/std/tuple (tuple(const _UElements...), tuple(_UElements...), tuple(const tuple_UElements...), tuple(tuple_UElements...), tuple(allocator_arg_t, const _Alloc, const _UElements...), tuple(allocator_arg_t, const _Alloc, _UElements...), tuple(allocator_arg_t, const _Alloc, const tuple_UElements...), tuple(allocator_arg_t, const _Alloc, tuple_UElements...), tuple(const pair_U1, _U2), tuple(pair_U1, _U2), tuple(allocator_arg_t, const _Alloc, const pair_U1, _U2), tuple(allocator_arg_t, const _Alloc, pair_U1, _U2)): Make conditionally explicit. * testsuite/20_util/pair/cons/explicit_construct.cc: New. * testsuite/20_util/pair/requirements/dr2367.cc: New. * testsuite/20_util/tuple/cons/explicit_construct.cc: New. * testsuite/20_util/tuple/requirements/dr2367.cc: New. explicit-tuple-pair.diff.gz Description: GNU Zip compressed data
[committed] Update HP-UX builtin predefines
The trunk was changed recently for a period to build with gcc -std=c++98. This caused a build failure on HP-UX because a non standard HP variant of the nftw function was selected. The attached change revises the hpux predefines so this won't happen. In particular, we now define _XOPEN_SOURCE_EXTENDED when building with c++. I also reviewed the existing predefines and added some new ones for c++ and hpux11.31. Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11. Committed to trunk and gcc-5 branch. Dave -- John David Anglin dave.ang...@bell.net 2015-06-06 John David Anglin dang...@gcc.gnu.org PR bootstrap/66319 * config/pa/pa-hpux10.h (TARGET_OS_CPP_BUILTINS): Rearrange builtin defines. Define _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE for c++. Define _XOPEN_UNIX and _XOPEN_SOURCE_EXTENDED for c++ if unix95 or later. * config/pa/pa-hpux11.h (TARGET_OS_CPP_BUILTINS): Likewise. Define _INCLUDE_STDC_SOURCE_PRE_199901, _INCLUDE_STDC_SOURCE_199901, _INCLUDE_XOPEN_SOURCE_PRE_500, _INCLUDE_XOPEN_SOURCE_520, _INCLUDE_XOPEN_SOURCE_PRE_600 and _INCLUDE_XOPEN_SOURCE_600 for c++ and non iso if unix2003. Index: config/pa/pa-hpux10.h === --- config/pa/pa-hpux10.h (revision 224079) +++ config/pa/pa-hpux10.h (working copy) @@ -24,7 +24,9 @@ the definition of __cplusplus. We define _INCLUDE_LONGLONG to prevent nlist.h from defining __STDC_32_MODE__ (no longlong support). We define __STDCPP__ to get certain system headers - (notably assert.h) to assume standard preprocessor behavior in C++. */ + (notably assert.h) to assume standard preprocessor behavior in C++. + We define _XOPEN_SOURCE_EXTENDED when we define _HPUX_SOURCE to avoid + non standard hpux variants in _INCLUDE_XOPEN_SOURCE_EXTENDED. */ #undef TARGET_OS_CPP_BUILTINS #define TARGET_OS_CPP_BUILTINS() \ do \ @@ -44,9 +46,21 @@ builtin_define (_REENTRANT); \ builtin_define (_INCLUDE_LONGLONG); \ builtin_define (__STDCPP__); \ + builtin_define (_LARGEFILE_SOURCE); \ + builtin_define (_LARGEFILE64_SOURCE); \ + if (flag_pa_unix = 1995) \ + { \ + builtin_define (_XOPEN_UNIX); \ + builtin_define (_XOPEN_SOURCE_EXTENDED); \ + } \ } \ - else if (!flag_iso) \ + else if (flag_iso) \ { \ + if (flag_isoc94)\ + builtin_define (_INCLUDE__STDC_A1_SOURCE); \ + } \ + else\ + { \ builtin_define (_HPUX_SOURCE);\ builtin_define (_REENTRANT); \ if (preprocessing_trad_p ())\ @@ -59,12 +73,12 @@ builtin_define (_PWB);\ builtin_define (PWB); \ } \ + if (flag_pa_unix = 1995) \ + { \ + builtin_define (_XOPEN_UNIX); \ + builtin_define (_XOPEN_SOURCE_EXTENDED); \ + } \ } \ - if (flag_pa_unix = 1995) \ - { \ - builtin_define (_XOPEN_UNIX); \ - builtin_define (_XOPEN_SOURCE_EXTENDED); \ - } \ if (TARGET_SIO) \ builtin_define (_SIO); \ else\ Index: