aboutsummaryrefslogtreecommitdiff
path: root/gcc/objc/objc-act.c
diff options
context:
space:
mode:
authorZack Weinberg <zackw@stanford.edu>2001-03-02 00:40:00 +0000
committerZack Weinberg <zack@gcc.gnu.org>2001-03-02 00:40:00 +0000
commit71b7be38c3f1d50ca004b3aa1c21e206d595c67f (patch)
treeb9429823f84096cf8932b11e6e31c6dd708dab5d /gcc/objc/objc-act.c
parent5aa709ad7e1cb28ae54dea521a5ca6cbf1fe6016 (diff)
downloadgcc-71b7be38c3f1d50ca004b3aa1c21e206d595c67f.zip
gcc-71b7be38c3f1d50ca004b3aa1c21e206d595c67f.tar.gz
gcc-71b7be38c3f1d50ca004b3aa1c21e206d595c67f.tar.bz2
stringpool.c (set_identifier): New function.
* stringpool.c (set_identifier): New function. * tree.h: Prototype it. * c-parse.in: Kill D_YES. If compiled for objc, call save_and_forget_protocol_qualifiers from init_reswords. * objc/objc-act.c (remember_protocol_qualifiers, forget_protocol_qualifiers): Don't diddle C_IS_RESERVED_WORD. Swap out the non-keyword IDENTIFIER_NODEs for keyword ones, or vice versa. (save_and_forget_protocol_qualifiers): New function. * c-lex.h: Prototype save_and_forget_protocol_qualifiers. From-SVN: r40170
Diffstat (limited to 'gcc/objc/objc-act.c')
-rw-r--r--gcc/objc/objc-act.c46
1 files changed, 33 insertions, 13 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 8da5c6b..f5f27ad 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -8590,25 +8590,45 @@ lookup_objc_ivar (id)
return 0;
}
-/* Parser callbacks. */
+/* Parser callbacks.
+ Some ObjC keywords are reserved only in a particular context:
+ in out inout bycopy byref oneway.
+ We have to save and restore the IDENTIFIER_NODEs that describe
+ them as keywords, when appropriate. */
+
+#define N_PQ 6
+static tree saved_pq[N_PQ];
+static tree saved_not_pq[N_PQ];
+static const char *const pq_strings[N_PQ] = {
+ "bycopy", "byref", "in", "inout", "oneway", "out"
+};
+
+void
+save_and_forget_protocol_qualifiers ()
+{
+ int i;
+ for (i = 0; i < N_PQ; i++)
+ saved_pq[i] = set_identifier (pq_strings[i], NULL_TREE);
+
+ ggc_add_tree_root (saved_pq, N_PQ);
+ ggc_add_tree_root (saved_not_pq, N_PQ);
+}
+
void
forget_protocol_qualifiers ()
{
- C_IS_RESERVED_WORD (ridpointers[(int) RID_IN]) = 0;
- C_IS_RESERVED_WORD (ridpointers[(int) RID_OUT]) = 0;
- C_IS_RESERVED_WORD (ridpointers[(int) RID_INOUT]) = 0;
- C_IS_RESERVED_WORD (ridpointers[(int) RID_BYCOPY]) = 0;
- C_IS_RESERVED_WORD (ridpointers[(int) RID_BYREF]) = 0;
- C_IS_RESERVED_WORD (ridpointers[(int) RID_ONEWAY]) = 0;
+ int i;
+ for (i = 0; i < N_PQ; i++)
+ {
+ set_identifier (pq_strings[i], saved_not_pq[i]);
+ saved_not_pq[i] = NULL_TREE;
+ }
}
void
remember_protocol_qualifiers ()
{
- C_IS_RESERVED_WORD (ridpointers[(int) RID_IN]) = 1;
- C_IS_RESERVED_WORD (ridpointers[(int) RID_OUT]) = 1;
- C_IS_RESERVED_WORD (ridpointers[(int) RID_INOUT]) = 1;
- C_IS_RESERVED_WORD (ridpointers[(int) RID_BYCOPY]) = 1;
- C_IS_RESERVED_WORD (ridpointers[(int) RID_BYREF]) = 1;
- C_IS_RESERVED_WORD (ridpointers[(int) RID_ONEWAY]) = 1;
+ int i;
+ for (i = 0; i < N_PQ; i++)
+ saved_not_pq[i] = set_identifier (pq_strings[i], saved_pq[i]);
}