Commit c6ca0e3e by Paolo Carlini Committed by Paolo Carlini

semantics.c (finish_switch_cond): Improve error message location.

/cp
2019-08-24  Paolo Carlini  <paolo.carlini@oracle.com>

	* semantics.c (finish_switch_cond): Improve error message location.

/testsuite
2019-08-24  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/conversion/simd4.C: Test all the locations.

From-SVN: r274901
parent 22b23ef2
2019-08-24 Paolo Carlini <paolo.carlini@oracle.com>
* semantics.c (finish_switch_cond): Improve error message location.
2019-08-22 Jason Merrill <jason@redhat.com>
* decl2.c (decl_dependent_p): New.
......
......@@ -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. */
......
2019-08-24 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/conversion/simd4.C: Test all the locations.
2019-08-23 Marek Polacek <polacek@redhat.com>
PR c++/91521 - wrong error with operator->.
......
......@@ -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" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment