This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Remove iterators
- To: gcc-patches at gcc dot gnu dot org
- Subject: PATCH: Remove iterators
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Thu, 24 Aug 2000 17:58:55 -0700
- Organization: CodeSourcery, LLC
After some discussion, the steering committee decided to remove the
(never-documented) iterators extension to C. This patch is the
implementation of that decision.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2000-08-24 Mark Mitchell <mark@codesourcery.com>
* Makefile.in (C_AND_OBJC_OBJS): Remove c-iterate.o.
(c-iterate.o): Remove target.
* gcc/c-common.h (enum rid): Remove RID_ITERATOR.
* gcc/c-decl.c (init_decl_processing): Remove call to init_iterators.
(finish_decl): Don't handle iterators.
(grokdeclarator): Likewise.
* gcc/c-parse.gperf: Remove __iterator and __iterator__ keywords.
* gcc/c-gperf.h: Regenerated.
* gcc/c-iterate.c: Removed.
* gcc/c-lex.c (init_lex): Don't handle iterators.
* gcc/c-parse.in (primary): Remove pop_iterator_stack call.
(compstmt_primary_start): Remove push_iterator_stack call.
(stmt): Don't allow iterator statements. Replace iterator_expand
with expand_expr_stmt.
(all_iter_stmt): Remove.
(all_iter_stmt_simple): Likewise.
(all_iter_stmt_with_decl): Likewise.
* gcc/c-tree.h (ITERATOR_P): Remove.
(ITERATOR_BOUND_P): Likewise.
(init_iterators): Remove declaration.
(iterator_expand): Likewise.
(iterator_for_loop_start): Likewise.
(iterator_for_loop_end): Likewise.
(iterator_for_loop_record): Likewise.
(push_iterator_stack): Likewise.
(pop_iterator_stack): Likewise.
* gcc/c-typeck.c (decl_constant_value): Don't check ITERATOR_P.
(readonly_warning): Likewise.
* gcc/tree.h (ITERATOR_BOUND_P): Don't mention it.
2000-08-24 Mark Mitchell <mark@codesourcery.com>
* Make-lang.in (cc1chill): Don't depend on c-iterate.o.
2000-08-24 Mark Mitchell <mark@codesourcery.com>
* gcc.dg/noncompile/930622-2.c: Adjust error message.
Index: gcc/Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/Makefile.in,v
retrieving revision 1.497
diff -c -p -r1.497 Makefile.in
*** Makefile.in 2000/08/23 22:35:13 1.497
--- Makefile.in 2000/08/25 00:41:38
*************** LANG_FLAGS_TO_PASS = $(SUBDIR_FLAGS_TO_P
*** 678,684 ****
# Language-specific object files for C and Objective C.
C_AND_OBJC_OBJS = c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o \
! c-convert.o c-aux-info.o c-common.o c-iterate.o c-semantics.o @extra_c_objs@
# Language-specific object files for C.
C_OBJS = c-parse.o c-lang.o $(C_AND_OBJC_OBJS)
--- 678,684 ----
# Language-specific object files for C and Objective C.
C_AND_OBJC_OBJS = c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o \
! c-convert.o c-aux-info.o c-common.o c-semantics.o @extra_c_objs@
# Language-specific object files for C.
C_OBJS = c-parse.o c-lang.o $(C_AND_OBJC_OBJS)
*************** c-aux-info.o : c-aux-info.c $(CONFIG_H)
*** 1111,1118 ****
c-convert.o : c-convert.c $(CONFIG_H) system.h $(TREE_H) flags.h toplev.h
c-pragma.o: c-pragma.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) function.h \
defaults.h c-pragma.h toplev.h $(GGC_H)
- c-iterate.o: c-iterate.c $(CONFIG_H) system.h $(TREE_H) $(RTL_H) c-tree.h \
- c-common.h flags.h toplev.h $(EXPR_H)
mbchar.o: mbchar.c $(CONFIG_H) system.h mbchar.h
graph.o: graph.c $(CONFIG_H) system.h toplev.h flags.h output.h $(RTL_H) \
function.h hard-reg-set.h $(BASIC_BLOCK_H) graph.h
--- 1111,1116 ----
Index: gcc/c-common.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-common.h,v
retrieving revision 1.29
diff -c -p -r1.29 c-common.h
*** c-common.h 2000/08/21 14:30:37 1.29
--- c-common.h 2000/08/25 00:41:38
*************** enum rid
*** 64,70 ****
RID_BOUNDED,
RID_UNBOUNDED,
RID_NOALIAS,
- RID_ITERATOR,
RID_COMPLEX,
RID_IN,
--- 64,69 ----
Index: gcc/c-decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-decl.c,v
retrieving revision 1.145
diff -c -p -r1.145 c-decl.c
*** c-decl.c 2000/08/24 20:09:27 1.145
--- c-decl.c 2000/08/25 00:41:42
*************** init_decl_processing ()
*** 3199,3206 ****
/* Prepare to check format strings against argument lists. */
init_function_format_info ();
- init_iterators ();
-
incomplete_decl_finalize_hook = finish_incomplete_decl;
/* Record our roots. */
--- 3199,3204 ----
*************** finish_decl (decl, init, asmspec_tree)
*** 3580,3593 ****
if (TREE_CODE (decl) == PARM_DECL)
init = 0;
- if (ITERATOR_P (decl))
- {
- if (init == 0)
- error_with_decl (decl, "iterator has no initial value");
- else
- init = save_expr (init);
- }
-
if (init)
{
if (TREE_CODE (decl) != TYPE_DECL)
--- 3578,3583 ----
*************** grokdeclarator (declarator, declspecs, d
*** 4254,4260 ****
if (specbits & 1 << (int) RID_EXTERN) nclasses++;
if (specbits & 1 << (int) RID_REGISTER) nclasses++;
if (specbits & 1 << (int) RID_TYPEDEF) nclasses++;
- if (specbits & 1 << (int) RID_ITERATOR) nclasses++;
/* Warn about storage classes that are invalid for certain
kinds of declarations (parameters, typenames, etc.). */
--- 4244,4249 ----
*************** grokdeclarator (declarator, declspecs, d
*** 4315,4332 ****
else if (current_binding_level == global_binding_level
&& specbits & (1 << (int) RID_AUTO))
error ("top-level declaration of `%s' specifies `auto'", name);
- else if ((specbits & 1 << (int) RID_ITERATOR)
- && TREE_CODE (declarator) != IDENTIFIER_NODE)
- {
- error ("iterator `%s' has derived type", name);
- type = error_mark_node;
- }
- else if ((specbits & 1 << (int) RID_ITERATOR)
- && TREE_CODE (type) != INTEGER_TYPE)
- {
- error ("iterator `%s' has noninteger type", name);
- type = error_mark_node;
- }
}
/* Now figure out the structure of the declarator proper.
--- 4304,4309 ----
*************** grokdeclarator (declarator, declspecs, d
*** 4879,4887 ****
TREE_STATIC (decl) = (specbits & (1 << (int) RID_STATIC)) != 0;
TREE_PUBLIC (decl) = DECL_EXTERNAL (decl);
}
-
- if (specbits & 1 << (int) RID_ITERATOR)
- ITERATOR_P (decl) = 1;
}
/* Record `register' declaration for warnings on &
--- 4856,4861 ----
Index: gcc/c-gperf.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-gperf.h,v
retrieving revision 1.13
diff -c -p -r1.13 c-gperf.h
*** c-gperf.h 2000/03/16 04:25:12 1.13
--- c-gperf.h 2000/08/25 00:41:42
***************
*** 1,5 ****
/* C code produced by gperf version 2.7.1 (19981006 egcs) */
! /* Command-line: gperf -L C -F , 0, 0 -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$ /work/src/gcc/gcc/c-parse.gperf */
/* Command-line: gperf -L C -F ', 0, 0' -p -j1 -i 1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf */
struct resword { const char *name; short token; enum rid rid; };
#ifdef __GNUC__
--- 1,5 ----
/* C code produced by gperf version 2.7.1 (19981006 egcs) */
! /* Command-line: gperf -L C -F , 0, 0 -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$ ../../gcc/c-parse.gperf */
/* Command-line: gperf -L C -F ', 0, 0' -p -j1 -i 1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf */
struct resword { const char *name; short token; enum rid rid; };
#ifdef __GNUC__
*************** __inline
*** 11,22 ****
#endif
struct resword *is_reserved_word PARAMS ((const char *, unsigned int));
! #define TOTAL_KEYWORDS 94
#define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 20
! #define MIN_HASH_VALUE 4
! #define MAX_HASH_VALUE 249
! /* maximum key range = 246, duplicates = 0 */
#ifdef __GNUC__
__inline
--- 11,22 ----
#endif
struct resword *is_reserved_word PARAMS ((const char *, unsigned int));
! #define TOTAL_KEYWORDS 92
#define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 20
! #define MIN_HASH_VALUE 17
! #define MAX_HASH_VALUE 301
! /* maximum key range = 285, duplicates = 0 */
#ifdef __GNUC__
__inline
*************** hash (str, len)
*** 26,59 ****
register const char *str;
register unsigned int len;
{
! static unsigned char asso_values[] =
{
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 11, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 1, 250, 78, 38, 61,
! 1, 37, 47, 70, 1, 13, 250, 4, 94, 37,
! 81, 1, 100, 250, 19, 8, 25, 4, 50, 1,
! 2, 1, 2, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
! 250, 250, 250, 250, 250, 250
};
register int hval = len;
--- 26,59 ----
register const char *str;
register unsigned int len;
{
! static unsigned short asso_values[] =
{
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 113, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 1, 302, 78, 52, 111,
! 34, 9, 46, 59, 1, 20, 302, 1, 118, 17,
! 18, 39, 58, 302, 7, 6, 33, 70, 21, 2,
! 5, 1, 1, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
! 302, 302, 302, 302, 302, 302
};
register int hval = len;
*************** hash (str, len)
*** 72,221 ****
static struct resword wordlist[] =
{
- {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
- {"do", DO, NORID},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"", 0, 0}, {"", 0, 0},
! {"id", OBJECTNAME, RID_ID},
! {"__unbounded", TYPE_QUAL, RID_UNBOUNDED},
! {"__signed", TYPESPEC, RID_SIGNED},
! {"__unbounded__", TYPE_QUAL, RID_UNBOUNDED},
{"__signed__", TYPESPEC, RID_SIGNED},
! {"unsigned", TYPESPEC, RID_UNSIGNED},
{"", 0, 0},
{"__imag__", IMAGPART, NORID},
{"", 0, 0},
{"__inline__", SCSPEC, RID_INLINE},
- {"", 0, 0},
- {"__iterator__", SCSPEC, RID_ITERATOR},
{"switch", SWITCH, NORID},
- {"__real__", REALPART, NORID},
- {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
- {"__restrict__", TYPE_QUAL, RID_RESTRICT},
- {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
- {"__typeof__", TYPEOF, NORID},
{"", 0, 0},
! {"short", TYPESPEC, RID_SHORT},
! {"@compatibility_alias", ALIAS, NORID},
! {"@protected", PROTECTED, NORID},
{"", 0, 0},
! {"__iterator", SCSPEC, RID_ITERATOR},
! {"inout", TYPE_QUAL, RID_INOUT},
! {"oneway", TYPE_QUAL, RID_ONEWAY},
! {"", 0, 0}, {"", 0, 0},
! {"double", TYPESPEC, RID_DOUBLE},
! {"__bounded", TYPE_QUAL, RID_BOUNDED},
{"", 0, 0},
! {"__bounded__", TYPE_QUAL, RID_BOUNDED},
! {"__extension__", EXTENSION, NORID},
{"", 0, 0},
- {"out", TYPE_QUAL, RID_OUT},
{"__restrict", TYPE_QUAL, RID_RESTRICT},
- {"while", WHILE, NORID},
- {"", 0, 0},
{"struct", STRUCT, NORID},
! {"__inline", SCSPEC, RID_INLINE},
{"restrict", TYPE_QUAL, RID_RESTRICT},
! {"@defs", DEFS, NORID},
! {"if", IF, NORID},
{"sizeof", SIZEOF, NORID},
! {"__volatile__", TYPE_QUAL, RID_VOLATILE},
{"", 0, 0},
! {"int", TYPESPEC, RID_INT},
{"", 0, 0},
{"void", TYPESPEC, RID_VOID},
- {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
- {"__const__", TYPE_QUAL, RID_CONST},
- {"__complex", TYPESPEC, RID_COMPLEX},
- {"__complex__", TYPESPEC, RID_COMPLEX},
- {"@private", PRIVATE, NORID},
- {"@selector", SELECTOR, NORID},
{"", 0, 0},
! {"float", TYPESPEC, RID_FLOAT},
{"", 0, 0},
! {"default", DEFAULT, NORID},
! {"__typeof", TYPEOF, NORID},
! {"enum", ENUM, NORID},
! {"@public", PUBLIC, NORID},
! {"break", BREAK, NORID},
! {"signed", TYPESPEC, RID_SIGNED},
! {"else", ELSE, NORID},
! {"__asm__", ASM_KEYWORD, NORID},
! {"for", FOR, NORID},
{"", 0, 0},
{"__imag", IMAGPART, NORID},
{"__alignof__", ALIGNOF, NORID},
{"", 0, 0},
{"__attribute__", ATTRIBUTE, NORID},
! {"__const", TYPE_QUAL, RID_CONST},
{"", 0, 0},
! {"in", TYPE_QUAL, RID_IN},
! {"@end", END, NORID},
! {"__volatile", TYPE_QUAL, RID_VOLATILE},
{"", 0, 0},
! {"goto", GOTO, NORID},
! {"", 0, 0}, {"", 0, 0},
! {"union", UNION, NORID},
{"", 0, 0},
! {"__label__", LABEL, NORID},
! {"bycopy", TYPE_QUAL, RID_BYCOPY},
{"", 0, 0},
- {"auto", SCSPEC, RID_AUTO},
{"byref", TYPE_QUAL, RID_BYREF},
- {"case", CASE, NORID},
- {"", 0, 0}, {"", 0, 0},
- {"__ptrbase__", PTR_BASE, NORID},
- {"__ptrvalue__", PTR_VALUE, NORID},
- {"__ptrextent__", PTR_EXTENT, NORID},
- {"register", SCSPEC, RID_REGISTER},
{"", 0, 0}, {"", 0, 0},
! {"@class", CLASS, NORID},
! {"__real", REALPART, NORID},
! {"__asm", ASM_KEYWORD, NORID},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"__builtin_va_arg", VA_ARG, NORID},
{"", 0, 0},
! {"__attribute", ATTRIBUTE, NORID},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"return", RETURN, NORID},
{"", 0, 0},
! {"@protocol", PROTOCOL, NORID},
{"", 0, 0},
{"__alignof", ALIGNOF, NORID},
! {"@encode", ENCODE, NORID},
! {"__ptrextent", PTR_EXTENT, NORID},
{"", 0, 0},
! {"@interface", INTERFACE, NORID},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"@implementation", IMPLEMENTATION, NORID},
{"", 0, 0}, {"", 0, 0},
! {"__ptrbase", PTR_BASE, NORID},
! {"__ptrvalue", PTR_VALUE, NORID},
! {"extern", SCSPEC, RID_EXTERN},
{"inline", SCSPEC, RID_INLINE},
! {"", 0, 0}, {"", 0, 0},
! {"static", SCSPEC, RID_STATIC},
{"", 0, 0},
! {"asm", ASM_KEYWORD, NORID},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"char", TYPESPEC, RID_CHAR},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
{"const", TYPE_QUAL, RID_CONST},
- {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
- {"typeof", TYPEOF, NORID},
- {"typedef", SCSPEC, RID_TYPEDEF},
- {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
- {"continue", CONTINUE, NORID},
{"", 0, 0},
! {"volatile", TYPE_QUAL, RID_VOLATILE},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"long", TYPESPEC, RID_LONG}
};
#ifdef __GNUC__
--- 72,231 ----
static struct resword wordlist[] =
{
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"__real__", REALPART, NORID},
{"__signed__", TYPESPEC, RID_SIGNED},
! {"", 0, 0}, {"", 0, 0},
! {"__restrict__", TYPE_QUAL, RID_RESTRICT},
! {"", 0, 0}, {"", 0, 0},
! {"__extension__", EXTENSION, NORID},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"else", ELSE, NORID},
{"", 0, 0},
{"__imag__", IMAGPART, NORID},
{"", 0, 0},
{"__inline__", SCSPEC, RID_INLINE},
{"switch", SWITCH, NORID},
{"", 0, 0},
! {"__volatile__", TYPE_QUAL, RID_VOLATILE},
! {"while", WHILE, NORID},
{"", 0, 0},
! {"__inline", SCSPEC, RID_INLINE},
{"", 0, 0},
! {"in", TYPE_QUAL, RID_IN},
! {"__volatile", TYPE_QUAL, RID_VOLATILE},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"__typeof__", TYPEOF, NORID},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"__signed", TYPESPEC, RID_SIGNED},
{"", 0, 0},
{"__restrict", TYPE_QUAL, RID_RESTRICT},
{"struct", STRUCT, NORID},
! {"", 0, 0},
{"restrict", TYPE_QUAL, RID_RESTRICT},
! {"oneway", TYPE_QUAL, RID_ONEWAY},
! {"id", OBJECTNAME, RID_ID},
! {"", 0, 0}, {"", 0, 0},
{"sizeof", SIZEOF, NORID},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"for", FOR, NORID},
! {"return", RETURN, NORID},
! {"__bounded__", TYPE_QUAL, RID_BOUNDED},
! {"extern", SCSPEC, RID_EXTERN},
! {"break", BREAK, NORID},
! {"if", IF, NORID},
! {"", 0, 0}, {"", 0, 0},
! {"__ptrbase__", PTR_BASE, NORID},
! {"__ptrvalue__", PTR_VALUE, NORID},
! {"__ptrextent__", PTR_EXTENT, NORID},
{"", 0, 0},
! {"do", DO, NORID},
{"", 0, 0},
+ {"__ptrbase", PTR_BASE, NORID},
+ {"__ptrvalue", PTR_VALUE, NORID},
{"void", TYPESPEC, RID_VOID},
{"", 0, 0},
! {"register", SCSPEC, RID_REGISTER},
{"", 0, 0},
! {"short", TYPESPEC, RID_SHORT},
{"", 0, 0},
+ {"__unbounded__", TYPE_QUAL, RID_UNBOUNDED},
{"__imag", IMAGPART, NORID},
+ {"__asm__", ASM_KEYWORD, NORID},
+ {"__typeof", TYPEOF, NORID},
+ {"int", TYPESPEC, RID_INT},
+ {"", 0, 0},
{"__alignof__", ALIGNOF, NORID},
{"", 0, 0},
{"__attribute__", ATTRIBUTE, NORID},
! {"", 0, 0}, {"", 0, 0},
! {"__bounded", TYPE_QUAL, RID_BOUNDED},
! {"inout", TYPE_QUAL, RID_INOUT},
{"", 0, 0},
! {"__attribute", ATTRIBUTE, NORID},
! {"enum", ENUM, NORID},
! {"__asm", ASM_KEYWORD, NORID},
{"", 0, 0},
! {"__ptrextent", PTR_EXTENT, NORID},
{"", 0, 0},
! {"signed", TYPESPEC, RID_SIGNED},
! {"", 0, 0}, {"", 0, 0},
! {"out", TYPE_QUAL, RID_OUT},
{"", 0, 0},
{"byref", TYPE_QUAL, RID_BYREF},
{"", 0, 0}, {"", 0, 0},
! {"union", UNION, NORID},
{"", 0, 0},
! {"asm", ASM_KEYWORD, NORID},
! {"__unbounded", TYPE_QUAL, RID_UNBOUNDED},
{"", 0, 0},
! {"unsigned", TYPESPEC, RID_UNSIGNED},
! {"double", TYPESPEC, RID_DOUBLE},
! {"default", DEFAULT, NORID},
! {"", 0, 0},
! {"__const__", TYPE_QUAL, RID_CONST},
! {"float", TYPESPEC, RID_FLOAT},
! {"__complex__", TYPESPEC, RID_COMPLEX},
! {"", 0, 0},
! {"__complex", TYPESPEC, RID_COMPLEX},
! {"", 0, 0},
! {"__builtin_va_arg", VA_ARG, NORID},
! {"__label__", LABEL, NORID},
! {"case", CASE, NORID},
{"", 0, 0},
+ {"__real", REALPART, NORID},
+ {"@defs", DEFS, NORID},
{"__alignof", ALIGNOF, NORID},
! {"goto", GOTO, NORID},
{"", 0, 0},
! {"@private", PRIVATE, NORID},
! {"@selector", SELECTOR, NORID},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"typeof", TYPEOF, NORID},
! {"typedef", SCSPEC, RID_TYPEDEF},
! {"", 0, 0},
! {"continue", CONTINUE, NORID},
! {"@encode", ENCODE, NORID},
{"", 0, 0}, {"", 0, 0},
! {"@interface", INTERFACE, NORID},
! {"", 0, 0},
! {"__const", TYPE_QUAL, RID_CONST},
{"inline", SCSPEC, RID_INLINE},
! {"auto", SCSPEC, RID_AUTO},
{"", 0, 0},
! {"volatile", TYPE_QUAL, RID_VOLATILE},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"@implementation", IMPLEMENTATION, NORID},
! {"@protected", PROTECTED, NORID},
! {"", 0, 0}, {"", 0, 0},
{"const", TYPE_QUAL, RID_CONST},
{"", 0, 0},
! {"@end", END, NORID},
! {"bycopy", TYPE_QUAL, RID_BYCOPY},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"@compatibility_alias", ALIAS, NORID},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
+ {"", 0, 0}, {"", 0, 0},
+ {"long", TYPESPEC, RID_LONG},
+ {"char", TYPESPEC, RID_CHAR},
+ {"static", SCSPEC, RID_STATIC},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"@class", CLASS, NORID},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"@protocol", PROTOCOL, NORID},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
! {"@public", PUBLIC, NORID}
};
#ifdef __GNUC__
Index: gcc/c-iterate.c
===================================================================
RCS file: c-iterate.c
diff -N c-iterate.c
*** /sourceware/cvs-tmp/cvsDnzaHq Thu Aug 24 17:42:00 2000
--- /dev/null Tue May 5 13:32:27 1998
***************
*** 1,587 ****
- /* Build expressions with type checking for C compiler.
- Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996
- 1997, 1998, 2000 Free Software Foundation, Inc.
-
- This file is part of GNU CC.
-
- GNU CC is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GNU CC is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU CC; see the file COPYING. If not, write to
- the Free Software Foundation, 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-
- /* This file is part of the C front end.
- It is responsible for implementing iterators,
- both their declarations and the expansion of statements using them. */
-
- #include "config.h"
- #include "system.h"
- #include "tree.h"
- #include "c-tree.h"
- #include "flags.h"
- #include "obstack.h"
- #include "rtl.h"
- #include "toplev.h"
- #include "expr.h"
-
- /*
- KEEPING TRACK OF EXPANSIONS
-
- In order to clean out expansions corresponding to statements inside
- "{(...)}" constructs we have to keep track of all expansions. The
- cleanup is needed when an automatic, or implicit, expansion on
- iterator, say X, happens to a statement which contains a {(...)}
- form with a statement already expanded on X. In this case we have
- to go back and cleanup the inner expansion. This can be further
- complicated by the fact that {(...)} can be nested.
-
- To make this cleanup possible, we keep lists of all expansions, and
- to make it work for nested constructs, we keep a stack. The list at
- the top of the stack (ITER_STACK.CURRENT_LEVEL) corresponds to the
- currently parsed level. All expansions of the levels below the
- current one are kept in one list whose head is pointed to by
- ITER_STACK.SUBLEVEL_FIRST (SUBLEVEL_LAST is there for making merges
- easy). The process works as follows:
-
- -- On "({" a new node is added to the stack by PUSH_ITERATOR_STACK.
- The sublevel list is not changed at this point.
-
- -- On "})" the list for the current level is appended to the sublevel
- list.
-
- -- On ";" sublevel lists are appended to the current level lists.
- The reason is this: if they have not been superseded by the
- expansion at the current level, they still might be
- superseded later by the expansion on the higher level.
- The levels do not have to distinguish levels below, so we
- can merge the lists together. */
-
- struct ixpansion
- {
- tree ixdecl; /* Iterator decl */
- rtx ixprologue_start; /* First insn of epilogue. NULL means */
- /* explicit (FOR) expansion*/
- rtx ixprologue_end;
- rtx ixepilogue_start;
- rtx ixepilogue_end;
- struct ixpansion *next; /* Next in the list */
- };
-
- struct iter_stack_node
- {
- struct ixpansion *first; /* Head of list of ixpansions */
- struct ixpansion *last; /* Last node in list of ixpansions */
- struct iter_stack_node *next; /* Next level iterator stack node */
- };
-
- struct iter_stack_node *iter_stack;
- struct iter_stack_node sublevel_ixpansions;
-
- /* A special obstack, and a pointer to the start of
- all the data in it (so we can free everything easily). */
- static struct obstack ixp_obstack;
- static char *ixp_firstobj;
-
- /* During collect_iterators, a list of SAVE_EXPRs already scanned. */
- static tree save_exprs;
-
- static void expand_stmt_with_iterators_1 PARAMS ((tree, tree));
- static tree collect_iterators PARAMS ((tree, tree));
- static void iterator_loop_prologue PARAMS ((tree, rtx *, rtx *));
- static void iterator_loop_epilogue PARAMS ((tree, rtx *, rtx *));
- static int top_level_ixpansion_p PARAMS ((void));
- static void isn_append PARAMS ((struct iter_stack_node *,
- struct iter_stack_node *));
- static void istack_sublevel_to_current PARAMS ((void));
- static void add_ixpansion PARAMS ((tree, rtx, rtx, rtx, rtx));
- static void delete_ixpansion PARAMS ((tree));
-
- /* Initialize our obstack once per compilation. */
-
- void
- init_iterators ()
- {
- gcc_obstack_init (&ixp_obstack);
- ixp_firstobj = (char *) obstack_alloc (&ixp_obstack, 0);
- }
-
- /* Handle the start of an explicit `for' loop for iterator IDECL. */
-
- void
- iterator_for_loop_start (idecl)
- tree idecl;
- {
- ITERATOR_BOUND_P (idecl) = 1;
- add_ixpansion (idecl, 0, 0, 0, 0);
- iterator_loop_prologue (idecl, 0, 0);
- }
-
- /* Handle the end of an explicit `for' loop for iterator IDECL. */
-
- void
- iterator_for_loop_end (idecl)
- tree idecl;
- {
- iterator_loop_epilogue (idecl, 0, 0);
- ITERATOR_BOUND_P (idecl) = 0;
- }
-
- /*
- ITERATOR RTL EXPANSIONS
-
- Expanding simple statements with iterators is straightforward:
- collect the list of all free iterators in the statement, and
- generate a loop for each of them.
-
- An iterator is "free" if it has not been "bound" by a FOR
- operator. The DECL_RTL of the iterator is the loop counter. */
-
- /* Expand a statement STMT, possibly containing iterator usage, into RTL. */
-
- void
- iterator_expand (stmt)
- tree stmt;
- {
- tree iter_list;
- save_exprs = NULL_TREE;
- iter_list = collect_iterators (stmt, NULL_TREE);
- expand_stmt_with_iterators_1 (stmt, iter_list);
- istack_sublevel_to_current ();
- }
-
-
- static void
- expand_stmt_with_iterators_1 (stmt, iter_list)
- tree stmt, iter_list;
- {
- if (iter_list == 0)
- expand_expr_stmt (stmt);
- else
- {
- tree current_iterator = TREE_VALUE (iter_list);
- tree iter_list_tail = TREE_CHAIN (iter_list);
- rtx p_start, p_end, e_start, e_end;
-
- iterator_loop_prologue (current_iterator, &p_start, &p_end);
- expand_stmt_with_iterators_1 (stmt, iter_list_tail);
- iterator_loop_epilogue (current_iterator, &e_start, &e_end);
-
- /** Delete all inner expansions based on current_iterator **/
- /** before adding the outer one. **/
-
- delete_ixpansion (current_iterator);
- add_ixpansion (current_iterator, p_start, p_end, e_start, e_end);
- }
- }
-
-
- /* Return a list containing all the free (i.e. not bound by a
- containing `for' statement) iterators mentioned in EXP, plus those
- in LIST. Do not add duplicate entries to the list. */
-
- static tree
- collect_iterators (exp, list)
- tree exp, list;
- {
- if (exp == 0) return list;
-
- switch (TREE_CODE (exp))
- {
- case VAR_DECL:
- if (! ITERATOR_P (exp) || ITERATOR_BOUND_P (exp))
- return list;
- if (value_member (exp, list))
- return list;
- return tree_cons (NULL_TREE, exp, list);
-
- case TREE_LIST:
- {
- tree tail;
- for (tail = exp; tail; tail = TREE_CHAIN (tail))
- list = collect_iterators (TREE_VALUE (tail), list);
- return list;
- }
-
- case SAVE_EXPR:
- /* In each scan, scan a given save_expr only once. */
- if (value_member (exp, save_exprs))
- return list;
-
- save_exprs = tree_cons (NULL_TREE, exp, save_exprs);
- return collect_iterators (TREE_OPERAND (exp, 0), list);
-
- /* we do not automatically iterate blocks -- one must */
- /* use the FOR construct to do that */
-
- case BLOCK:
- return list;
-
- default:
- switch (TREE_CODE_CLASS (TREE_CODE (exp)))
- {
- case '1':
- return collect_iterators (TREE_OPERAND (exp, 0), list);
-
- case '2':
- case '<':
- return collect_iterators (TREE_OPERAND (exp, 0),
- collect_iterators (TREE_OPERAND (exp, 1),
- list));
-
- case 'e':
- case 'r':
- {
- int num_args = first_rtl_op (TREE_CODE (exp));
- int i;
-
- for (i = 0; i < num_args; i++)
- list = collect_iterators (TREE_OPERAND (exp, i), list);
- return list;
- }
- default:
- return list;
- }
- }
- }
-
- /* Emit rtl for the start of a loop for iterator IDECL.
-
- If necessary, create loop counter rtx and store it as DECL_RTL of IDECL.
-
- The prologue normally starts and ends with notes, which are returned
- by this function in *START_NOTE and *END_NODE.
- If START_NOTE and END_NODE are 0, we don't make those notes. */
-
- static void
- iterator_loop_prologue (idecl, start_note, end_note)
- tree idecl;
- rtx *start_note, *end_note;
- {
- tree expr;
-
- /* Force the save_expr in DECL_INITIAL to be calculated
- if it hasn't been calculated yet. */
- expand_expr (DECL_INITIAL (idecl), const0_rtx, VOIDmode,
- EXPAND_NORMAL);
-
- if (DECL_RTL (idecl) == 0)
- expand_decl (idecl);
-
- if (start_note)
- *start_note = emit_note (0, NOTE_INSN_DELETED);
-
- /* Initialize counter. */
- expr = build (MODIFY_EXPR, TREE_TYPE (idecl), idecl, integer_zero_node);
- TREE_SIDE_EFFECTS (expr) = 1;
- expand_expr (expr, const0_rtx, VOIDmode, EXPAND_NORMAL);
-
- expand_start_loop_continue_elsewhere (1);
-
- ITERATOR_BOUND_P (idecl) = 1;
-
- if (end_note)
- *end_note = emit_note (0, NOTE_INSN_DELETED);
- }
-
- /* Similar to the previous function, but for the end of the loop.
-
- DECL_RTL is zeroed unless we are inside "({...})". The reason for that is
- described below.
-
- When we create two (or more) loops based on the same IDECL, and
- both inside the same "({...})" construct, we must be prepared to
- delete both of the loops and create a single one on the level
- above, i.e. enclosing the "({...})". The new loop has to use the
- same counter rtl because the references to the iterator decl
- (IDECL) have already been expanded as references to the counter
- rtl.
-
- It is incorrect to use the same counter reg in different functions,
- and it is desirable to use different counters in disjoint loops
- when we know there's no need to combine them (because then they can
- get allocated separately). */
-
- static void
- iterator_loop_epilogue (idecl, start_note, end_note)
- tree idecl;
- rtx *start_note, *end_note;
- {
- tree test, incr;
-
- if (start_note)
- *start_note = emit_note (0, NOTE_INSN_DELETED);
- expand_loop_continue_here ();
- incr = build_binary_op (PLUS_EXPR, idecl, integer_one_node, 0);
- incr = build (MODIFY_EXPR, TREE_TYPE (idecl), idecl, incr);
- TREE_SIDE_EFFECTS (incr) = 1;
- expand_expr (incr, const0_rtx, VOIDmode, EXPAND_NORMAL);
- test = build_binary_op (LT_EXPR, idecl, DECL_INITIAL (idecl), 0);
- expand_exit_loop_if_false (0, test);
- expand_end_loop ();
-
- ITERATOR_BOUND_P (idecl) = 0;
- /* we can reset rtl since there is not chance that this expansion */
- /* would be superseded by a higher level one */
- /* but don't do this if the decl is static, since we need to share */
- /* the same decl in that case. */
- if (top_level_ixpansion_p () && ! TREE_STATIC (idecl))
- DECL_RTL (idecl) = 0;
- if (end_note)
- *end_note = emit_note (0, NOTE_INSN_DELETED);
- }
-
- /* Return true if we are not currently inside a "({...})" construct. */
-
- static int
- top_level_ixpansion_p ()
- {
- return iter_stack == 0;
- }
-
- /* Given two chains of iter_stack_nodes,
- append the nodes in X into Y. */
-
- static void
- isn_append (x, y)
- struct iter_stack_node *x, *y;
- {
- if (x->first == 0)
- return;
-
- if (y->first == 0)
- {
- y->first = x->first;
- y->last = x->last;
- }
- else
- {
- y->last->next = x->first;
- y->last = x->last;
- }
- }
-
- /** Make X empty **/
-
- #define ISN_ZERO(X) (X).first=(X).last=0
-
- /* Move the ixpansions in sublevel_ixpansions into the current
- node on the iter_stack, or discard them if the iter_stack is empty.
- We do this at the end of a statement. */
-
- static void
- istack_sublevel_to_current ()
- {
- /* At the top level we can throw away sublevel's expansions **/
- /* because there is nobody above us to ask for a cleanup **/
- if (iter_stack != 0)
- /** Merging with empty sublevel list is a no-op **/
- if (sublevel_ixpansions.last)
- isn_append (&sublevel_ixpansions, iter_stack);
-
- if (iter_stack == 0)
- obstack_free (&ixp_obstack, ixp_firstobj);
-
- ISN_ZERO (sublevel_ixpansions);
- }
-
- /* Push a new node on the iter_stack, when we enter a ({...}). */
-
- void
- push_iterator_stack ()
- {
- struct iter_stack_node *new_top
- = (struct iter_stack_node *)
- obstack_alloc (&ixp_obstack, sizeof (struct iter_stack_node));
-
- new_top->first = 0;
- new_top->last = 0;
- new_top->next = iter_stack;
- iter_stack = new_top;
- }
-
- /* Pop iter_stack, moving the ixpansions in the node being popped
- into sublevel_ixpansions. */
-
- void
- pop_iterator_stack ()
- {
- if (iter_stack == 0)
- abort ();
-
- isn_append (iter_stack, &sublevel_ixpansions);
- /** Pop current level node: */
- iter_stack = iter_stack->next;
- }
-
-
- /* Record an iterator expansion ("ixpansion") for IDECL.
- The remaining parameters are the notes in the loop entry
- and exit rtl. */
-
- static void
- add_ixpansion (idecl, pro_start, pro_end, epi_start, epi_end)
- tree idecl;
- rtx pro_start, pro_end, epi_start, epi_end;
- {
- struct ixpansion *newix;
-
- /* Do nothing if we are not inside "({...})",
- as in that case this expansion can't need subsequent RTL modification. */
- if (iter_stack == 0)
- return;
-
- newix = (struct ixpansion *) obstack_alloc (&ixp_obstack,
- sizeof (struct ixpansion));
- newix->ixdecl = idecl;
- newix->ixprologue_start = pro_start;
- newix->ixprologue_end = pro_end;
- newix->ixepilogue_start = epi_start;
- newix->ixepilogue_end = epi_end;
-
- newix->next = iter_stack->first;
- iter_stack->first = newix;
- if (iter_stack->last == 0)
- iter_stack->last = newix;
- }
-
- /* Delete the RTL for all ixpansions for iterator IDECL
- in our sublevels. We do this when we make a larger
- containing expansion for IDECL. */
-
- static void
- delete_ixpansion (idecl)
- tree idecl;
- {
- struct ixpansion *previx = 0, *ix;
-
- for (ix = sublevel_ixpansions.first; ix; ix = ix->next)
- if (ix->ixdecl == idecl)
- {
- /** zero means that this is a mark for FOR -- **/
- /** we do not delete anything, just issue an error. **/
-
- if (ix->ixprologue_start == 0)
- error_with_decl (idecl,
- "`for (%s)' appears within implicit iteration");
- else
- {
- rtx insn;
- /* We delete all insns, including notes because leaving loop */
- /* notes and barriers produced by iterator expansion would */
- /* be misleading to other phases */
-
- for (insn = NEXT_INSN (ix->ixprologue_start);
- insn != ix->ixprologue_end;
- insn = NEXT_INSN (insn))
- delete_insn (insn);
- for (insn = NEXT_INSN (ix->ixepilogue_start);
- insn != ix->ixepilogue_end;
- insn = NEXT_INSN (insn))
- delete_insn (insn);
- }
-
- /* Delete this ixpansion from sublevel_ixpansions. */
- if (previx)
- previx->next = ix->next;
- else
- sublevel_ixpansions.first = ix->next;
- if (sublevel_ixpansions.last == ix)
- sublevel_ixpansions.last = previx;
- }
- else
- previx = ix;
- }
-
- #ifdef DEBUG_ITERATORS
-
- /* The functions below are for use from source level debugger.
- They print short forms of iterator lists and the iterator stack. */
-
- /* Print the name of the iterator D. */
-
- void
- prdecl (d)
- tree d;
- {
- if (d)
- {
- if (TREE_CODE (d) == VAR_DECL)
- {
- tree tname = DECL_NAME (d);
- char *dname = IDENTIFIER_POINTER (tname);
- fprintf (stderr, dname);
- }
- else
- fprintf (stderr, "<<?>>");
- }
- else
- fprintf (stderr, "<<0>>");
- }
-
- /* Print Iterator List -- names only */
-
- tree
- pil (head)
- tree head;
- {
- tree current, next;
- for (current = head; current; current = next)
- {
- tree node = TREE_VALUE (current);
- prdecl (node);
- next = TREE_CHAIN (current);
- if (next) fprintf (stderr, ",");
- }
- fprintf (stderr, "\n");
- }
-
- /* Print IXpansion List */
-
- struct ixpansion *
- pixl (head)
- struct ixpansion *head;
- {
- struct ixpansion *current, *next;
- fprintf (stderr, "> ");
- if (head == 0)
- fprintf (stderr, "(empty)");
-
- for (current=head; current; current = next)
- {
- tree node = current->ixdecl;
- prdecl (node);
- next = current->next;
- if (next)
- fprintf (stderr, ",");
- }
- fprintf (stderr, "\n");
- return head;
- }
-
- /* Print Iterator Stack. */
-
- void
- pis ()
- {
- struct iter_stack_node *stack_node;
-
- fprintf (stderr, "--SubLevel: ");
- pixl (sublevel_ixpansions.first);
- fprintf (stderr, "--Stack:--\n");
- for (stack_node = iter_stack;
- stack_node;
- stack_node = stack_node->next)
- pixl (stack_node->first);
- }
-
- #endif /* DEBUG_ITERATORS */
--- 0 ----
Index: gcc/c-lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-lex.c,v
retrieving revision 1.95
diff -c -p -r1.95 c-lex.c
*** c-lex.c 2000/08/21 14:54:28 1.95
--- c-lex.c 2000/08/25 00:41:44
*************** init_lex ()
*** 300,306 ****
ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
ridpointers[(int) RID_REGISTER] = get_identifier ("register");
- ridpointers[(int) RID_ITERATOR] = get_identifier ("iterator");
ridpointers[(int) RID_COMPLEX] = get_identifier ("complex");
ridpointers[(int) RID_ID] = get_identifier ("id");
ridpointers[(int) RID_IN] = get_identifier ("in");
--- 300,305 ----
*************** init_lex ()
*** 328,334 ****
UNSET_RESERVED_WORD ("typeof");
UNSET_RESERVED_WORD ("signed");
UNSET_RESERVED_WORD ("inline");
- UNSET_RESERVED_WORD ("iterator");
UNSET_RESERVED_WORD ("complex");
}
else if (!flag_isoc99)
--- 327,332 ----
*************** init_lex ()
*** 340,346 ****
UNSET_RESERVED_WORD ("typeof");
if (! flag_isoc99)
UNSET_RESERVED_WORD ("inline");
- UNSET_RESERVED_WORD ("iterator");
UNSET_RESERVED_WORD ("complex");
}
}
--- 338,343 ----
Index: gcc/c-parse.gperf
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-parse.gperf,v
retrieving revision 1.10
diff -c -p -r1.10 c-parse.gperf
*** c-parse.gperf 2000/03/14 19:42:11 1.10
--- c-parse.gperf 2000/08/25 00:41:44
*************** __imag, IMAGPART, NORID
*** 41,48 ****
__imag__, IMAGPART, NORID
__inline, SCSPEC, RID_INLINE
__inline__, SCSPEC, RID_INLINE
- __iterator, SCSPEC, RID_ITERATOR
- __iterator__, SCSPEC, RID_ITERATOR
__label__, LABEL, NORID
__ptrbase, PTR_BASE, NORID
__ptrbase__, PTR_BASE, NORID
--- 41,46 ----
Index: gcc/c-parse.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-parse.in,v
retrieving revision 1.51
diff -c -p -r1.51 c-parse.in
*** c-parse.in 2000/08/23 01:00:52 1.51
--- c-parse.in 2000/08/25 00:41:45
*************** primary:
*** 656,662 ****
{ tree rtl_exp;
if (pedantic)
pedwarn ("ISO C forbids braced-groups within expressions");
- pop_iterator_stack ();
pop_label_level ();
rtl_exp = expand_end_stmt_expr ($1);
/* The statements have side effects, so the group does. */
--- 656,661 ----
*************** primary:
*** 679,685 ****
{
/* Make sure we call expand_end_stmt_expr. Otherwise
we are likely to lose sequences and crash later. */
- pop_iterator_stack ();
pop_label_level ();
expand_end_stmt_expr ($1);
$$ = error_mark_node;
--- 678,683 ----
*************** compstmt_primary_start:
*** 1673,1679 ****
there is a way to turn off the entire subtree of blocks
that are contained in it. */
keep_next_level ();
- push_iterator_stack ();
push_label_level ();
$$ = expand_start_stmt_expr ();
compstmt_count++;
--- 1671,1676 ----
*************** stmt_or_label:
*** 1753,1759 ****
stmt:
compstmt
{ stmt_count++; }
- | all_iter_stmt
| expr ';'
{ stmt_count++;
emit_line_note ($<filename>-1, $<lineno>0);
--- 1750,1755 ----
*************** stmt:
*** 1769,1775 ****
|| TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
$1 = default_conversion ($1);
#endif
! iterator_expand ($1); }
| simple_if ELSE
{ c_expand_start_else ();
$<itype>1 = stmt_count;
--- 1765,1771 ----
|| TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
$1 = default_conversion ($1);
#endif
! expand_expr_stmt ($1); }
| simple_if ELSE
{ c_expand_start_else ();
$<itype>1 = stmt_count;
*************** stmt:
*** 1932,1991 ****
expand_computed_goto (convert (ptr_type_node, $3)); }
| ';'
;
-
- all_iter_stmt:
- all_iter_stmt_simple
- /* | all_iter_stmt_with_decl */
- ;
-
- all_iter_stmt_simple:
- FOR '(' primary ')'
- {
- /* The value returned by this action is */
- /* 1 if everything is OK */
- /* 0 in case of error or already bound iterator */
-
- $<itype>$ = 0;
- if (TREE_CODE ($3) != VAR_DECL)
- error ("invalid `for (ITERATOR)' syntax");
- else if (! ITERATOR_P ($3))
- error ("`%s' is not an iterator",
- IDENTIFIER_POINTER (DECL_NAME ($3)));
- else if (ITERATOR_BOUND_P ($3))
- error ("`for (%s)' inside expansion of same iterator",
- IDENTIFIER_POINTER (DECL_NAME ($3)));
- else
- {
- $<itype>$ = 1;
- iterator_for_loop_start ($3);
- }
- }
- lineno_labeled_stmt
- {
- if ($<itype>5)
- iterator_for_loop_end ($3);
- }
-
- /* This really should allow any kind of declaration,
- for generality. Fix it before turning it back on.
-
- all_iter_stmt_with_decl:
- FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
- {
- */ /* The value returned by this action is */
- /* 1 if everything is OK */
- /* 0 in case of error or already bound iterator */
- /*
- iterator_for_loop_start ($6);
- }
- lineno_labeled_stmt
- {
- iterator_for_loop_end ($6);
- emit_line_note (input_filename, lineno);
- expand_end_bindings (getdecls (), 1, 0);
- $<ttype>$ = poplevel (1, 1, 0);
- }
- */
/* Any kind of label, including jump labels and case labels.
ANSI C accepts labels only before statements, but we allow them
--- 1928,1933 ----
Index: gcc/c-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-tree.h,v
retrieving revision 1.42
diff -c -p -r1.42 c-tree.h
*** c-tree.h 2000/08/21 14:30:37 1.42
--- c-tree.h 2000/08/25 00:41:46
*************** struct lang_type
*** 126,137 ****
/* In a FIELD_DECL, nonzero if the decl was originally a bitfield. */
#define DECL_C_BIT_FIELD(NODE) DECL_LANG_FLAG_4 (NODE)
- /* In a VAR_DECL, means the variable is really an iterator. */
- #define ITERATOR_P(D) (DECL_LANG_FLAG_4(D))
-
- /* In a VAR_DECL for an iterator, means we are within
- an explicit loop over that iterator. */
- #define ITERATOR_BOUND_P(NODE) ((NODE)->common.readonly_flag)
/* in c-lang.c and objc-act.c */
extern tree lookup_interface PARAMS ((tree));
--- 126,131 ----
*************** extern void set_init_label PARAMS ((tr
*** 261,275 ****
extern void process_init_element PARAMS ((tree));
extern void pedwarn_c99 PARAMS ((const char *, ...))
ATTRIBUTE_PRINTF_1;
-
- /* in c-iterate.c */
- extern void init_iterators PARAMS ((void));
- extern void iterator_expand PARAMS ((tree));
- extern void iterator_for_loop_start PARAMS ((tree));
- extern void iterator_for_loop_end PARAMS ((tree));
- extern void iterator_for_loop_record PARAMS ((tree));
- extern void push_iterator_stack PARAMS ((void));
- extern void pop_iterator_stack PARAMS ((void));
/* Set to 0 at beginning of a function definition, set to 1 if
a return statement that specifies a return value is seen. */
--- 255,260 ----
Index: gcc/c-typeck.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-typeck.c,v
retrieving revision 1.84
diff -c -p -r1.84 c-typeck.c
*** c-typeck.c 2000/08/21 14:54:28 1.84
--- c-typeck.c 2000/08/25 00:41:49
*************** decl_constant_value (decl)
*** 847,853 ****
current_function_decl != 0
&& ! pedantic
&& ! TREE_THIS_VOLATILE (decl)
! && TREE_READONLY (decl) && ! ITERATOR_P (decl)
&& DECL_INITIAL (decl) != 0
&& TREE_CODE (DECL_INITIAL (decl)) != ERROR_MARK
/* This is invalid if initial value is not constant.
--- 847,853 ----
current_function_decl != 0
&& ! pedantic
&& ! TREE_THIS_VOLATILE (decl)
! && TREE_READONLY (decl)
&& DECL_INITIAL (decl) != 0
&& TREE_CODE (DECL_INITIAL (decl)) != ERROR_MARK
/* This is invalid if initial value is not constant.
*************** readonly_warning (arg, msgid)
*** 3280,3290 ****
tree arg;
const char *msgid;
{
- /* Forbid assignments to iterators. */
- if (TREE_CODE (arg) == VAR_DECL && ITERATOR_P (arg))
- pedwarn ("%s of iterator `%s'", _(msgid),
- IDENTIFIER_POINTER (DECL_NAME (arg)));
-
if (TREE_CODE (arg) == COMPONENT_REF)
{
if (TYPE_READONLY (TREE_TYPE (TREE_OPERAND (arg, 0))))
--- 3280,3285 ----
Index: gcc/tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree.h,v
retrieving revision 1.190
diff -c -p -r1.190 tree.h
*** tree.h 2000/08/24 20:09:27 1.190
--- tree.h 2000/08/25 00:41:52
*************** struct tree_common
*** 219,226 ****
TREE_READONLY in
all expressions
- ITERATOR_BOUND_P in
- VAR_DECL if iterator (C)
TYPE_READONLY in
..._TYPE
--- 219,224 ----
Index: gcc/ch/Make-lang.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/ch/Make-lang.in,v
retrieving revision 1.15
diff -c -p -r1.15 Make-lang.in
*** Make-lang.in 2000/08/05 00:50:01 1.15
--- Make-lang.in 2000/08/25 00:41:52
***************
*** 1,5 ****
# Top level Makefile fragment for GNU CHILL.
! # Copyright (C) 1994, 1998 Free Software Foundation, Inc.
#This file is part of GNU CC.
--- 1,5 ----
# Top level Makefile fragment for GNU CHILL.
! # Copyright (C) 1994, 1998, 2000 Free Software Foundation, Inc.
#This file is part of GNU CC.
*************** chill-cross: $(srcdir)/ch/chill.in
*** 95,101 ****
cc1chill$(exeext): $(P) $(CHILL_SRCS) $(LIBDEPS) $(BACKEND) \
insn-config.h insn-flags.h insn-attr.h insn-codes.h \
! c-typeck.o c-aux-info.o c-common.o c-iterate.o \
ggc-callbacks.o
cd ch; $(MAKE) $(LANG_FLAGS_TO_PASS) $(CHILL_FLAGS_TO_PASS) ../cc1chill$(exeext)
--- 95,101 ----
cc1chill$(exeext): $(P) $(CHILL_SRCS) $(LIBDEPS) $(BACKEND) \
insn-config.h insn-flags.h insn-attr.h insn-codes.h \
! c-typeck.o c-aux-info.o c-common.o \
ggc-callbacks.o
cd ch; $(MAKE) $(LANG_FLAGS_TO_PASS) $(CHILL_FLAGS_TO_PASS) ../cc1chill$(exeext)
Index: gcc/testsuite/gcc.dg/noncompile/930622-2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/gcc.dg/noncompile/930622-2.c,v
retrieving revision 1.1
diff -c -p -r1.1 930622-2.c
*** 930622-2.c 2000/06/29 19:55:26 1.1
--- 930622-2.c 2000/08/25 00:41:58
***************
*** 1,6 ****
f ()
{
int i;
! for (i--) /* { dg-error "syntax" } */
;
}
--- 1,6 ----
f ()
{
int i;
! for (i--) /* { dg-error "parse" } */
;
}