OSDN Git Service

2000-06-26 Joseph S. Myers <jsm28@cam.ac.uk>
[pf3gnuchains/gcc-fork.git] / gcc / c-lex.c
index 6597ffc..8b917ff 100644 (file)
@@ -126,16 +126,6 @@ put_back (ch)
 
 int linemode;
 
-/* the declaration found for the last IDENTIFIER token read in.
-   yylex must look this up to detect typedefs, which get token type TYPENAME,
-   so it is left around in case the identifier is not a typedef but is
-   used in a context which makes it a reference to a variable.  */
-tree lastiddecl;
-
-/* Nonzero enables objc features.  */
-
-int doing_objc_thang;
-
 extern int yydebug;
 
 /* File used for outputting assembler code.  */
@@ -222,9 +212,9 @@ remember_protocol_qualifiers ()
       wordlist[i].name = "oneway";
 }
 \f
-char *
+const char *
 init_parse (filename)
-     char *filename;
+     const char *filename;
 {
 #if !USE_CPPLIB
   /* Open input file.  */
@@ -256,6 +246,8 @@ init_parse (filename)
   cpp_token = CPP_DIRECTIVE;
 #endif
 
+  add_c_tree_codes ();
+  
   init_lex ();
   init_pragma ();
 
@@ -305,6 +297,8 @@ init_lex ()
   ridpointers[(int) RID_CONST] = get_identifier ("const");
   ridpointers[(int) RID_RESTRICT] = get_identifier ("restrict");
   ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
+  ridpointers[(int) RID_BOUNDED] = get_identifier ("__bounded");
+  ridpointers[(int) RID_UNBOUNDED] = get_identifier ("__unbounded");
   ridpointers[(int) RID_AUTO] = get_identifier ("auto");
   ridpointers[(int) RID_STATIC] = get_identifier ("static");
   ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
@@ -678,7 +672,7 @@ check_newline ()
        }
       else if (!strcmp (name, "ident"))
        {
-         /* #ident.  The pedantic warning is now in cccp.c.  */
+         /* #ident.  The pedantic warning is now in cpp.  */
 
          /* Here we have just seen `#ident '.
             A string constant should follow.  */
@@ -1400,10 +1394,10 @@ yylex ()
            /* Only return OBJECTNAME if it is a typedef.  */
            if (doing_objc_thang && value == OBJECTNAME)
              {
-               lastiddecl = lookup_name(yylval.ttype);
+               tree decl = lookup_name(yylval.ttype);
 
-               if (lastiddecl == NULL_TREE
-                   || TREE_CODE (lastiddecl) != TYPE_DECL)
+               if (decl == NULL_TREE
+                   || TREE_CODE (decl) != TYPE_DECL)
                  value = IDENTIFIER;
              }
 
@@ -1422,24 +1416,26 @@ yylex ()
 
       if (value == IDENTIFIER)
        {
+         tree decl;
+
          if (token_buffer[0] == '@')
            error("invalid identifier `%s'", token_buffer);
 
           yylval.ttype = get_identifier (token_buffer);
-         lastiddecl = lookup_name (yylval.ttype);
+         decl = lookup_name (yylval.ttype);
 
-         if (lastiddecl != 0 && TREE_CODE (lastiddecl) == TYPE_DECL)
+         if (decl != 0 && TREE_CODE (decl) == TYPE_DECL)
            value = TYPENAME;
          /* A user-invisible read-only initialized variable
             should be replaced by its value.
             We handle only strings since that's the only case used in C.  */
-         else if (lastiddecl != 0 && TREE_CODE (lastiddecl) == VAR_DECL
-                  && DECL_IGNORED_P (lastiddecl)
-                  && TREE_READONLY (lastiddecl)
-                  && DECL_INITIAL (lastiddecl) != 0
-                  && TREE_CODE (DECL_INITIAL (lastiddecl)) == STRING_CST)
+         else if (decl != 0 && TREE_CODE (decl) == VAR_DECL
+                  && DECL_IGNORED_P (decl)
+                  && TREE_READONLY (decl)
+                  && DECL_INITIAL (decl) != 0
+                  && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST)
            {
-             tree stringval = DECL_INITIAL (lastiddecl);
+             tree stringval = DECL_INITIAL (decl);
 
              /* Copy the string value so that we won't clobber anything
                 if we put something in the TREE_CHAIN of this one.  */
@@ -1623,7 +1619,7 @@ yylex ()
                    floatflag = AFTER_EXPON;
                    break;   /* start of exponent */
                  }
-               else if (c >= 'a')
+               else if (c >= 'a' && c <= 'f')
                  {
                    c = c - 'a' + 10;
                  }
@@ -1785,7 +1781,8 @@ yylex ()
                      {
                        if (spec_long_long)
                          error ("three `l's in integer constant");
-                       else if (pedantic && ! in_system_header && warn_long_long)
+                       else if (pedantic && ! flag_isoc99
+                                && ! in_system_header && warn_long_long)
                          pedwarn ("ANSI C forbids long long integer constants");
                        spec_long_long = 1;
                      }