* src/mcs51/gen.c (genPagedPointerSet): fixed bug 1670148
[fw/sdcc] / support / cpp2 / libcpp / lex.c
index 791bdfe91ea2cf302355d54dcda9cc3096e9ce26..22dc7e7e54149d1f67d92ed41bab98596e4d76fa 100644 (file)
@@ -327,27 +327,27 @@ skip_asm_block (cpp_reader *pfile)
       c = *buffer->cur++;
 
       if (prev_space && c == '_')
-       {
+        {
           if (buffer->cur + _ENDASM_LEN <= buffer->rlimit &&
-            strncmp(buffer->cur, _ENDASM_STR, _ENDASM_LEN) == 0)
+            strncmp((char *)buffer->cur, _ENDASM_STR, _ENDASM_LEN) == 0)
             {
               buffer->cur += _ENDASM_LEN;
               ret = 0;
-             break;
+              break;
             }
-       }
+        }
       else if (c == '\n')
-       {
-         unsigned int cols;
-         --buffer->cur;
-         _cpp_process_line_notes (pfile, true);
-         if (buffer->next_line >= buffer->rlimit)
-           return true;
-         _cpp_clean_line (pfile);
-
-         cols = buffer->next_line - buffer->line_base;
-         CPP_INCREMENT_LINE (pfile, cols);
-       }
+        {
+          unsigned int cols;
+          --buffer->cur;
+          _cpp_process_line_notes (pfile, true);
+          if (buffer->next_line >= buffer->rlimit)
+            return true;
+          _cpp_clean_line (pfile);
+
+          cols = buffer->next_line - buffer->line_base;
+          CPP_INCREMENT_LINE (pfile, cols);
+        }
     }
 
   _cpp_process_line_notes (pfile, true);
@@ -937,6 +937,10 @@ lex_string (cpp_reader *pfile, cpp_token *token, const uchar *base)
     cpp_error (pfile, CPP_DL_WARNING,
               "null character(s) preserved in literal");
 
+  if (type == CPP_OTHER && CPP_OPTION (pfile, lang) != CLK_ASM)
+    cpp_error (pfile, CPP_DL_PEDWARN, "missing terminating %c character",
+              (int) terminator);
+
   pfile->buffer->cur = cur;
   create_literal (pfile, token, base, cur - base, type);
 }
@@ -949,10 +953,10 @@ lex_string (cpp_reader *pfile, cpp_token *token, const uchar *base)
    CRs are automatically generated, because the output is
    opened in TEXT mode. If dest == NULL, only count chars */
 static unsigned int
-copy_text_chars (char *dest, const char *src, unsigned int len)
+copy_text_chars (unsigned char *dest, const unsigned char *src, unsigned int len)
 {
   unsigned int n = 0;
-  const char *p;
+  const unsigned char *p;
 
   for (p = src; p != src + len; ++p)
     {
@@ -1111,24 +1115,24 @@ _cpp_lex_token (cpp_reader *pfile)
              /* 6.10.3 p 11: Directives in a list of macro arguments
                 gives undefined behavior.  This implementation
                 handles the directive as normal.  */
-             && pfile->state.parsing_args != 1
-             && _cpp_handle_directive (pfile, result->flags & PREV_WHITE))
+             && pfile->state.parsing_args != 1)
            {
-             if (pfile->directive_result.type == CPP_PADDING)
-               continue;
-             else
+             if (_cpp_handle_directive (pfile, result->flags & PREV_WHITE))
                {
+                 if (pfile->directive_result.type == CPP_PADDING)
+                   continue;
                  result = &pfile->directive_result;
-                 break;
                }
            }
+         else if (pfile->state.in_deferred_pragma)
+           result = &pfile->directive_result;
 
          if (pfile->cb.line_change && !pfile->state.skipping)
            pfile->cb.line_change (pfile, result, pfile->state.parsing_args);
        }
 
       /* We don't skip tokens in directives.  */
-      if (pfile->state.in_directive)
+      if (pfile->state.in_directive || pfile->state.in_deferred_pragma)
        break;
 
       /* Outside a directive, invalidate controlling macros.  At file
@@ -1222,6 +1226,14 @@ _cpp_lex_direct (cpp_reader *pfile)
   buffer = pfile->buffer;
   if (buffer->need_line)
     {
+      if (pfile->state.in_deferred_pragma)
+       {
+         result->type = CPP_PRAGMA_EOL;
+         pfile->state.in_deferred_pragma = false;
+         if (!pfile->state.pragma_allow_expansion)
+           pfile->state.prevent_expansion--;
+         return result;
+       }
       if (!_cpp_get_fresh_line (pfile))
        {
          result->type = CPP_EOF;
@@ -1401,11 +1413,6 @@ _cpp_lex_direct (cpp_reader *pfile)
          buffer->cur++;
          IF_NEXT_IS ('=', CPP_LSHIFT_EQ, CPP_LSHIFT);
        }
-      else if (*buffer->cur == '?' && CPP_OPTION (pfile, cplusplus))
-       {
-         buffer->cur++;
-         IF_NEXT_IS ('=', CPP_MIN_EQ, CPP_MIN);
-       }
       else if (CPP_OPTION (pfile, digraphs))
        {
          if (*buffer->cur == ':')
@@ -1432,11 +1439,6 @@ _cpp_lex_direct (cpp_reader *pfile)
          buffer->cur++;
          IF_NEXT_IS ('=', CPP_RSHIFT_EQ, CPP_RSHIFT);
        }
-      else if (*buffer->cur == '?' && CPP_OPTION (pfile, cplusplus))
-       {
-         buffer->cur++;
-         IF_NEXT_IS ('=', CPP_MAX_EQ, CPP_MAX);
-       }
       break;
 
     case '%':
@@ -1824,8 +1826,8 @@ cpp_avoid_paste (cpp_reader *pfile, const cpp_token *token1,
 
   switch (a)
     {
-    case CPP_GREATER:  return c == '>' || c == '?';
-    case CPP_LESS:     return c == '<' || c == '?' || c == '%' || c == ':';
+    case CPP_GREATER:  return c == '>';
+    case CPP_LESS:     return c == '<' || c == '%' || c == ':';
     case CPP_PLUS:     return c == '+';
     case CPP_MINUS:    return c == '-' || c == '>';
     case CPP_DIV:      return c == '/' || c == '*'; /* Comments.  */
@@ -2057,7 +2059,7 @@ cpp_token_val_index (cpp_token *tok)
       else if (tok->type == CPP_PADDING)
        return CPP_TOKEN_FLD_SOURCE;
       else if (tok->type == CPP_PRAGMA)
-       return CPP_TOKEN_FLD_STR;
+       return CPP_TOKEN_FLD_PRAGMA;
       /* else fall through */
     default:
       return CPP_TOKEN_FLD_NONE;