summaryrefslogtreecommitdiffstats
path: root/gcc/c-typeck.c
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-21 02:22:08 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-21 02:22:08 +0000
commite35976b114cde73f3131da32a9bbbc6da1b13eb8 (patch)
tree4f046755cca3d6be85f4cf05610ef5313e865404 /gcc/c-typeck.c
parentb859c0f1ddca305e49affed122053aad04f8728d (diff)
downloadppe42-gcc-e35976b114cde73f3131da32a9bbbc6da1b13eb8.tar.gz
ppe42-gcc-e35976b114cde73f3131da32a9bbbc6da1b13eb8.zip
* c-common.c (lvalue_or_else): Replace by lvalue_error; only give
diagnostic without checking whether an lvalue. * c-common.h (lvalue_p): Remove. (enum lvalue_use): Update comment. (lvalue_or_else): Replace by lvalue_error. * c-typeck.c (lvalue_p): Make static. (lvalue_or_else): New. Call lvalue_error. cp: * cp-tree.h (lvalue_or_else, lvalue_p): New. * typeck.c (lvalue_or_else): New. Call lvalue_error. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96776 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r--gcc/c-typeck.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 0595b88b877..d5046d5f425 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -100,6 +100,8 @@ static void set_nonincremental_init (void);
static void set_nonincremental_init_from_string (tree);
static tree find_init_member (tree);
static void readonly_error (tree, enum lvalue_use);
+static int lvalue_or_else (tree, enum lvalue_use);
+static int lvalue_p (tree);
static void record_maybe_used_decl (tree);
/* Do `exp = require_complete_type (exp);' to make sure exp
@@ -2742,7 +2744,7 @@ build_unary_op (enum tree_code code, tree xarg, int flag)
Lvalues can be assigned, unless their type has TYPE_READONLY.
Lvalues can have their address taken, unless they have C_DECL_REGISTER. */
-int
+static int
lvalue_p (tree ref)
{
enum tree_code code = TREE_CODE (ref);
@@ -2807,6 +2809,22 @@ readonly_error (tree arg, enum lvalue_use use)
N_("increment of read-only location"),
N_("decrement of read-only location")));
}
+
+
+/* Return nonzero if REF is an lvalue valid for this language;
+ otherwise, print an error message and return zero. USE says
+ how the lvalue is being used and so selects the error message. */
+
+static int
+lvalue_or_else (tree ref, enum lvalue_use use)
+{
+ int win = lvalue_p (ref);
+
+ if (!win)
+ lvalue_error (use);
+
+ return win;
+}
/* Mark EXP saying that we need to be able to take the
address of it; it should not be allocated in a register.
OpenPOWER on IntegriCloud