This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Why we can't have nice discarding const warnings
- To: gcc at gcc dot gnu dot org
- Subject: Why we can't have nice discarding const warnings
- From: Zack Weinberg <zack at bitmover dot com>
- Date: Wed, 01 Sep 1999 18:24:33 -0700
After considerable staring, I've concluded there is no clean way to do
detailed warnings for assignments that discard qualifiers.
All of these warnings are in c-typeck.c and go through
warn_for_assignment. warn_for_assignment is a helper function
which inserts "assignment" or "passing arg N of function BLEAH" into
a call to pedwarn. It is _not_ printflike, you can only have one %s
in the pedwarn format string, and it gets used for
"assignment"/"passing...".
To be able to tell the user which qualifiers they discarded, we must
make warning_for_assignment printflike. Unfortunately, there are
several bars to that:
vpedwarn is not exported from toplev.c. Actually, none of the
verror functions are.
warn_for_assignment can't be moved to toplev.c because it calls
maybe_building_objc_message_expr which is not always available. (Is
it just me, or are the C and ObjC front ends way too tightly coupled?)
A hypothetical varargs warn_for_assignment would have to print
"assignment" or whatever separately from the pedwarn, because you
can't add to a va_list. But some of the messages fed to
warn_for_assignment want "assignment" printed in the _middle_ of the
string, not at the beginning. At least one of them can't be easily
reworded.
Maybe there's a way to get around this but I don't see it.
zw