Committed: Fix PR53156, testsuite regression from recent reload change
The regression was mostly due to a failed assumption by the test-case (a minimal solution must match the assembly code patterns), but also due to a different suboptimal sequence after the reload change. The committed patch below fixes the regresssed code, the test-case, and tweaks the comment to match the current state of both the peephole2 use and gcc version. Tested cross to cris-elf. Also tested that the updated test-case matches the 4.7 output, in case the reload change is reverted. :) (I have no particular reason to believe that'd happen, though.) gcc/testsuite: PR target/53156 * gcc.target/cris/peep2-andu2.c: Tweak expected assembly code to match current output and cover new peephole2 pattern. gcc: PR target/53156 * config/cris/cris.md (andqu): New peephole2. (andu): Tweak head comment. Index: gcc/testsuite/gcc.target/cris/peep2-andu2.c === --- gcc/testsuite/gcc.target/cris/peep2-andu2.c (revision 186934) +++ gcc/testsuite/gcc.target/cris/peep2-andu2.c (working copy) @@ -1,13 +1,20 @@ /* { dg-do assemble } */ -/* { dg-final { scan-assembler "movu.w \\\$r10,\\\$" } } */ -/* { dg-final { scan-assembler "and.w 2047,\\\$" } } */ +/* { dg-final { scan-assembler "movu.w \\\$r10,\\\$|movu.w 2047," } } */ +/* { dg-final { scan-assembler "and.w 2047,\\\$|and.d \\\$r10," } } */ /* { dg-final { scan-assembler-not "move.d \\\$r10,\\\$" } } */ -/* { dg-final { scan-assembler "movu.b \\\$r10,\\\$" } } */ -/* { dg-final { scan-assembler "and.b 95,\\\$" } } */ +/* { dg-final { scan-assembler "movu.b \\\$r10,\\\$|movu.b 95," } } */ +/* { dg-final { scan-assembler "and.b 95,\\\$|and.d \\\$r10," } } */ /* { dg-final { scan-assembler "andq -2,\\\$" } } */ +/* { dg-final { scan-assembler-not "movu.b 254,\\\$" } } */ /* { dg-options "-O2 -save-temps" } */ -/* Test the "andu" peephole2 trivially, register operand. */ +/* Originally used to test the "andu" peephole2 trivially, register operand. + Due to reload changes (r186861), the suboptimal sequence isn't + generated and the peephole2 doesn't trig for this trivial code + anymore. Another minimal sequence is generated, where the constant + is loaded to a free register first. Instead another case is exposed; + handled by the "andqu" peephole2, trigged by and_peep2_q (the andq + and scan-assembler-not-movu.b lines above). */ unsigned int and_peep2_hi (unsigned int y, unsigned int *x) Index: gcc/config/cris/cris.md === --- gcc/config/cris/cris.md (revision 186934) +++ gcc/config/cris/cris.md (working copy) @@ -4936,17 +4936,17 @@ (define_peephole2 ; op3 (peephole casesi "operands[7] = rtx_equal_p (operands[3], operands[0]) ? operands[4] : operands[3];") -;; I cannot tell GCC (2.1, 2.7.2) how to correctly reload an instruction -;; that looks like -;; and.b some_byte,const,reg_32 -;; where reg_32 is the destination of the "three-address" code optimally. +;; There seems to be no other way to make GCC (including 4.8/trunk at +;; r186932) optimally reload an instruction that looks like +;; and.d reg_or_mem,const_32__65535,other_reg +;; where other_reg is the destination. ;; It should be: -;; movu.b some_byte,reg_32 -;; and.b const,reg_32 +;; movu.[bw] reg_or_mem,reg_32 +;; and.[bw] trunc_int_for_mode([bw], const_32__65535),reg_32 ;; or andq ;; but it turns into: -;; move.b some_byte,reg_32 -;; and.d const,reg_32 -;; Fix it here. +;; move.d reg_or_mem,reg_32 +;; and.d const_32__65535,reg_32 +;; Fix it with these two peephole2's. ;; Testcases: gcc.dg/cris-peep2-andu1.c gcc.dg/cris-peep2-andu2.c (define_peephole2 ; andu (casesi+45) @@ -4982,6 +4982,36 @@ (define_peephole2 ; andu (casesi+45) GEN_INT (trunc_int_for_mode (INTVAL (operands[3]), amode == SImode ? QImode : amode))); +}) + +;; Since r186861, gcc.dg/cris-peep2-andu2.c trigs this pattern, with which +;; we fix up e.g.: +;; movu.b 254,$r9. +;; and.d $r10,$r9 +;; into: +;; movu.b $r10,$r9 +;; andq -2,$r9. +;; Only do this for values fitting the quick immediate operand. +(define_peephole2 ; andqu (casesi+46) + [(set (match_operand:SI 0 "register_operand") + (match_operand:SI 1 "const_int_operand")) + (set (match_dup 0) + (and:SI (match_dup 0) (match_operand:SI 2 "nonimmediate_operand")))] + ;; Since the size of the memory access will be made different here, + ;; don't do this for a volatile access or a post-incremented address. + "satisfies_constraint_O (operands[1]) + && !side_effects_p (operands[2]) + && !reg_overlap_mentioned_p (operands[0], operands[2])" + [(set (match_dup 0) (match_dup 3)) + (set (match_dup 0) (and:SI (match_dup 0) (match_dup 4)))] +{ + enum machine_mode zmode = INTVAL (operands[2]) <= 255 ? QImode : HImode; + r
[patch, fortran, committed] Fix PR 53148
Hello world, I have committed the attached patch as obvious as rev. 186942 after regression-testing. Will also commit to 4.7 in a few days. Thomas 2012-04-29 Thomas Koenig PR fortran/53148 * frontend-passes.c (create_var): If the statement has a label, put the label around the block. 2012-04-29 Thomas Koenig PR fortran/53148 * gfortran.dg/function_optimize_12.f90: New test. ! { dg-do run } ! { dg-options "-ffrontend-optimize" } ! PR 53148 - this used to cause wrong code because the label was ! placed after the statement assigning the new variables. program main integer :: n double precision x n = 3 goto 100 100 x = dble(n) + dble(n) if (x /= 6.d0) call abort end program main Index: frontend-passes.c === --- frontend-passes.c (Revision 186549) +++ frontend-passes.c (Arbeitskopie) @@ -271,6 +271,16 @@ create_var (gfc_expr * e) inserted_block->ext.block.assoc = NULL; ns->code = *current_code; + + /* If the statement has a label, make sure it is transferred to + the newly created block. */ + + if ((*current_code)->here) + { + inserted_block->here = (*current_code)->here; + (*current_code)->here = NULL; + } + inserted_block->next = (*current_code)->next; changed_statement = &(inserted_block->ext.block.ns->code); (*current_code)->next = NULL;
[committed] Make Wmissing-noreturn an alias of -Wsuggest-attribute=noreturn.
Bootstrapped and regression tested. Committed as obvious at revision 186943. Index: gcc/ChangeLog === --- gcc/ChangeLog (revision 186942) +++ gcc/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2012-04-29 Manuel López-Ibáñez + +* opts.c (finish_options): Do not handle -Wmissing-noreturn here. +* common.opt (Wmissing-noreturn): Alias of -Wsuggest-attribute=noreturn. + 2012-04-29 Hans-Peter Nilsson PR target/53156 Index: gcc/opts.c === --- gcc/opts.c (revision 186942) +++ gcc/opts.c (working copy) @@ -667,10 +667,6 @@ if (opts->x_flag_tm && opts->x_flag_non_call_exceptions) sorry ("transactional memory is not supported with non-call exceptions"); - /* -Wmissing-noreturn is alias for -Wsuggest-attribute=noreturn. */ - if (opts->x_warn_missing_noreturn) -opts->x_warn_suggest_attribute_noreturn = true; - /* Unless the user has asked for section anchors, we disable toplevel reordering at -O0 to disable transformations that might be surprising to end users and to get -fno-toplevel-reorder tested. */ Index: gcc/common.opt === --- gcc/common.opt (revision 186942) +++ gcc/common.opt (working copy) @@ -567,8 +567,7 @@ Warn if the loop cannot be optimized due to nontrivial assumptions. Wmissing-noreturn -Common Var(warn_missing_noreturn) Warning -Warn about functions which might be candidates for __attribute__((noreturn)) +Common Alias(Wsuggest-attribute=noreturn) Woverflow Common Var(warn_overflow) Init(1) Warning
[c/c++] Alias Wmissing-format-attribute to Wsuggest-attribute=format
Since Wsuggest-attribute=[pure|const|noreturn] was introduced, it makes sense to have Wsuggest-attribute=format. This patch makes this the canonical form of Wmissing-format-attribute (the old form is still accepted and documented). Bootstrapped and regression tested. OK? 2012-04-29 Manuel López-Ibáñez gcc/ * doc/invoke.texi (Wmissing-format-attribute): Document as an alias of Wsuggest-attribute=format. c-family/ * c.opt (Wsuggest-attribute=format): New. Alias of Wmissing-format-attribute. * c-format.c (decode_format_type): Replace Wmissing-format-attribute with Wsuggest-attribute=format. (check_function_format): Likewise. cp/ * typeck.c (convert_for_assignment): Replace Wmissing-format-attribute with Wsuggest-attribute=format. * call.c (convert_for_arg_passing): Likewise. gcc/ * c-typeck.c (convert_for_assignment): Replace Wmissing-format-attribute with Wsuggest-attribute=format. (digest_init): Likewise. Wsuggest-attribute.diff Description: Binary data
[committed] adjust testcase gcc.dg/20011021-1.c
An oversight from a previous commit. Committed as obvious after testing. Cheers, Manuel. Index: gcc/testsuite/gcc.dg/20011021-1.c === --- gcc/testsuite/gcc.dg/20011021-1.c (revision 186942) +++ gcc/testsuite/gcc.dg/20011021-1.c (working copy) @@ -8,7 +8,7 @@ struct t { int a; - int b; + int b; /* { dg-message "note: 'b' declared here" } */ int c; }; @@ -28,7 +28,7 @@ }; struct t T0 = { 1 }; /* { dg-warning "missing init" } */ -/* { dg-warning "near init" "near init" { target *-*-* } 30 } */ + struct t T1 = { .a = 1 }; /* { dg-bogus "(missing|near) init" } */ union u U0 = { 1 };/* { dg-warning "initialization of union" } */ Index: gcc/testsuite/ChangeLog === --- gcc/testsuite/ChangeLog (revision 186942) +++ gcc/testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2012-04-29 Manuel López-Ibáñez + + PR 53149 +* gcc.dg/20011021-1.c: Adjust testcase. + 2012-04-29 Thomas Koenig PR fortran/53148
Re: [libcpp] maybe canonicalize system paths in line-map
New version of the patch. Bootstrapped and regression tested. Is this version OK? 2012-04-29 Manuel López-Ibáñez Dodji Seketeli PR 5297 * libcpp/files.c (maybe_shorter_path): New. (find_file_in_dir): Use it. pr52974.diff Description: Binary data
Re: [RFC] improve caret diagnostics for overload failures
A new version using unsigned int for the flag type. It also adds another use in the C FE. I am not asking for approval, only whether this approach/implementation is the way to go. Cheers, Manuel. On 23 April 2012 20:09, Manuel López-Ibáñez wrote: > So, apart from the type of the flag, are there any other comments on > the patch? Is the approach acceptable? > > On 21 April 2012 17:51, Gabriel Dos Reis > wrote: >> On Sat, Apr 21, 2012 at 9:42 AM, Jakub Jelinek wrote: >>> On Sat, Apr 21, 2012 at 04:26:32PM +0200, Manuel López-Ibáñez wrote: On 21 April 2012 16:22, Gabriel Dos Reis wrote: > Do no use 'char' as the type of a flag. Prefer 'unsigned int'. > Thanks, good catch! Should I worry about memory here and use something shorter? >>> >>> If it is a bool flag, you certainly should use bool type, which is shorter. >> >> It is a bit flag -- see the patch in his original message and 'enum >> diagnostic_info_flags'. caret-overload.diff Description: Binary data
Re: [v3] is_modulo
On Sat, Apr 28, 2012 at 6:45 PM, Marc Glisse wrote: > On Sat, 28 Apr 2012, Gabriel Dos Reis wrote: > >> On Sat, Apr 28, 2012 at 5:41 PM, Marc Glisse wrote: >>> >>> Hello, >>> >>> the attached follows the precisions on the definition of is_modulo in DR >>> 612. I believe this is what the values always should have been, so I >>> didn't >>> make the change conditional to C++11. >> >> >> Thanks for the patch. >> I think 'char' shouldn't be considered modulo even if >> -funsigned-char -- I will bring this to LWG attention. > > > Why not? If an implementation decides to guarantee that the arithmetic on a > type is modular, it should advertise it through this trait, I don't see > anything wrong about that. Well, doing arithmetic on char may not be the > best idea, but still... (1) char really is a character type, it is an 'accident' that it is classified as arithmetic type. (2) there is no arithmetic operation on char: the arithmetic is done on a different type and the result clamped back to char. > Actually, if you are going to bring this up in LWG, > let's not discuss that here. Exactly. > >> OK. > > > Note that I can't commit, you'll have to do it, sorry... > > -- > Marc Glisse
Re: [c/c++] Alias Wmissing-format-attribute to Wsuggest-attribute=format
On Sun, Apr 29, 2012 at 4:28 AM, Manuel López-Ibáñez wrote: > Since Wsuggest-attribute=[pure|const|noreturn] was introduced, it > makes sense to have Wsuggest-attribute=format. This patch makes this > the canonical form of Wmissing-format-attribute (the old form is still > accepted and documented). > > Bootstrapped and regression tested. > > OK? OK.
Re: [RFH / Patch] PR 51222
Hi, On 04/29/2012 05:17 AM, Jason Merrill wrote: On 04/28/2012 07:12 AM, Paolo Carlini wrote: isn't, but clearly can be instantiation dependent. Then, I guess the way I'm proposing to handle this is by starting some sort of embryonic instantiation_dependent_expression_p and using it only here, for now, like the attached (which passes on x86_64-linux). What do you think? I think that implementing it properly shouldn't be that much harder; the definition from the ABI is An expression is instantiation-dependent if it is type-dependent or value-dependent, or it has a subexpression that is type-dependent or value-dependent. Ok, yesterday didn't read it, sorry. This might just be a matter of calling for_each_template_parm and returning 1 if we see any template parameter. Good. Today I quickly tried something along these lines (see 'p' attachment) and got some fails: FAIL: g++.dg/abi/mangle45.C scan-assembler _Z1fIiEvT_DtfL0p_E FAIL: g++.dg/abi/mangle45.C scan-assembler _Z1gIiEvT_PFDtfL0p_EvE FAIL: g++.dg/abi/mangle49.C scan-assembler _Z2f1I1SENDtfp_E4typeET_ FAIL: g++.dg/cpp0x/decltype21.C (test for excess errors) FAIL: g++.dg/cpp0x/sfinae12.C (test for excess errors) FAIL: g++.dg/cpp0x/sfinae17.C (test for excess errors) FAIL: g++.dg/cpp0x/sfinae21.C (test for excess errors) FAIL: g++.dg/cpp0x/sfinae28.C (test for excess errors) FAIL: g++.dg/cpp0x/trailing1.C scan-assembler _Z1lIiEDtfp_ET_ FAIL: g++.dg/cpp0x/variadic121.C (test for excess errors) I don't know if you believe it could be easily amended (*)... Otherwise, I'm attaching something very close to the letter of the ABI, which passes as-is the testsuite. If you like, I could also exercise more this version of instantiation_dependent_expression_p by changing static_assert too to also use it. Thanks, Paolo. (*) In case somebody is curious, include_nondeduced_p doesn't change anything. / Index: testsuite/g++.dg/cpp0x/decltype37.C === --- testsuite/g++.dg/cpp0x/decltype37.C (revision 0) +++ testsuite/g++.dg/cpp0x/decltype37.C (revision 0) @@ -0,0 +1,101 @@ +// PR c++/51222 +// { dg-options -std=c++11 } + +template +struct add_rref { + typedef T&& type; +}; + +template<> +struct add_rref { + typedef void type; +}; + +template +typename add_rref::type declval(); + +template())) +> +auto f(int) -> char; + +template +auto f(...) -> char(&)[2]; + +template +auto g(int) -> char; + +template +auto g(...) -> char(&)[2]; + +template +auto f2(int) -> decltype(::delete ::new T(declval()), char()); + +template +auto f2(...) -> char(&)[2]; + +template +auto g2(int) -> decltype(::delete ::new T(), char()); + +template +auto g2(...) -> char(&)[2]; + +struct C { }; + +struct A { + virtual ~A() = 0; +}; + +struct D1 { + D1() = delete; +}; + +struct D2 { + ~D2() = delete; +}; + +static_assert(sizeof(g(0)) == 2, "Ouch"); +static_assert(sizeof(g(0)) == 2, "Ouch"); +static_assert(sizeof(g(0)) == 2, "Ouch"); +static_assert(sizeof(g(0)) == 2, "Ouch"); +static_assert(sizeof(g(0)) == 2, "Ouch"); +static_assert(sizeof(g(0)) == 2, "Ouch"); +static_assert(sizeof(g(0)) == 2, "Ouch"); +static_assert(sizeof(g(0)) == 2, "Ouch"); +static_assert(sizeof(g(0)) == 2, "Ouch"); +static_assert(sizeof(g(0)) == 2, "Ouch"); +static_assert(sizeof(f(0)) == 2, "Ouch"); +static_assert(sizeof(f(0)) == 2, "Ouch"); +static_assert(sizeof(f(0)) == 2, "Ouch"); +static_assert(sizeof(f(0)) == 2, "Ouch"); +static_assert(sizeof(f(0)) == 2, "Ouch"); +static_assert(sizeof(f(0)) == 2, "Ouch"); +static_assert(sizeof(f(0)) == 2, "Ouch"); +static_assert(sizeof(f(0)) == 2, "Ouch"); +static_assert(sizeof(f(0)) == 2, "Ouch"); +static_assert(sizeof(f(0)) == 2, "Ouch"); +static_assert(sizeof(f(0)) == 2, "Ouch"); + +static_assert(sizeof(g2(0)) == 2, "Ouch"); +static_assert(sizeof(g2(0)) == 2, "Ouch"); +static_assert(sizeof(g2(0)) == 2, "Ouch"); +static_assert(sizeof(g2(0)) == 2, "Ouch"); +static_assert(sizeof(g2(0)) == 2, "Ouch"); +static_assert(sizeof(g2(0)) == 2, "Ouch"); +static_assert(sizeof(g2(0)) == 2, "Ouch"); +static_assert(sizeof(g2(0)) == 2, "Ouch"); +static_assert(sizeof(g2(0)) == 2, "Ouch"); +static_assert(sizeof(g2(0)) == 2, "Ouch"); +static_assert(sizeof(f2(0)) == 2, "Ouch"); +static_assert(sizeof(f2(0)) == 2, "Ouch"); +static_assert(sizeof(f2(0)) == 2, "Ouch"); +static_assert(sizeof(f2(0)) == 2, "Ouch"); +static_assert(sizeof(f2(0)) == 2, "Ouch"); +static_assert(sizeof(f2(0)) == 2, "Ouch"); +static_assert(sizeof(f2(0)) == 2, "Ouch"); +static_assert(sizeof(f2(0)) == 2, "Ouch"); +static_assert(sizeof(f2(0)) == 2, "Ouch"); +static_assert(sizeof(f2(0)) == 2, "Ouch"); +static_assert(sizeof(f2(0)) == 2, "Ouch"); Index: cp/pt.c === --- cp/pt.c (revision 186943) +++ cp/pt.c (working copy) @@ -19742,6 +19742,36 @@ type_dependent_expression_p (tree expression) return (dependent_type_p (TREE_TYPE (expression))); } +/* Returns
[PATCH, libcpp] Don't use C++ style comments in libcpp
Hello, I noticed that the file lex.c had C++ style comments, which I believe is against the coding standards of the project. Fixed, tested and applied to the mainline as per the obvious rule. libcpp/ * lex.c (lex_raw_string): Change C++ style comments into C style comments. (lex_string): Likewise. diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index f7c330c..4b66c84 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,9 @@ +2012-04-29 Dodji Seketeli + + * lex.c (lex_raw_string): Change C++ style comments into C style + comments. + (lex_string): Likewise. + 2012-04-27 Ollie Wild * include/cpplib.h (struct cpp_options): Add new field, diff --git a/libcpp/lex.c b/libcpp/lex.c index 7e2671e..c4dd603 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -1561,7 +1561,7 @@ lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base, extension by other front ends such as clang. */ if (ISALPHA (*cur)) { - // Raise a warning, but do not consume subsequent tokens. + /* Raise a warning, but do not consume subsequent tokens. */ if (CPP_OPTION (pfile, warn_literal_suffix)) cpp_warning_with_line (pfile, CPP_W_LITERAL_SUFFIX, token->src_loc, 0, @@ -1692,7 +1692,7 @@ lex_string (cpp_reader *pfile, cpp_token *token, const uchar *base) extension by other front ends such as clang. */ if (ISALPHA (*cur)) { - // Raise a warning, but do not consume subsequent tokens. + /* Raise a warning, but do not consume subsequent tokens. */ if (CPP_OPTION (pfile, warn_literal_suffix)) cpp_warning_with_line (pfile, CPP_W_LITERAL_SUFFIX, token->src_loc, 0, -- Dodji
Re: [patch] Fix cygwin ada install [was Re: Yet another issue with gcc current trunk with ada on cygwin]
Arno, > Pascal, I'd suggest you go ahead and revert this patch. This patch has already been reverted by Eric on Apr 10 on gcc-4.7 branch. -- Pascal Obry -- gpg --keyserver keys.gnupg.net --recv-key F949BD3B
Re: [PATCH 04/11] Fix expansion point loc for macro-like tokens
Jason Merrill writes: > On 04/25/2012 05:07 AM, Dodji Seketeli wrote: >> + /* If the first token we got was a padding token, let's put >> + it back into the stream so that cpp_get_token will get it >> + first; and if we are currently expanding a macro, don't >> + forget that information. */ >> + cpp_hashnode *macro = >> +(pfile->context->tokens_kind == TOKENS_KIND_EXTENDED) >> +? pfile->context->c.mc->macro_node >> +: pfile->context->c.macro; >> + _cpp_push_token_context (pfile, macro, padding, 1); > > What about the other places that call _cpp_push_token_context with a > NULL macro argument? Don't we want to continue the current macro > context in that case, too? Perhaps we should move this new code > inside _cpp_push_token_context for the case when the macro parameter > is NULL. Right. I did that. But then, now that there can be some contiguous contexts representing the same macro, I had to adjust how _cpp_pop_context was re-enabling the 'expandability' of a given macro M. For the background, When M is being expanded, it's flagged by enter_macro_context as being non-expandable, to prevent its possible recursive expansions. And it's flagged back to being expandable when we get out of its expansion context. Now, getting out of the expansion context means to test that have actually popped all the possibly contiguous contexts that are related to M. Otherwise, we get into situations of recursive expansion of M. Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk. libcpp/ * macro.c (macro_of_context): New static function. (_cpp_push_token_context, push_extended_tokens_context): If the macro argument is NULL, it means we are continuing the expansion of the current macro, if any. Update comments. (_cpp_pop_context): Re-enable expansion of the macro only when we are really out of the context of the current expansion. gcc/testsuite/ * gcc.dg/debug/dwarf2/pr41445-5.c: Adjust. * gcc.dg/debug/dwarf2/pr41445-6.c: Likewise. --- gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c |5 ++- gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c |5 ++- libcpp/macro.c| 56 + 3 files changed, 56 insertions(+), 10 deletions(-) diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c index 03af604..d21acd5 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-5.c @@ -9,6 +9,9 @@ #define B , varj int A(B) ; -/* { dg-final { scan-assembler "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"vari\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^0-9a-fA-FxX](0x)?7\[^0-9a-fA-FxX]\[^\\r\\n\]*DW_AT_decl_line" } } */ +/* We want to check that both vari and varj have the same line +number. */ + +/* { dg-final { scan-assembler "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"vari\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^0-9a-fA-FxX](0xa|10)\[^0-9a-fA-FxX]\[^\\r\\n\]*DW_AT_decl_line" } } */ /* { dg-final { scan-assembler "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"varj\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^0-9a-fA-FxX](0xa|10)\[^0-9a-fA-FxX]\[^\\r\\n\]*DW_AT_decl_line" } } */ /* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c index 8aa37d1..d6d79cc 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-6.c @@ -4,5 +4,8 @@ #include "pr41445-5.c" -/* { dg-final { scan-assembler "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"vari\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^0-9a-fA-FxX](0x)?7\[^0-9a-fA-FxX]\[^\\r\\n\]*DW_AT_decl_line" } } */ +/* We want to check that both vari and varj have the same line +number. */ + +/* { dg-final { scan-assembler "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"vari\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^0-9a-fA-FxX](0xa|10)?\[^0-9a-fA-FxX]\[^\\r\\n\]*DW_AT_decl_line" } } */ /* { dg-final { scan-assembler "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"varj\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^0-9a-fA-FxX](0xa|10)\[^0-9a-fA-FxX]\[^\\r\\n\]*DW_AT_decl_line" } } */ diff --git a/libcpp/macro.c b/libcpp/macro.c index f4638c4..ab3e8f6 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -165,6 +165,8 @@ static void consume_next_token_from_context (cpp_reader *pfile, source_location
Re: [PATCH 05/11] Make expand_location resolve to locus in main source file
Jason Merrill writes: > On 04/25/2012 11:31 AM, Dodji Seketeli wrote: >> +#define EXPANSION_POINT_LOCATION_FILE(LOC) \ >> + ((expand_location_to_expansion_point (LOC)).file) >> +#define EXPANSION_POINT_LOCATION_LINE(LOC) \ >> + ((expand_location_to_expansion_point (LOC)).line) >> +#define EXPANSION_POINT_LOCATION_COLUMN(LOC)\ >> + ((expand_location_to_expansion_point (LOC)).column) > > These macros don't seem to be used anywhere. The rest of the patch is > OK. Thanks. Here is the updated patch that I will commit with the rest when all the patches are ACKed. gcc/ * input.c (expand_location_1): New. Takes a parameter to choose whether to resolve the location to spelling or expansion point. Was factorized from ... (expand_location): ... here. (expand_location_to_spelling_point): New. Implemented in terms of expand_location_1. * diagnostic.c (diagnostic_build_prefix): Use the new expand_location_to_spelling_point instead of expand_location. --- gcc/diagnostic.c |4 ++-- gcc/input.c | 40 +++- gcc/input.h |1 + 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 4496803..729e865 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -214,7 +214,7 @@ diagnostic_build_prefix (diagnostic_context *context, "must-not-happen" }; const char *text = _(diagnostic_kind_text[diagnostic->kind]); - expanded_location s = expand_location (diagnostic->location); + expanded_location s = expand_location_to_spelling_point (diagnostic->location); if (diagnostic->override_column) s.column = diagnostic->override_column; gcc_assert (diagnostic->kind < DK_LAST_DIAGNOSTIC_KIND); @@ -266,7 +266,7 @@ diagnostic_show_locus (diagnostic_context * context, || diagnostic->location <= BUILTINS_LOCATION) return; - s = expand_location(diagnostic->location); + s = expand_location_to_spelling_point (diagnostic->location); line = location_get_source_line (s); if (line == NULL) return; diff --git a/gcc/input.c b/gcc/input.c index bf5fe48..e9ba301 100644 --- a/gcc/input.c +++ b/gcc/input.c @@ -32,16 +32,22 @@ struct line_maps *line_table; /* Expand the source location LOC into a human readable location. If LOC resolves to a builtin location, the file name of the readable - location is set to the string "". */ - -expanded_location -expand_location (source_location loc) + location is set to the string "". If EXPANSION_POINT_P is + TRUE and LOC is virtual, then it is resolved to the expansion + point of the involved macro. Otherwise, it is resolved to the + spelling location of the token. */ + +static expanded_location +expand_location_1 (source_location loc, + bool expansion_point_p) { expanded_location xloc; const struct line_map *map; loc = linemap_resolve_location (line_table, loc, - LRK_SPELLING_LOCATION, &map); + expansion_point_p + ? LRK_MACRO_EXPANSION_POINT + : LRK_SPELLING_LOCATION, &map); xloc = linemap_expand_location (line_table, map, loc); if (loc <= BUILTINS_LOCATION) @@ -109,6 +115,30 @@ location_get_source_line(expanded_location xloc) return buffer; } +/* Expand the source location LOC into a human readable location. If + LOC is virtual, it resolves to the expansion point of the involved + macro. If LOC resolves to a builtin location, the file name of the + readable location is set to the string "". */ + +expanded_location +expand_location (source_location loc) +{ + return expand_location_1 (loc, /*expansion_point_p=*/true); +} + +/* Expand the source location LOC into a human readable location. If + LOC is virtual, it resolves to the expansion location of the + relevant macro. If LOC resolves to a builtin location, the file + name of the readable location is set to the string + "". */ + +expanded_location +expand_location_to_spelling_point (source_location loc) +{ + return expand_location_1 (loc, /*expansion_piont_p=*/false); +} + + #define ONE_K 1024 #define ONE_M (ONE_K * ONE_K) diff --git a/gcc/input.h b/gcc/input.h index 4b15222..ea19e07 100644 --- a/gcc/input.h +++ b/gcc/input.h @@ -39,6 +39,7 @@ extern char builtins_location_check[(BUILTINS_LOCATION extern expanded_location expand_location (source_location); extern const char * location_get_source_line(expanded_location xloc); +extern expanded_location expand_location_to_spelling_point (source_location); /* Historically GCC used location_t, while cpp used source_location. This could be removed but it hardly seems worth the effort. */ -- Dodji
Re: [RFH / Patch] PR 51222
On 04/29/2012 05:42 PM, Paolo Carlini wrote: Otherwise, I'm attaching something very close to the letter of the ABI, which passes as-is the testsuite. Which in any case should use cp_tree_operand_length. Paolo.
Re: [libcpp] maybe canonicalize system paths in line-map
Manuel López-Ibáñez a écrit: > PR 5297 > * libcpp/files.c (maybe_shorter_path): New. > (find_file_in_dir): Use it. I can't approve or deny this patch, but for what it's worth, I find it fine. Thanks. -- Dodji
PATCH: Add x32 support to boehm-gc
Hi, This patch adds x32 support to boehm-gc. The same patch has been sent to the boehm-gc mailing list. Tested on Linux/x32 and Linux/x86-64. OK for trunk? Thanks. H.J. - Forwarded message from "H.J. Lu" - Date: Mon, 16 Apr 2012 09:39:20 -0700 From: "H.J. Lu" To: "H.J. Lu" Cc: hans_bo...@hp.com, g...@linux.hpl.hp.com Subject: [bdwgc] PATCH: Add x32 support User-Agent: Mutt/1.5.21 (2010-09-15) Hi, Here are 2 small patches to add x32 support to bdwgc. X32 info can be found at https://sites.google.com/site/x32abi/ They are fully tested on Linux/x32 and Linux/x86-64. Thanks. H.J. --- >From 16ea9de35f16f0859c40862f8ef310c0dde6082c Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 16 Apr 2012 09:26:07 -0700 Subject: [PATCH 1/2] Define ALIGNMENT and CPP_WORDSZ for x32 * include/private/gcconfig.h: (ALIGNMENT): Set to 4 for x32. (CPP_WORDSZ): Set to 32 for x32. diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index a163e47..918d100 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -2117,8 +2117,13 @@ # ifdef X86_64 # define MACH_TYPE "X86_64" -# define ALIGNMENT 8 -# define CPP_WORDSZ 64 +# ifdef __ILP32__ +# define ALIGNMENT 4 +# define CPP_WORDSZ 32 +# else +# define ALIGNMENT 8 +# define CPP_WORDSZ 64 +# endif # ifndef HBLKSIZE # define HBLKSIZE 4096 # endif -- 1.7.6.5
Re: [PATCH 12/13] Adjust relevant test cases wrt -ftrack-macro-expansion=[0|2]
Gabriel Dos Reis writes: > OK. Thank you. While bootstrapping the tree again, it appeared that an output regression of the objc test objc.dg/foreach-7.m flew below my radar. It's one of those typical cases where the first location pointed to by the diagnostics points into the definition of a macro, instead of pointing to its expansion point. I have just forced that unique test to run without -ftrack-macro-expansion. This looks fairly obvious to me, but I am CC-ing Mike Stump, just in case. I have updated this patch to include the adjustment for objc.dg/foreach-7.m. All the other parts remained unchanged. Tested on x86_64-unknown-linux-gnu against trunk, bootstrap still underway. gcc/testsuite/ * objc.dg/foreach-7.m: Force the test case to run without -ftrack-macro-expansion. * c-c++-common/tm/attrib-1.c: Likewise. * c-c++-common/warn-ommitted-condop.c: Likewise. * gcc.dg/assign-warn-1.c: Likewise. * gcc.dg/assign-warn-2.c: Likewise. * gcc.dg/attr-alloc_size.c: Likewise. * gcc.dg/builtin-stringop-chk-1.c: Likewise. * gcc.dg/builtin-stringop-chk-2.c: Likewise. * gcc.dg/builtin-strncat-chk-1.c: Likewise. * gcc.dg/c90-const-expr-9.c: Likewise. * gcc.dg/c99-const-expr-9.c: Likewise. * gcc.dg/cpp/direct2.c: Likewise. Adjust. * gcc.dg/cpp/direct2s.c: Likewise. * gcc/testsuite/gcc.dg/cpp/pr28709.c: Likewise. * gcc.dg/cpp/pragma-diagnostic-1.c: Likewise. * gcc.dg/dfp/composite-type.c: Likewise. * gcc.dg/uninit-6-O0.c: Adjust the test case and force it to run with -ftrack-macro-expansion * g++.dg/cpp0x/constexpr-ex3.C: Likewise. * g++.dg/cpp0x/constexpr-overflow.C: Likewise. * g++.dg/ext/cleanup-1.C: Likewise. * g++.dg/ext/gnu-inline-global-reject.C: Likewise. * g++.dg/template/sfinae10.C: Likewise. * g++.dg/tm/wrap-2.C: Likewise. * g++.dg/warn/Wconversion-real-integer.C: Likewise. * g++.dg/warn/Wsign-conversion.C: Likewise. * g++.dg/warn/multiple-overflow-warn-1.C: Likewise. * g++.old-deja/g++.mike/p10769b.C: Likewise. * g++.dg/warn/Wdouble-promotion.C: Adjust the test case and force it to run with -ftrack-macro-expansion. * libstdc++-v3/scripts/testsuite_flags.in: By default, run the test cases without -ftrack-macro-expansion. --- gcc/testsuite/c-c++-common/tm/attrib-1.c |2 +- gcc/testsuite/c-c++-common/warn-ommitted-condop.c |2 +- gcc/testsuite/g++.dg/cpp0x/constexpr-ex3.C |2 +- gcc/testsuite/g++.dg/cpp0x/constexpr-overflow.C|2 +- gcc/testsuite/g++.dg/ext/cleanup-1.C |2 +- .../g++.dg/ext/gnu-inline-global-reject.C |2 +- gcc/testsuite/g++.dg/template/sfinae10.C |2 +- gcc/testsuite/g++.dg/tm/wrap-2.C |2 +- .../g++.dg/warn/Wconversion-real-integer.C |2 +- gcc/testsuite/g++.dg/warn/Wdouble-promotion.C |6 +++--- gcc/testsuite/g++.dg/warn/Wsign-conversion.C |2 +- .../g++.dg/warn/multiple-overflow-warn-1.C |2 +- gcc/testsuite/g++.old-deja/g++.mike/p10769b.C |2 +- gcc/testsuite/gcc.dg/assign-warn-1.c |2 +- gcc/testsuite/gcc.dg/assign-warn-2.c |2 +- gcc/testsuite/gcc.dg/attr-alloc_size.c |2 +- gcc/testsuite/gcc.dg/builtin-stringop-chk-1.c |2 +- gcc/testsuite/gcc.dg/builtin-stringop-chk-2.c |2 +- gcc/testsuite/gcc.dg/builtin-strncat-chk-1.c |2 +- gcc/testsuite/gcc.dg/c90-const-expr-9.c|2 +- gcc/testsuite/gcc.dg/c99-const-expr-9.c|2 +- gcc/testsuite/gcc.dg/cpp/direct2.c | 12 +++- gcc/testsuite/gcc.dg/cpp/direct2s.c|2 +- gcc/testsuite/gcc.dg/cpp/pr28709.c |8 +--- gcc/testsuite/gcc.dg/cpp/pragma-diagnostic-1.c |2 +- gcc/testsuite/gcc.dg/dfp/composite-type.c |2 +- gcc/testsuite/gcc.dg/uninit-6-O0.c |6 +++--- gcc/testsuite/objc.dg/foreach-7.m |9 ++--- libstdc++-v3/scripts/testsuite_flags.in|2 +- 29 files changed, 48 insertions(+), 41 deletions(-) diff --git a/gcc/testsuite/c-c++-common/tm/attrib-1.c b/gcc/testsuite/c-c++-common/tm/attrib-1.c index 536aeb3..534fa0e 100644 --- a/gcc/testsuite/c-c++-common/tm/attrib-1.c +++ b/gcc/testsuite/c-c++-common/tm/attrib-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-fgnu-tm" } */ +/* { dg-options "-fgnu-tm -ftrack-macro-expansion=0" } */ #define TC __attribute__((transaction_callable)) #define TU __attribute__((transaction_unsafe)) diff --git a/gcc/testsuite/c-c++-common/warn-ommitted-condop.c b/gcc/testsuite/c-c++-common/warn-ommitted-condop.c index de92b8f..0726f04 100644 --- a/gcc/testsuite/c-c++-common/warn-ommitted-condop.c +++ b/gcc/tes
[v3] constrain std::function constructor to only accept callable types
Currently we only constrain std::function's constructor to reject integral arguments, this patch changes it to reject non-callable arguments. This is the proposed resolution of LWG 2132, I had already planned to do this anyway before the issue was opened so I don't see any need to wait for a DR. * include/std/functional (function::function(F)): LWG 2132: Disable constructor if argument isn't callable. * testsuite/20_util/function/cons/callable.cc: New. Tested x86_64-linux, committed to trunk. commit 0e069c4221d6ed4fda7d10938470c472170dcad7 Author: Jonathan Wakely Date: Tue Feb 14 22:22:48 2012 + * include/std/functional (function::function(F)): LWG 2132: Disable constructor if argument isn't callable. * testsuite/20_util/function/cons/callable.cc: New. diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 980c6ab..0edb4f1 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -1856,7 +1856,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) { typedef _Function_base::_Base_manager<_Functor*> _Base; -public: + public: static bool _M_manager(_Any_data& __dest, const _Any_data& __source, _Manager_operation __op) @@ -1994,7 +1994,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) typedef _Simple_type_wrapper<_Functor> _Wrapper; typedef _Function_base::_Base_manager<_Wrapper> _Base; - public: +public: static bool _M_manager(_Any_data& __dest, const _Any_data& __source, _Manager_operation __op) @@ -2038,7 +2038,23 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) { typedef _Res _Signature_type(_ArgTypes...); - struct _Useless { }; + template + using _Invoke = decltype(__callable_functor(std::declval<_Functor&>()) +(std::declval<_ArgTypes>()...) ); + + template + struct _CheckResult + : is_convertible<_CallRes, _Res1> { }; + + template + struct _CheckResult<_CallRes, void> + : true_type { }; + + template + using _Callable = _CheckResult<_Invoke<_Functor>, _Res>; + + template + using _Requires = typename enable_if<_Cond::value, _Tp>::type; public: typedef _Res result_type; @@ -2099,11 +2115,9 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) * If @a __f is a non-NULL function pointer or an object of type @c * reference_wrapper, this function will not throw. */ - template - function(_Functor __f, -typename enable_if< - !is_integral<_Functor>::value, _Useless>::type - = _Useless()); + template, void>> + function(_Functor); /** * @brief %Function assignment operator. @@ -2178,7 +2192,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) * reference_wrapper, this function will not throw. */ template - typename enable_if::value, function&>::type + _Requires<_Callable<_Functor>, function&> operator=(_Functor&& __f) { function(std::forward<_Functor>(__f)).swap(*this); @@ -2187,7 +2201,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) /// @overload template - typename enable_if::value, function&>::type + function& operator=(reference_wrapper<_Functor> __f) noexcept { function(__f).swap(*this); @@ -2294,11 +2308,9 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) } template -template +template function<_Res(_ArgTypes...)>:: - function(_Functor __f, - typename enable_if< - !is_integral<_Functor>::value, _Useless>::type) + function(_Functor __f) : _Function_base() { typedef _Function_handler<_Signature_type, _Functor> _My_handler; diff --git a/libstdc++-v3/testsuite/20_util/function/cons/callable.cc b/libstdc++-v3/testsuite/20_util/function/cons/callable.cc new file mode 100644 index 000..209c404 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/cons/callable.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +//
[Patch ping] Strength reduction
Thought I'd ping http://gcc.gnu.org/ml/gcc-patches/2012-03/msg01225.html since it's been about six weeks. Any initial feedback would be very much appreciated! Thanks, Bill
[v3] Completely fix libstdc++/51795 in mainline
Hi, contributed by Marc (thanks Again!) and integrated by me. Tested x86_64-linux, multilib. Committed to mainline. Thanks, Paolo. /// 2012-04-29 Marc Glisse Paolo Carlini PR libstdc++/51795 * include/bits/stl_algobase.h (__lg<>(_Size)): Remove. (__lg(int), __lg(unsigned), __lg(long), __lg(unsigned long), __lg(long long), __lg(unsigned long long)): Define constexpr. * include/bits/random.h (_Mod<>): Overcome Schrage's algorithm limitations. (__mod): Adjust. (linear_congruential): Remove FIXME static_assert. * include/bits/random.tcc (_Mod<>): Adjust. * testsuite/26_numerics/random/linear_congruential_engine/operators/ 51795.cc: New. Index: include/bits/stl_algobase.h === --- include/bits/stl_algobase.h (revision 186943) +++ include/bits/stl_algobase.h (working copy) @@ -975,37 +975,27 @@ /// This is a helper function for the sort routines and for random.tcc. // Precondition: __n > 0. - template -inline _Size -__lg(_Size __n) -{ - _Size __k; - for (__k = 0; __n != 0; __n >>= 1) - ++__k; - return __k - 1; -} - - inline int + inline _GLIBCXX_CONSTEXPR int __lg(int __n) { return sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); } - inline unsigned + inline _GLIBCXX_CONSTEXPR unsigned __lg(unsigned __n) { return sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); } - inline long + inline _GLIBCXX_CONSTEXPR long __lg(long __n) { return sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); } - inline unsigned long + inline _GLIBCXX_CONSTEXPR unsigned long __lg(unsigned long __n) { return sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); } - inline long long + inline _GLIBCXX_CONSTEXPR long long __lg(long long __n) { return sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } - inline unsigned long long + inline _GLIBCXX_CONSTEXPR unsigned long long __lg(unsigned long long __n) { return sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } Index: include/bits/random.tcc === --- include/bits/random.tcc (revision 186943) +++ include/bits/random.tcc (working copy) @@ -41,59 +41,43 @@ { _GLIBCXX_BEGIN_NAMESPACE_VERSION -// General case for x = (ax + c) mod m -- use Schrage's algorithm to -// avoid integer overflow. +// General case for x = (ax + c) mod m -- use Schrage's algorithm +// to avoid integer overflow. // -// Because a and c are compile-time integral constants the compiler -// kindly elides any unreachable paths. -// // Preconditions: a > 0, m > 0. // -// XXX FIXME: as-is, only works correctly for __m % __a < __m / __a. -// -template - struct _Mod +// Note: only works correctly for __m % __a < __m / __a. +template + _Tp + _Mod<_Tp, __m, __a, __c, false, true>:: + __calc(_Tp __x) { - static _Tp - __calc(_Tp __x) - { - if (__a == 1) - __x %= __m; - else - { - static const _Tp __q = __m / __a; - static const _Tp __r = __m % __a; + if (__a == 1) + __x %= __m; + else + { + static const _Tp __q = __m / __a; + static const _Tp __r = __m % __a; - _Tp __t1 = __a * (__x % __q); - _Tp __t2 = __r * (__x / __q); - if (__t1 >= __t2) - __x = __t1 - __t2; - else - __x = __m - __t2 + __t1; - } + _Tp __t1 = __a * (__x % __q); + _Tp __t2 = __r * (__x / __q); + if (__t1 >= __t2) + __x = __t1 - __t2; + else + __x = __m - __t2 + __t1; + } - if (__c != 0) - { - const _Tp __d = __m - __x; - if (__d > __c) - __x += __c; - else - __x = __c - __d; - } - return __x; - } - }; + if (__c != 0) + { + const _Tp __d = __m - __x; + if (__d > __c) + __x += __c; + else + __x = __c - __d; + } + return __x; + } -// Special case for m == 0 -- use unsigned integer overflow as modulo -// operator. -template - struct _Mod<_Tp, __m, __a, __c, true> - { - static _Tp - __calc(_Tp __x) - { return __a * __x + __c; } - }; - template _OutputIterator Index: include/bits/random.h === --- include/bits/random.h (revision 186943) +++ include/bits/random.h (working copy) @@ -76,15 +76,78 @@ struct _Shift<_UIntType, __w, true> { static const
Re: [PATCH 04/11] Fix expansion point loc for macro-like tokens
OK. Jason
Re: [PATCH 12/13] Adjust relevant test cases wrt -ftrack-macro-expansion=[0|2]
Dodji Seketeli writes: > Gabriel Dos Reis writes: > >> OK. > > Thank you. > > While bootstrapping the tree again, it appeared that an output > regression of the objc test objc.dg/foreach-7.m flew below my radar. > > It's one of those typical cases where the first location pointed to by > the diagnostics points into the definition of a macro, instead of > pointing to its expansion point. I have just forced that unique test to > run without -ftrack-macro-expansion. > > This looks fairly obvious to me, but I am CC-ing Mike Stump, just in > case. > > I have updated this patch to include the adjustment for > objc.dg/foreach-7.m. All the other parts remained unchanged. > > Tested on x86_64-unknown-linux-gnu against trunk, bootstrap still > underway. FWIW, this passed bootstrap fine. -- Dodji