This is the mail archive of the gcc-cvs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

r262908 - in /trunk/gcc/go/gofrontend: MERGE go...


Author: ian
Date: Fri Jul 20 19:56:21 2018
New Revision: 262908

URL: https://gcc.gnu.org/viewcvs?rev=262908&root=gcc&view=rev
Log:
    compiler: do order_evaluations before remove_shortcuts
    
    In remove_shortcuts, the shortcut expressions (&&, ||) are
    rewritten to if statements, which are lifted out before the
    statement containing the shortcut expression. If the containing
    statement has other (sub)expressions that should be evaluated
    before the shortcut expression, which has not been lifted out,
    this will result in wrong evaluation order.
    
    For example, F() + G(A() && B()), the evaluation order per spec
    is F, A, B (if A returns true), G. If we lift A() and B() out
    first, they will be called before F, which is wrong.
    
    To fix this, we split order_evaluations to two phases. The first
    phase, which runs before remove_shortcuts, skips shortcut
    expressions' components. So it won't lift out subexpressions that
    are evaluated conditionally. The shortcut expression itself is
    ordered, since it may have side effects. Then we run
    remove_shortcuts. At this point the subexpressions that should be
    evaluated before the shortcut expression are already lifted out.
    remove_shortcuts also runs the second phase of order_evaluations
    to order the components of shortcut expressions, which were
    skipped during the first phase.
    
    Reorder the code blocks of remove_shortcuts and order_evaluations,
    since remove_shortcuts now calls Order_eval.
    
    Fixes golang/go#26495.
    
    Reviewed-on: https://go-review.googlesource.com/125299

Modified:
    trunk/gcc/go/gofrontend/MERGE
    trunk/gcc/go/gofrontend/go.cc
    trunk/gcc/go/gofrontend/gogo.cc


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]