This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] mostly unify readonly_error in C and C++ front-ends


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]