diff options
author | Martin Liska <mliska@suse.cz> | 2022-08-08 09:05:36 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2022-08-08 09:05:36 +0200 |
commit | b3a187edd33b89acf19ba46f3b8070d7c977ac57 (patch) | |
tree | 43549f6851052eb2844ea76358af30a9fd302ec5 /gcc/c | |
parent | 89eca196c99645ee1abefcf8b4a9dd84edd87ad6 (diff) | |
parent | 2633c8d8f338f1e2b53d3757f3edf4179bfcc218 (diff) | |
download | gcc-b3a187edd33b89acf19ba46f3b8070d7c977ac57.zip gcc-b3a187edd33b89acf19ba46f3b8070d7c977ac57.tar.gz gcc-b3a187edd33b89acf19ba46f3b8070d7c977ac57.tar.bz2 |
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c/c-typeck.cc | 27 |
2 files changed, 26 insertions, 8 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 3aa672b..cffb462 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,10 @@ +2022-08-01 David Malcolm <dmalcolm@redhat.com> + + * c-typeck.cc (build_c_cast): Quote names of address spaces in + diagnostics. + (convert_for_assignment): Add a note to address space mismatch + diagnostics, specifying the expected and actual types. + 2022-07-10 Lewis Hyatt <lhyatt@gmail.com> PR preprocessor/97498 diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index fd0a7f8..8514488 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -6032,18 +6032,18 @@ build_c_cast (location_t loc, tree type, tree expr) if (!addr_space_superset (as_to, as_from, &as_common)) { if (ADDR_SPACE_GENERIC_P (as_from)) - warning_at (loc, 0, "cast to %s address space pointer " + warning_at (loc, 0, "cast to %qs address space pointer " "from disjoint generic address space pointer", c_addr_space_name (as_to)); else if (ADDR_SPACE_GENERIC_P (as_to)) warning_at (loc, 0, "cast to generic address space pointer " - "from disjoint %s address space pointer", + "from disjoint %qs address space pointer", c_addr_space_name (as_from)); else - warning_at (loc, 0, "cast to %s address space pointer " - "from disjoint %s address space pointer", + warning_at (loc, 0, "cast to %qs address space pointer " + "from disjoint %qs address space pointer", c_addr_space_name (as_to), c_addr_space_name (as_from)); } @@ -7252,6 +7252,8 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, if (!null_pointer_constant_p (rhs) && asr != asl && !targetm.addr_space.subset_p (asr, asl)) { + auto_diagnostic_group d; + bool diagnosed = true; switch (errtype) { case ic_argpass: @@ -7259,7 +7261,8 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, const char msg[] = G_("passing argument %d of %qE from " "pointer to non-enclosed address space"); if (warnopt) - warning_at (expr_loc, warnopt, msg, parmnum, rname); + diagnosed + = warning_at (expr_loc, warnopt, msg, parmnum, rname); else error_at (expr_loc, msg, parmnum, rname); break; @@ -7269,7 +7272,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, const char msg[] = G_("assignment from pointer to " "non-enclosed address space"); if (warnopt) - warning_at (location, warnopt, msg); + diagnosed = warning_at (location, warnopt, msg); else error_at (location, msg); break; @@ -7280,7 +7283,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, const char msg[] = G_("initialization from pointer to " "non-enclosed address space"); if (warnopt) - warning_at (location, warnopt, msg); + diagnosed = warning_at (location, warnopt, msg); else error_at (location, msg); break; @@ -7290,7 +7293,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, const char msg[] = G_("return from pointer to " "non-enclosed address space"); if (warnopt) - warning_at (location, warnopt, msg); + diagnosed = warning_at (location, warnopt, msg); else error_at (location, msg); break; @@ -7298,6 +7301,14 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, default: gcc_unreachable (); } + if (diagnosed) + { + if (errtype == ic_argpass) + inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); + else + inform (location, "expected %qT but pointer is of type %qT", + type, rhstype); + } return error_mark_node; } |