From c6ca0e3e69e2e3681c81d5a5ddd2dcd6f41b7522 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Sat, 24 Aug 2019 19:39:44 +0000 Subject: [PATCH] semantics.c (finish_switch_cond): Improve error message location. /cp 2019-08-24 Paolo Carlini * semantics.c (finish_switch_cond): Improve error message location. /testsuite 2019-08-24 Paolo Carlini * g++.dg/conversion/simd4.C: Test all the locations. From-SVN: r274901 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/semantics.c | 4 +++- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/conversion/simd4.C | 16 ++++++++-------- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 86d1849acc4..d0a8c7745a2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2019-08-24 Paolo Carlini + + * semantics.c (finish_switch_cond): Improve error message location. + 2019-08-22 Jason Merrill * decl2.c (decl_dependent_p): New. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 8aec4eff9b3..1f7745933f9 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1185,10 +1185,12 @@ finish_switch_cond (tree cond, tree switch_stmt) if (!processing_template_decl) { /* Convert the condition to an integer or enumeration type. */ + tree orig_cond = cond; cond = build_expr_type_conversion (WANT_INT | WANT_ENUM, cond, true); if (cond == NULL_TREE) { - error ("switch quantity not an integer"); + error_at (cp_expr_loc_or_input_loc (orig_cond), + "switch quantity not an integer"); cond = error_mark_node; } /* We want unlowered type here to handle enum bit-fields. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2162fcf40f4..af6fe82bfbf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-08-24 Paolo Carlini + + * g++.dg/conversion/simd4.C: Test all the locations. + 2019-08-23 Marek Polacek PR c++/91521 - wrong error with operator->. diff --git a/gcc/testsuite/g++.dg/conversion/simd4.C b/gcc/testsuite/g++.dg/conversion/simd4.C index 22274a17838..9d43b02db30 100644 --- a/gcc/testsuite/g++.dg/conversion/simd4.C +++ b/gcc/testsuite/g++.dg/conversion/simd4.C @@ -20,15 +20,15 @@ foo () v[b]; // { dg-error "4:invalid types" } w[b]; // { dg-error "4:invalid types" } new int[t]; - new int[u]; // { dg-error "new-declarator must have integral" } - new int[v]; // { dg-error "new-declarator must have integral" } - new int[w]; // { dg-error "new-declarator must have integral" } + new int[u]; // { dg-error "11:expression in new-declarator must have integral" } + new int[v]; // { dg-error "11:expression in new-declarator must have integral" } + new int[w]; // { dg-error "11:expression in new-declarator must have integral" } switch (t) { default: break; } - switch (u) { default: break; } // { dg-error "switch quantity not an integer" } - switch (v) { default: break; } // { dg-error "switch quantity not an integer" } - switch (w) { default: break; } // { dg-error "switch quantity not an integer" } + switch (u) { default: break; } // { dg-error "11:switch quantity not an integer" } + switch (v) { default: break; } // { dg-error "11:switch quantity not an integer" } + switch (w) { default: break; } // { dg-error "11:switch quantity not an integer" } t = ~t; - u = ~u; // { dg-error "wrong type argument to bit-complement" } + u = ~u; // { dg-error "8:wrong type argument to bit-complement" } v = ~v; - w = ~w; // { dg-error "wrong type argument to bit-complement" } + w = ~w; // { dg-error "8:wrong type argument to bit-complement" } } -- 2.30.2