This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] mostly unify readonly_error in C and C++ front-ends
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Nathan Froyd <froydnj at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 9 Dec 2010 15:38:18 -0600
- Subject: Re: [PATCH] mostly unify readonly_error in C and C++ front-ends
- References: <20101209203538.GP25904@nightcrawler>
On Thu, Dec 9, 2010 at 2:35 PM, Nathan Froyd <froydnj@codesourcery.com> wrote:
> This patch introduces a common readonly_error function that can be used
> by the C and C++ front-ends along with associated tweaks to make it work
> right. ?Notably, the C++-specific readonly_error_kind goes away,
> subsumed by lvalue_use, and the C++ readonly_error function is renamed
> to cp_readonly_error to handle a few C++-specific cases.
A nit: could you call it cxx_readonly_error instead?
> +#define READONLY_MSG(A, I, D, AS) (use == lv_assign ? (A) ? ? ? ? ? ? ?\
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?: (use == lv_increment ? (I) ? ? ? ? \
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?: (use == lv_decrement ? (D) : (AS))))
> + ?if (TREE_CODE (arg) == COMPONENT_REF)
> + ? ?{
> + ? ? ?if (TYPE_READONLY (TREE_TYPE (TREE_OPERAND (arg, 0))))
> + ? ? ? ?error (READONLY_MSG (G_("assignment of member "
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "%qD in read-only structure"),
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ?G_("increment of member "
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "%qD in read-only structure"),
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ?G_("decrement of member "
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "%qD in read-only structure"),
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ?G_("member %qD in read-only structure "
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "used as %<asm%> output")),
> + ? ? ? ? ? ? ?TREE_OPERAND (arg, 1));
I always thought the use of "structure" is a bit low-level view (from a C++
programmer point of view) and misleading -- what about readonly union?
I would suggest to use "read-only object" instead.
OK with that change (change adjust a couple of testsuite too..)
-- Gaby