Backports to gcc-9-branch

2019-11-08 Thread Jakub Jelinek
Hi!

I've backorted following 10 patches from trunk to 9 branch,
bootstrapped/regtested them on x86_64-linux and i686-linux and committed.

Jakub
2019-11-08  Jakub Jelinek  

Backported from mainline
2019-10-21  Jakub Jelinek  

PR c++/92015
* constexpr.c (cxx_eval_component_reference, cxx_eval_bit_field_ref):
Use STRIP_ANY_LOCATION_WRAPPER on CONSTRUCTOR elts.

* g++.dg/cpp0x/constexpr-92015.C: New test.

--- gcc/cp/constexpr.c  (revision 277266)
+++ gcc/cp/constexpr.c  (revision 277267)
@@ -2887,7 +2887,10 @@ cxx_eval_component_reference (const cons
  : field == part)
{
  if (value)
-   return value;
+   {
+ STRIP_ANY_LOCATION_WRAPPER (value);
+ return value;
+   }
  else
/* We're in the middle of initializing it.  */
break;
@@ -2977,6 +2980,7 @@ cxx_eval_bit_field_ref (const constexpr_
   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (whole), i, field, value)
 {
   tree bitpos = bit_position (field);
+  STRIP_ANY_LOCATION_WRAPPER (value);
   if (bitpos == start && DECL_SIZE (field) == TREE_OPERAND (t, 1))
return value;
   if (TREE_CODE (TREE_TYPE (field)) == INTEGER_TYPE
--- gcc/testsuite/g++.dg/cpp0x/constexpr-92015.C(nonexistent)
+++ gcc/testsuite/g++.dg/cpp0x/constexpr-92015.C(revision 277267)
@@ -0,0 +1,7 @@
+// PR c++/92015
+// { dg-do compile { target c++11 } }
+
+struct S1 { char c[6] {'h', 'e', 'l', 'l', 'o', 0}; };
+struct S2 { char c[6] = "hello"; };
+static_assert (S1{}.c[0] == 'h', "");
+static_assert (S2{}.c[0] == 'h', "");
2019-11-08  Jakub Jelinek  

Backported from mainline
2019-10-22  Tamar Christina  

PR sanitizer/92154
* sanitizer_common/sanitizer_platform_limits_posix.cc:
Cherry-pick compiler-rt revision r375220.

--- libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
(revision 277290)
+++ libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
(revision 277291)
@@ -1126,8 +1126,12 @@ CHECK_SIZE_AND_OFFSET(ipc_perm, uid);
 CHECK_SIZE_AND_OFFSET(ipc_perm, gid);
 CHECK_SIZE_AND_OFFSET(ipc_perm, cuid);
 CHECK_SIZE_AND_OFFSET(ipc_perm, cgid);
-#if !defined(__aarch64__) || !SANITIZER_LINUX || __GLIBC_PREREQ (2, 21)
+#if (!defined(__aarch64__) || !SANITIZER_LINUX || __GLIBC_PREREQ (2, 21)) && \
+!defined(__arm__)
 /* On aarch64 glibc 2.20 and earlier provided incorrect mode field.  */
+/* On Arm glibc 2.31 and later provide a different mode field, this field is
+   never used by libsanitizer so we can simply ignore this assert for all glibc
+   versions.  */
 CHECK_SIZE_AND_OFFSET(ipc_perm, mode);
 #endif
 
2019-11-08  Jakub Jelinek  

Backported from mainline
2019-10-22  Jakub Jelinek  

PR tree-optimization/85887
* decl.c (expand_static_init): Drop ECF_LEAF from __cxa_guard_acquire
and __cxa_guard_release.

--- gcc/cp/decl.c   (revision 277292)
+++ gcc/cp/decl.c   (revision 277293)
@@ -8589,14 +8589,14 @@ expand_static_init (tree decl, tree init
  (acquire_name, build_function_type_list (integer_type_node,
   TREE_TYPE (guard_addr),
   NULL_TREE),
-  NULL_TREE, ECF_NOTHROW | ECF_LEAF);
+  NULL_TREE, ECF_NOTHROW);
  if (!release_fn || !abort_fn)
vfntype = build_function_type_list (void_type_node,
TREE_TYPE (guard_addr),
NULL_TREE);
  if (!release_fn)
release_fn = push_library_fn (release_name, vfntype, NULL_TREE,
-  ECF_NOTHROW | ECF_LEAF);
+ ECF_NOTHROW);
  if (!abort_fn)
abort_fn = push_library_fn (abort_name, vfntype, NULL_TREE,
ECF_NOTHROW | ECF_LEAF);
2019-11-08  Jakub Jelinek  

Backported from mainline
2019-10-27  Jakub Jelinek  

* locales.c (iso_3166): Add missing comma after "United-States".

--- gcc/ada/locales.c   (revision 277491)
+++ gcc/ada/locales.c   (revision 277492)
@@ -529,7 +529,7 @@ static char* iso_3166[] =
   "UM", "United States Minor Outlying Islands",
   "US", "United States",
   "US", "United States of America",
-  "US", "United-States"
+  "US", "United-States",
   "UY", "Uruguay",
   "UZ", "Uzbekistan",
 
2019-11-08  Jakub Jelinek  

Backported from mainline
2019-10-29  Jakub Jelinek  

* doc/install.texi (--enable-offload-targets): Fix up a typo in the
example, use actual names of supported offload targets.

--- gcc/doc/install.texi(revision 277551)
+++ gcc/doc/install.texi(revision 277552)
@@ -2158,7 +2158,7 @@ specifying paths @var{path1}, @dots{}, @
 
 

[committed] Backports to gcc-9-branch

2019-10-21 Thread Jakub Jelinek
Hi!

I've backported following 18 patches (20 trunk commits in total)
from trunk to gcc-9-branch, bootstrapped/regtested on x86_64-linux and
i686-linux and committed to gcc-9-branch.

Jakub
2019-10-21  Jakub Jelinek  

Backported from mainline
2019-08-02  Jakub Jelinek  

* quadmath.h (M_Eq, M_LOG2Eq, M_LOG10Eq, M_LN2q, M_LN10q, M_PIq,
M_PI_2q, M_PI_4q, M_1_PIq, M_2_PIq, M_2_SQRTPIq, M_SQRT2q,
M_SQRT1_2q): Use two more decimal places.

--- libquadmath/quadmath.h  (revision 273996)
+++ libquadmath/quadmath.h  (revision 273997)
@@ -1,5 +1,5 @@
 /* GCC Quad-Precision Math Library
-   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2010-2019 Free Software Foundation, Inc.
Written by Francois-Xavier Coudert  
 
 This file is part of the libquadmath library.
@@ -165,19 +165,19 @@ extern int quadmath_snprintf (char *str,
(floating constant exceeds range of ‘__float128’)  */
 /* #define HUGE_VALQ (__extension__ 0x1.0p32767Q) */
 
-#define M_Eq   2.7182818284590452353602874713526625Q  /* e */
-#define M_LOG2Eq   1.4426950408889634073599246810018921Q  /* log_2 e */
-#define M_LOG10Eq  0.4342944819032518276511289189166051Q  /* log_10 e */
-#define M_LN2q 0.6931471805599453094172321214581766Q  /* log_e 2 */
-#define M_LN10q2.3025850929940456840179914546843642Q  /* log_e 
10 */
-#define M_PIq  3.1415926535897932384626433832795029Q  /* pi */
-#define M_PI_2q1.5707963267948966192313216916397514Q  /* pi/2 
*/
-#define M_PI_4q0.7853981633974483096156608458198757Q  /* pi/4 
*/
-#define M_1_PIq0.3183098861837906715377675267450287Q  /* 1/pi 
*/
-#define M_2_PIq0.6366197723675813430755350534900574Q  /* 2/pi 
*/
-#define M_2_SQRTPIq1.1283791670955125738961589031215452Q  /* 2/sqrt(pi) */
-#define M_SQRT2q   1.4142135623730950488016887242096981Q  /* sqrt(2) */
-#define M_SQRT1_2q 0.7071067811865475244008443621048490Q  /* 1/sqrt(2) */
+#define M_Eq   2.718281828459045235360287471352662498Q  /* e */
+#define M_LOG2Eq   1.442695040888963407359924681001892137Q  /* log_2 e */
+#define M_LOG10Eq  0.434294481903251827651128918916605082Q  /* log_10 e */
+#define M_LN2q 0.693147180559945309417232121458176568Q  /* log_e 2 */
+#define M_LN10q2.302585092994045684017991454684364208Q  /* 
log_e 10 */
+#define M_PIq  3.141592653589793238462643383279502884Q  /* pi */
+#define M_PI_2q1.570796326794896619231321691639751442Q  /* 
pi/2 */
+#define M_PI_4q0.785398163397448309615660845819875721Q  /* 
pi/4 */
+#define M_1_PIq0.318309886183790671537767526745028724Q  /* 
1/pi */
+#define M_2_PIq0.636619772367581343075535053490057448Q  /* 
2/pi */
+#define M_2_SQRTPIq1.128379167095512573896158903121545172Q  /* 2/sqrt(pi) 
*/
+#define M_SQRT2q   1.414213562373095048801688724209698079Q  /* sqrt(2) */
+#define M_SQRT1_2q 0.707106781186547524400844362104849039Q  /* 1/sqrt(2) */
 
 #define __quadmath_extern_inline \
   extern inline __attribute__ ((__gnu_inline__))
2019-10-21  Jakub Jelinek  

Backported from mainline
2019-08-09  Jakub Jelinek  

PR c/91401
* c-parser.c (c_parser_omp_clause_dist_schedule): Fix up typos in the
check_no_duplicate_clause call.  Comment it out, instead emit a
warning for duplicate dist_schedule clauses.

* parser.c (cp_parser_omp_clause_dist_schedule): Comment out the
check_no_duplicate_clause call, instead emit a warning for duplicate
dist_schedule clauses.

* c-c++-common/gomp/pr91401-1.c: New test.
* c-c++-common/gomp/pr91401-2.c: New test.

--- gcc/c/c-parser.c(revision 274225)
+++ gcc/c/c-parser.c(revision 274226)
@@ -14811,7 +14811,10 @@ c_parser_omp_clause_dist_schedule (c_par
 c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
   "expected %<,%> or %<)%>");
 
-  check_no_duplicate_clause (list, OMP_CLAUSE_SCHEDULE, "schedule");
+  /* check_no_duplicate_clause (list, OMP_CLAUSE_DIST_SCHEDULE,
+   "dist_schedule"); */
+  if (omp_find_clause (list, OMP_CLAUSE_DIST_SCHEDULE))
+warning_at (loc, 0, "too many %qs clauses", "dist_schedule");
   if (t == error_mark_node)
 return list;
 
--- gcc/cp/parser.c (revision 274225)
+++ gcc/cp/parser.c (revision 274226)
@@ -35258,8 +35258,10 @@ cp_parser_omp_clause_dist_schedule (cp_p
   else if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_COMMA_CLOSE_PAREN))
 goto resync_fail;
 
-  check_no_duplicate_clause (list, OMP_CLAUSE_DIST_SCHEDULE, "dist_schedule",
-location);
+  /* check_no_duplicate_clause (list, OMP_CLAUSE_DIST_SCHEDULE,
+   "dist_schedule", location); */
+  if (omp_find_clause (list, OMP_CLAUSE_DIST_SCHEDULE))
+  

Backports to gcc-9-branch

2019-08-01 Thread Jakub Jelinek
Hi!

I've backported following 5 patches from trunk to 9.2,
bootstrapped/regtested on x86_64-linux and i686-linux, committed to
gcc-9-branch.

Jakub
2019-08-01  Jakub Jelinek  

Backported from mainline
2019-07-17  Jakub Jelinek  

PR tree-optimization/91157
* tree-vect-generic.c (expand_vector_comparison): Handle lhs being
a vector boolean with scalar mode.
(expand_vector_condition): Handle first operand being a vector boolean
with scalar mode.
(expand_vector_operations_1): For comparisons, don't bail out early
if the return type is vector boolean with scalar mode, but comparison
operand type is not.

* gcc.target/i386/avx512f-pr91157.c: New test.
* gcc.target/i386/avx512bw-pr91157.c: New test.

--- gcc/tree-vect-generic.c (revision 273542)
+++ gcc/tree-vect-generic.c (revision 273545)
@@ -382,8 +382,47 @@ expand_vector_comparison (gimple_stmt_it
   tree t;
   if (!expand_vec_cmp_expr_p (TREE_TYPE (op0), type, code)
   && !expand_vec_cond_expr_p (type, TREE_TYPE (op0), code))
-t = expand_vector_piecewise (gsi, do_compare, type,
-TREE_TYPE (TREE_TYPE (op0)), op0, op1, code);
+{
+  if (VECTOR_BOOLEAN_TYPE_P (type)
+ && SCALAR_INT_MODE_P (TYPE_MODE (type))
+ && known_lt (GET_MODE_BITSIZE (TYPE_MODE (type)),
+  TYPE_VECTOR_SUBPARTS (type)
+  * GET_MODE_BITSIZE (SCALAR_TYPE_MODE
+   (TREE_TYPE (type)
+   {
+ tree inner_type = TREE_TYPE (TREE_TYPE (op0));
+ tree part_width = TYPE_SIZE (inner_type);
+ tree index = bitsize_int (0);
+ int nunits = nunits_for_known_piecewise_op (TREE_TYPE (op0));
+ int prec = GET_MODE_PRECISION (SCALAR_TYPE_MODE (type));
+ tree ret_type = build_nonstandard_integer_type (prec, 1);
+ tree ret_inner_type = boolean_type_node;
+ int i;
+ location_t loc = gimple_location (gsi_stmt (*gsi));
+ t = build_zero_cst (ret_type);
+
+ if (TYPE_PRECISION (ret_inner_type) != 1)
+   ret_inner_type = build_nonstandard_integer_type (1, 1);
+ warning_at (loc, OPT_Wvector_operation_performance,
+ "vector operation will be expanded piecewise");
+ for (i = 0; i < nunits;
+  i++, index = int_const_binop (PLUS_EXPR, index, part_width))
+   {
+ tree a = tree_vec_extract (gsi, inner_type, op0, part_width,
+index);
+ tree b = tree_vec_extract (gsi, inner_type, op1, part_width,
+index);
+ tree result = gimplify_build2 (gsi, code, ret_inner_type, a, b);
+ t = gimplify_build3 (gsi, BIT_INSERT_EXPR, ret_type, t, result,
+  bitsize_int (i));
+   }
+ t = gimplify_build1 (gsi, VIEW_CONVERT_EXPR, type, t);
+   }
+  else
+   t = expand_vector_piecewise (gsi, do_compare, type,
+TREE_TYPE (TREE_TYPE (op0)), op0, op1,
+code);
+}
   else
 t = NULL_TREE;
 
@@ -879,6 +918,7 @@ expand_vector_condition (gimple_stmt_ite
   tree a1 = a;
   tree a2 = NULL_TREE;
   bool a_is_comparison = false;
+  bool a_is_scalar_bitmask = false;
   tree b = gimple_assign_rhs2 (stmt);
   tree c = gimple_assign_rhs3 (stmt);
   vec *v;
@@ -942,6 +982,20 @@ expand_vector_condition (gimple_stmt_ite
   warning_at (loc, OPT_Wvector_operation_performance,
  "vector condition will be expanded piecewise");
 
+  if (!a_is_comparison
+  && VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (a))
+  && SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (a)))
+  && known_lt (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (a))),
+  TYPE_VECTOR_SUBPARTS (TREE_TYPE (a))
+  * GET_MODE_BITSIZE (SCALAR_TYPE_MODE
+   (TREE_TYPE (TREE_TYPE (a))
+{
+  a_is_scalar_bitmask = true;
+  int prec = GET_MODE_PRECISION (SCALAR_TYPE_MODE (TREE_TYPE (a)));
+  tree atype = build_nonstandard_integer_type (prec, 1);
+  a = gimplify_build1 (gsi, VIEW_CONVERT_EXPR, atype, a);
+}
+
   int nunits = nunits_for_known_piecewise_op (type);
   vec_alloc (v, nunits);
   for (i = 0; i < nunits; i++)
@@ -957,6 +1011,14 @@ expand_vector_condition (gimple_stmt_ite
   comp_width, comp_index);
  aa = fold_build2 (TREE_CODE (a), cond_type, aa1, aa2);
}
+  else if (a_is_scalar_bitmask)
+   {
+ wide_int w = wi::set_bit_in_zero (i, TYPE_PRECISION (TREE_TYPE (a)));
+ result = gimplify_build2 (gsi, BIT_AND_EXPR, TREE_TYPE (a),
+   a, wide_int_to_tree (TREE_TYPE (a), w));
+ aa = fold_build2 (NE_EXPR, boolean_type_node, 

Backports to gcc-9-branch

2019-06-05 Thread Jakub Jelinek
Hi!

I've backported following 4 patches from trunk to 9 branch,
bootstrapped/regtested on x86_64-linux and i686-linux, committed.

Jakub
2019-06-05  Jakub Jelinek  

Backported from mainline
2019-05-24  Jakub Jelinek  

PR libgomp/90585
* plugin/plugin-hsa.c (print_kernel_dispatch, run_kernel): Use PRIu64
macro instead of "lu".
(release_kernel_dispatch): Likewise.  Cast shadow->debug to uintptr_t
before casting to void *.

--- libgomp/plugin/plugin-hsa.c (revision 271596)
+++ libgomp/plugin/plugin-hsa.c (revision 271597)
@@ -1154,8 +1164,9 @@ create_single_kernel_dispatch (struct ke
 static void
 release_kernel_dispatch (struct GOMP_hsa_kernel_dispatch *shadow)
 {
-  HSA_DEBUG ("Released kernel dispatch: %p has value: %lu (%p)\n", shadow,
-shadow->debug, (void *) shadow->debug);
+  HSA_DEBUG ("Released kernel dispatch: %p has value: %" PRIu64 " (%p)\n",
+shadow, shadow->debug,
+(void *) (uintptr_t) shadow->debug);
 
   hsa_fns.hsa_memory_free_fn (shadow->kernarg_address);
 
@@ -1276,9 +1287,9 @@ print_kernel_dispatch (struct GOMP_hsa_k
   indent_stream (stderr, indent);
   fprintf (stderr, "kernarg_address: %p\n", dispatch->kernarg_address);
   indent_stream (stderr, indent);
-  fprintf (stderr, "object: %lu\n", dispatch->object);
+  fprintf (stderr, "object: %" PRIu64 "\n", dispatch->object);
   indent_stream (stderr, indent);
-  fprintf (stderr, "signal: %lu\n", dispatch->signal);
+  fprintf (stderr, "signal: %" PRIu64 "\n", dispatch->signal);
   indent_stream (stderr, indent);
   fprintf (stderr, "private_segment_size: %u\n",
   dispatch->private_segment_size);
@@ -1286,8 +1297,8 @@ print_kernel_dispatch (struct GOMP_hsa_k
   fprintf (stderr, "group_segment_size: %u\n",
   dispatch->group_segment_size);
   indent_stream (stderr, indent);
-  fprintf (stderr, "children dispatches: %lu\n",
-  dispatch->kernel_dispatch_count);
+  fprintf (stderr, "children dispatches: %" PRIu64 "\n",
+  dispatch->kernel_dispatch_count);
   indent_stream (stderr, indent);
   fprintf (stderr, "omp_num_threads: %u\n",
   dispatch->omp_num_threads);
@@ -1594,8 +1605,8 @@ run_kernel (struct kernel_info *kernel,
hsa_signal_t child_s;
child_s.handle = shadow->children_dispatches[i]->signal;
 
-   HSA_DEBUG ("Waiting for children completion signal: %lu\n",
-  shadow->children_dispatches[i]->signal);
+   HSA_DEBUG ("Waiting for children completion signal: %" PRIu64 "\n",
+  shadow->children_dispatches[i]->signal);
hsa_fns.hsa_signal_load_acquire_fn (child_s);
   }
 
2019-06-05  Jakub Jelinek  

Backported from mainline
2019-05-27  Jakub Jelinek  

PR libgomp/90641
* work.c (gomp_init_work_share): Instead of aligning final ordered
value to multiples of long long alignment, align to that the
first part (ordered team ids) and if inline_ordered_team_ids
is not on a long long alignment boundary within the structure,
use __alignof__ (long long) - 1 pad size always.
* loop.c (GOMP_loop_start): Fix *mem computation if
inline_ordered_team_ids is not aligned on long long alignment boundary
within the structure.
* loop-ull.c (GOMP_loop_ull_start): Likewise.
* sections.c (GOMP_sections2_start): Likewise.

--- libgomp/loop.c  (revision 271670)
+++ libgomp/loop.c  (revision 271671)
@@ -267,14 +267,17 @@ GOMP_loop_start (long start, long end, l
   if (mem)
{
  uintptr_t size = (uintptr_t) *mem;
+#define INLINE_ORDERED_TEAM_IDS_OFF \
+  ((offsetof (struct gomp_work_share, inline_ordered_team_ids) \
++ __alignof__ (long long) - 1) & ~(__alignof__ (long long) - 1))
  if (size > (sizeof (struct gomp_work_share)
- - offsetof (struct gomp_work_share,
- inline_ordered_team_ids)))
-   thr->ts.work_share->ordered_team_ids
- = gomp_malloc_cleared (size);
+ - INLINE_ORDERED_TEAM_IDS_OFF))
+   *mem
+ = (void *) (thr->ts.work_share->ordered_team_ids
+ = gomp_malloc_cleared (size));
  else
-   memset (thr->ts.work_share->ordered_team_ids, '\0', size);
- *mem = (void *) thr->ts.work_share->ordered_team_ids;
+   *mem = memset (((char *) thr->ts.work_share)
+  + INLINE_ORDERED_TEAM_IDS_OFF, '\0', size);
}
   gomp_work_share_init_done ();
 }
@@ -287,7 +290,18 @@ GOMP_loop_start (long start, long end, l
  first_reductions);
}
   if (mem)
-   *mem = (void *) thr->ts.work_share->ordered_team_ids;
+   {
+ if ((offsetof (struct gomp_work_share, inline_ordered_team_ids)
+  & (__alignof__ (long long) - 1)) == 0)
+   

Backports to gcc-9-branch

2019-05-17 Thread Jakub Jelinek
Hi!

I've backported following 11 patches from trunk to gcc-9-branch,
bootstrapped/regtested on x86_64-linux and i686-linux, committed.

Jakub
2019-05-17  Jakub Jelinek  

Backported from mainline
2019-04-26  Jakub Jelinek  

PR debug/90197
* c-tree.h (c_finish_loop): Add 2 further location_t arguments.
* c-parser.c (c_parser_while_statement): Adjust c_finish_loop caller.
(c_parser_do_statement): Likewise.
(c_parser_for_statement): Likewise.  Formatting fixes.
* c-typeck.c (c_finish_loop): Add COND_LOCUS and INCR_LOCUS arguments,
emit DEBUG_BEGIN_STMTs if needed.

--- gcc/c/c-tree.h  (revision 270605)
+++ gcc/c/c-tree.h  (revision 270606)
@@ -694,7 +694,8 @@ extern int c_types_compatible_p (tree, t
 extern tree c_begin_compound_stmt (bool);
 extern tree c_end_compound_stmt (location_t, tree, bool);
 extern void c_finish_if_stmt (location_t, tree, tree, tree);
-extern void c_finish_loop (location_t, tree, tree, tree, tree, tree, bool);
+extern void c_finish_loop (location_t, location_t, tree, location_t, tree,
+  tree, tree, tree, bool);
 extern tree c_begin_stmt_expr (void);
 extern tree c_finish_stmt_expr (location_t, tree);
 extern tree c_process_expr_stmt (location_t, tree);
--- gcc/c/c-parser.c(revision 270605)
+++ gcc/c/c-parser.c(revision 270606)
@@ -6001,7 +6001,8 @@ c_parser_while_statement (c_parser *pars
   location_t loc_after_labels;
   bool open_brace = c_parser_next_token_is (parser, CPP_OPEN_BRACE);
   body = c_parser_c99_block_statement (parser, if_p, _after_labels);
-  c_finish_loop (loc, cond, NULL, body, c_break_label, c_cont_label, true);
+  c_finish_loop (loc, loc, cond, UNKNOWN_LOCATION, NULL, body,
+c_break_label, c_cont_label, true);
   add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
   c_parser_maybe_reclassify_token (parser);
 
@@ -6046,6 +6047,7 @@ c_parser_do_statement (c_parser *parser,
   c_break_label = save_break;
   new_cont = c_cont_label;
   c_cont_label = save_cont;
+  location_t cond_loc = c_parser_peek_token (parser)->location;
   cond = c_parser_paren_condition (parser);
   if (ivdep && cond != error_mark_node)
 cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
@@ -6059,7 +6061,8 @@ c_parser_do_statement (c_parser *parser,
   build_int_cst (integer_type_node, unroll));
   if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>"))
 c_parser_skip_to_end_of_block_or_statement (parser);
-  c_finish_loop (loc, cond, NULL, body, new_break, new_cont, false);
+  c_finish_loop (loc, cond_loc, cond, UNKNOWN_LOCATION, NULL, body,
+new_break, new_cont, false);
   add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
 }
 
@@ -6132,7 +6135,9 @@ c_parser_for_statement (c_parser *parser
   /* Silence the bogus uninitialized warning.  */
   tree collection_expression = NULL;
   location_t loc = c_parser_peek_token (parser)->location;
-  location_t for_loc = c_parser_peek_token (parser)->location;
+  location_t for_loc = loc;
+  location_t cond_loc = UNKNOWN_LOCATION;
+  location_t incr_loc = UNKNOWN_LOCATION;
   bool is_foreach_statement = false;
   gcc_assert (c_parser_next_token_is_keyword (parser, RID_FOR));
   token_indent_info for_tinfo
@@ -6166,7 +6171,8 @@ c_parser_for_statement (c_parser *parser
  c_parser_consume_token (parser);
  is_foreach_statement = true;
  if (check_for_loop_decls (for_loc, true) == NULL_TREE)
-   c_parser_error (parser, "multiple iterating variables in fast 
enumeration");
+   c_parser_error (parser, "multiple iterating variables in "
+   "fast enumeration");
}
  else
check_for_loop_decls (for_loc, flag_isoc99);
@@ -6196,7 +6202,8 @@ c_parser_for_statement (c_parser *parser
  c_parser_consume_token (parser);
  is_foreach_statement = true;
  if (check_for_loop_decls (for_loc, true) == NULL_TREE)
-   c_parser_error (parser, "multiple iterating variables in 
fast enumeration");
+   c_parser_error (parser, "multiple iterating variables in "
+   "fast enumeration");
}
  else
check_for_loop_decls (for_loc, flag_isoc99);
@@ -6218,15 +6225,18 @@ c_parser_for_statement (c_parser *parser
c_parser_consume_token (parser);
is_foreach_statement = true;
if (! lvalue_p (init_expression))
- c_parser_error (parser, "invalid iterating variable in fast 
enumeration");
-   object_expression = c_fully_fold (init_expression, false, NULL);
+ c_parser_error (parser, "invalid iterating variable in "
+ "fast enumeration");
+   object_expression
+