https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87850
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by David Malcolm <dmalc...@gcc.gnu.org>: https://gcc.gnu.org/g:5336b63fe81029cfd790208fbc69a08c70b82b01 commit r15-5738-g5336b63fe81029cfd790208fbc69a08c70b82b01 Author: David Malcolm <dmalc...@redhat.com> Date: Wed Nov 27 19:21:15 2024 -0500 C/C++: add fix-it hints for missing '&' and '*' (v5) [PR87850] This patch adds a note with a fix-it hint to various pointer-vs-non-pointer diagnostics, suggesting the addition of a leading '&' or '*'. For example, note the ampersand fix-it hint in the following: demo.c: In function 'int main()': demo.c:5:22: error: invalid conversion from 'pthread_key_t' {aka 'unsigned int'} to 'pthread_key_t*' {aka 'unsigned int*'} [-fpermissive] 5 | pthread_key_create(key, NULL); | ^~~ | | | pthread_key_t {aka unsigned int} demo.c:5:22: note: possible fix: take the address with '&' 5 | pthread_key_create(key, NULL); | ^~~ | & In file included from demo.c:1: /usr/include/pthread.h:1122:47: note: initializing argument 1 of 'int pthread_key_create(pthread_key_t*, void (*)(void*))' 1122 | extern int pthread_key_create (pthread_key_t *__key, | ~~~~~~~~~~~~~~~^~~~~ gcc/c-family/ChangeLog: PR c++/87850 * c-common.cc: Include "gcc-rich-location.h". (maybe_emit_indirection_note): New function. * c-common.h (maybe_emit_indirection_note): New decl. (compatible_types_for_indirection_note_p): New decl. gcc/c/ChangeLog: PR c++/87850 * c-typeck.cc (compatible_types_for_indirection_note_p): New function. (convert_for_assignment): Call maybe_emit_indirection_note for pointer vs non-pointer diagnostics. gcc/cp/ChangeLog: PR c++/87850 * call.cc (convert_like_real): Call maybe_emit_indirection_note for "invalid conversion" diagnostic. * typeck.cc (compatible_types_for_indirection_note_p): New function. gcc/testsuite/ChangeLog: PR c++/87850 * c-c++-common/indirection-fixits.c: New test. * g++.dg/template/error60.C: Add fix-it hint to expected output. * g++.dg/template/error60a.C: Likewise. Signed-off-by: David Malcolm <dmalc...@redhat.com>