aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-03-02 02:03:56 +0000
committerRichard Stallman <rms@gnu.org>1993-03-02 02:03:56 +0000
commit519d591f03527d0bd0b33ead719ea1e2d4e2f45a (patch)
tree1adde46b3790de7115bdefed1312145979c16d3e /gcc
parent3791970daf55a3bedd1d83e46bdf798f44b4b6a9 (diff)
downloadgcc-519d591f03527d0bd0b33ead719ea1e2d4e2f45a.zip
gcc-519d591f03527d0bd0b33ead719ea1e2d4e2f45a.tar.gz
gcc-519d591f03527d0bd0b33ead719ea1e2d4e2f45a.tar.bz2
(grokdeclarator): Handle iterator storage class.
(finish_decl): For iterator, require initial value, make a save_expr. From-SVN: r3579
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-decl.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 6045476..15da5ba 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -3268,6 +3268,14 @@ finish_decl (decl, init, asmspec_tree)
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)
@@ -3880,6 +3888,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
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.). */
@@ -3933,6 +3942,18 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
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.
@@ -4449,6 +4470,14 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
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;
+ {
+ error ("iterator `%s' has derived type", name);
+ type = error_mark_node;
+ }
+
}
/* Record `register' declaration for warnings on &