aboutsummaryrefslogtreecommitdiff
path: root/contrib/unused_functions.py
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2023-08-25 17:55:58 -0400
committerMarek Polacek <polacek@redhat.com>2023-08-29 17:43:08 -0400
commit85ad41a494e31311f8a6b2dbe930a128c5e85840 (patch)
tree92a1d7720c2bf5c43a0217d5da60667faf37db4a /contrib/unused_functions.py
parentfce74ce2535aa3b7648ba82e7e61eb77d0175546 (diff)
downloadgcc-85ad41a494e31311f8a6b2dbe930a128c5e85840.zip
gcc-85ad41a494e31311f8a6b2dbe930a128c5e85840.tar.gz
gcc-85ad41a494e31311f8a6b2dbe930a128c5e85840.tar.bz2
c++: tweaks for explicit conversion fns diagnostic
1) When saying that a conversion is erroneous because it would use an explicit constructor, it might be nice to show where exactly the explicit constructor is located. For example, with this patch: [...] explicit.C:4:12: note: 'S::S(int)' declared here 4 | explicit S(int) { } | ^ 2) When a conversion doesn't work out merely because the conversion function necessary to do the conversion couldn't be used because it was marked explicit, it would be useful to the user to say so, rather than just saying "cannot convert". For example, with this patch: explicit.C:13:12: error: cannot convert 'S' to 'bool' in initialization 13 | bool b = S{1}; | ^~~~ | | | S explicit.C:5:12: note: explicit conversion function was not considered 5 | explicit operator bool() const { return true; } | ^~~~~~~~ gcc/cp/ChangeLog: * call.cc (convert_like_internal): Show where the conversion function was declared. (maybe_show_nonconverting_candidate): New. * cp-tree.h (maybe_show_nonconverting_candidate): Declare. * typeck.cc (convert_for_assignment): Call it. gcc/testsuite/ChangeLog: * g++.dg/diagnostic/explicit.C: New test.
Diffstat (limited to 'contrib/unused_functions.py')
0 files changed, 0 insertions, 0 deletions