2018-08-27 David Malcolm <dmalcolm@redhat.com>
- PR 87091
+ PR c++/87091
* diagnostic-show-locus.c (class layout_range): Update for
conversion of show_caret_p to a tri-state.
(layout_range::layout_range): Likewise.
2018-08-27 David Malcolm <dmalcolm@redhat.com>
- PR 87091
+ PR c++/87091
* diagnostic-show-locus.c (get_line_span_for_fixit_hint): Show the
line above for line-insertion fix-it hints.
(selftest::test_fixit_insert_containing_newline): Update the
2018-08-24 David Malcolm <dmalcolm@redhat.com>
- PR 87091
+ PR c++/87091
* diagnostic-show-locus.c (layout::layout): Ensure the margin is
wide enough for jumps in the line-numbering to be visible.
(layout::print_gap_in_line_numbering): New member function.
+2018-08-27 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/86993
+ * cp-tree.h (cxx_readonly_error): Add location_t argument.
+ * typeck2.c (cxx_readonly_error): Add LOC argument, pass it to
+ ERROR_FOR_ASSIGNMENT macro and readonly_error. Add LOC argument
+ to ERROR_FOR_ASSIGNMENT macro, use error_at instead of error and
+ pass LOC to it. Formatting fixes.
+ * typeck.c (cp_build_unary_op): Pass location to cxx_readonly_error.
+ (cp_build_modify_expr): Pass loc to cxx_readonly_error.
+ * semantics.c (finish_asm_stmt): Pass input_location to
+ cxx_readonly_error.
+
2018-08-27 David Malcolm <dmalcolm@redhat.com>
- PR 87091
+ PR c++/87091
* decl.c (grokdeclarator): Update for conversion of show_caret_p
to a tri-state.
* error.c (cp_printer): Likewise.
extern void cxx_incomplete_type_inform (const_tree);
extern tree error_not_base_type (tree, tree);
extern tree binfo_or_else (tree, tree);
-extern void cxx_readonly_error (tree, enum lvalue_use);
+extern void cxx_readonly_error (location_t, tree,
+ enum lvalue_use);
extern void complete_type_check_abstract (tree);
extern int abstract_virtuals_error (tree, tree);
extern int abstract_virtuals_error (abstract_class_use, tree);
effectively const. */
|| (CLASS_TYPE_P (TREE_TYPE (operand))
&& C_TYPE_FIELDS_READONLY (TREE_TYPE (operand)))))
- cxx_readonly_error (operand, lv_asm);
+ cxx_readonly_error (input_location, operand, lv_asm);
tree *op = &operand;
while (TREE_CODE (*op) == COMPOUND_EXPR)
|| TREE_READONLY (arg))
{
if (complain & tf_error)
- cxx_readonly_error (arg, ((code == PREINCREMENT_EXPR
- || code == POSTINCREMENT_EXPR)
- ? lv_increment : lv_decrement));
+ cxx_readonly_error (location, arg,
+ ((code == PREINCREMENT_EXPR
+ || code == POSTINCREMENT_EXPR)
+ ? lv_increment : lv_decrement));
else
return error_mark_node;
}
&& C_TYPE_FIELDS_READONLY (lhstype))))
{
if (complain & tf_error)
- cxx_readonly_error (lhs, lv_assign);
+ cxx_readonly_error (loc, lhs, lv_assign);
return error_mark_node;
}
value may not be changed thereafter. */
void
-cxx_readonly_error (tree arg, enum lvalue_use errstring)
+cxx_readonly_error (location_t loc, tree arg, enum lvalue_use errstring)
{
/* This macro is used to emit diagnostics to ensure that all format
strings are complete sentences, visible to gettext and checked at
compile time. */
-#define ERROR_FOR_ASSIGNMENT(AS, ASM, IN, DE, ARG) \
+#define ERROR_FOR_ASSIGNMENT(LOC, AS, ASM, IN, DE, ARG) \
do { \
switch (errstring) \
{ \
case lv_assign: \
- error(AS, ARG); \
+ error_at (LOC, AS, ARG); \
break; \
case lv_asm: \
- error(ASM, ARG); \
+ error_at (LOC, ASM, ARG); \
break; \
case lv_increment: \
- error (IN, ARG); \
+ error_at (LOC, IN, ARG); \
break; \
- case lv_decrement: \
- error (DE, ARG); \
+ case lv_decrement: \
+ error_at (LOC, DE, ARG); \
break; \
default: \
gcc_unreachable (); \
&& DECL_LANG_SPECIFIC (arg)
&& DECL_IN_AGGR_P (arg)
&& !TREE_STATIC (arg))
- ERROR_FOR_ASSIGNMENT (G_("assignment of "
- "constant field %qD"),
- G_("constant field %qD "
- "used as %<asm%> output"),
- G_("increment of "
- "constant field %qD"),
- G_("decrement of "
- "constant field %qD"),
+ ERROR_FOR_ASSIGNMENT (loc,
+ G_("assignment of constant field %qD"),
+ G_("constant field %qD used as %<asm%> output"),
+ G_("increment of constant field %qD"),
+ G_("decrement of constant field %qD"),
arg);
else if (INDIRECT_REF_P (arg)
&& TYPE_REF_P (TREE_TYPE (TREE_OPERAND (arg, 0)))
&& (VAR_P (TREE_OPERAND (arg, 0))
|| TREE_CODE (TREE_OPERAND (arg, 0)) == PARM_DECL))
- ERROR_FOR_ASSIGNMENT (G_("assignment of "
- "read-only reference %qD"),
- G_("read-only reference %qD "
- "used as %<asm%> output"),
- G_("increment of "
- "read-only reference %qD"),
- G_("decrement of "
- "read-only reference %qD"),
- TREE_OPERAND (arg, 0));
+ ERROR_FOR_ASSIGNMENT (loc,
+ G_("assignment of read-only reference %qD"),
+ G_("read-only reference %qD used as %<asm%> output"),
+ G_("increment of read-only reference %qD"),
+ G_("decrement of read-only reference %qD"),
+ TREE_OPERAND (arg, 0));
else
- readonly_error (input_location, arg, errstring);
+ readonly_error (loc, arg, errstring);
}
-
\f
/* Structure that holds information about declarations whose type was
incomplete and we could not check whether it was abstract or not. */
+2018-08-27 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/86993
+ * g++.dg/diagnostic/pr86993.C: New test.
+
2018-08-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/86927
2018-08-27 David Malcolm <dmalcolm@redhat.com>
- PR 87091
+ PR c++/87091
* gcc.dg/empty.h: New file.
* gcc.dg/fixits-pr84852-1.c: Update for move of fix-it hint to
top of file and removal of redundant second printing of warning
2018-08-27 David Malcolm <dmalcolm@redhat.com>
- PR 87091
+ PR c++/87091
* g++.dg/pr85523.C: Extend expected output to show line
before line-insertion fix-it hint.
* gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c
2018-08-24 David Malcolm <dmalcolm@redhat.com>
- PR 87091
+ PR c++/87091
* gcc.dg/missing-header-fixit-3.c: Update for changes to how
line spans are printed with -fdiagnostics-show-line-numbers.
--- /dev/null
+// PR c++/86993
+// { dg-options "-fdiagnostics-show-caret" }
+
+int
+main ()
+{
+ const int i = 5; // { dg-error "assignment of read-only variable 'i'" "" { target *-*-* } .+1 }
+ i = 5 + 6;
+/* { dg-begin-multiline-output "" }
+ i = 5 + 6;
+ ~~^~~~~~~
+ { dg-end-multiline-output "" } */
+}