From 9daf14d44298a602ff7be05efe6c9a65e9c97350 Mon Sep 17 00:00:00 2001 From: Andreas Arnez Date: Thu, 26 Nov 2015 17:52:01 +0000 Subject: [PATCH] cp-gimplify.c (genericize_cp_loop): Change LOOP_EXPR's location to start of loop body instead of start of loop. gcc/cp/ChangeLog: 2015-11-26 Andreas Arnez * cp-gimplify.c (genericize_cp_loop): Change LOOP_EXPR's location to start of loop body instead of start of loop. gcc/testsuite/ChangeLog: 2015-11-26 Andreas Arnez * g++.dg/guality/pr67192.C: New test. From-SVN: r230979 --- gcc/cp/ChangeLog | 5 ++ gcc/cp/cp-gimplify.c | 7 ++- gcc/testsuite/ChangeLog | 4 ++ gcc/testsuite/g++.dg/guality/pr67192.C | 79 ++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/guality/pr67192.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 90d86dca052..1d6e252ebb1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-11-26 Andreas Arnez + + * cp-gimplify.c (genericize_cp_loop): Change LOOP_EXPR's location + to start of loop body instead of start of loop. + 2015-11-26 Jakub Jelinek PR c++/68508 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 8fdcb6d81e0..a9a34cd81cc 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -263,7 +263,12 @@ genericize_cp_loop (tree *stmt_p, location_t start_locus, tree cond, tree body, loop = stmt_list; } else - loop = build1_loc (start_locus, LOOP_EXPR, void_type_node, stmt_list); + { + location_t loc = EXPR_LOCATION (expr_first (body)); + if (loc == UNKNOWN_LOCATION) + loc = start_locus; + loop = build1_loc (loc, LOOP_EXPR, void_type_node, stmt_list); + } stmt_list = NULL; append_to_statement_list (loop, &stmt_list); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5c663c4d07c..7eedf80f38f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-11-26 Andreas Arnez + + * g++.dg/guality/pr67192.C: New test. + 2015-11-26 Matthew Wahab * gcc.target/aarch64/advsimd-intrinsics/vqrdmlXh_lane.inc: New file, diff --git a/gcc/testsuite/g++.dg/guality/pr67192.C b/gcc/testsuite/g++.dg/guality/pr67192.C new file mode 100644 index 00000000000..c09ecf8dc81 --- /dev/null +++ b/gcc/testsuite/g++.dg/guality/pr67192.C @@ -0,0 +1,79 @@ +/* PR debug/67192 */ +/* { dg-do run } */ +/* { dg-options "-x c++ -g -Wmisleading-indentation" } */ + +volatile int cnt = 0; + +__attribute__((noinline, noclone)) static int +last (void) +{ + return ++cnt % 5 == 0; +} + +__attribute__((noinline, noclone)) static void +do_it (void) +{ + asm volatile ("" : : "r" (&cnt) : "memory"); +} + +__attribute__((noinline, noclone)) static void +f1 (void) +{ + for (;; do_it()) + { + if (last ()) + break; + } + do_it (); /* { dg-final { gdb-test 27 "cnt" "5" } } */ +} + +__attribute__((noinline, noclone)) static void +f2 (void) +{ + while (1) + { + if (last ()) + break; + do_it (); + } + do_it (); /* { dg-final { gdb-test 39 "cnt" "10" } } */ +} + +__attribute__((noinline, noclone)) static void +f3 (void) +{ + for (;; do_it()) + if (last ()) + break; + do_it (); /* { dg-final { gdb-test 48 "cnt" "15" } } */ +} + +__attribute__((noinline, noclone)) static void +f4 (void) +{ + while (1) /* { dg-final { gdb-test 54 "cnt" "15" } } */ + if (last ()) + break; + else + do_it (); + do_it (); /* { dg-final { gdb-test 59 "cnt" "20" } } */ +} + +void (*volatile fnp1) (void) = f1; +void (*volatile fnp2) (void) = f2; +void (*volatile fnp3) (void) = f3; +void (*volatile fnp4) (void) = f4; + +int +main () +{ + asm volatile ("" : : "r" (&fnp1) : "memory"); + asm volatile ("" : : "r" (&fnp2) : "memory"); + asm volatile ("" : : "r" (&fnp3) : "memory"); + asm volatile ("" : : "r" (&fnp4) : "memory"); + fnp1 (); + fnp2 (); + fnp3 (); + fnp4 (); + return 0; +}