summaryrefslogtreecommitdiffstats
path: root/gcc/c-typeck.c
diff options
context:
space:
mode:
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