unaligned-memcpy-2.c (dest): Initialize to ensure alignment.
[gcc.git] / libcpp / lex.c
index 7e2671ef026f526f061a40017340fdf04ba5707f..3e59d40d32e3f1a4a1192276dec5f0b358651b17 100644 (file)
@@ -1,6 +1,5 @@
 /* CPP Library - lexical analysis.
-   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010,
-   2011, 2012 Free Software Foundation, Inc.
+   Copyright (C) 2000-2013 Free Software Foundation, Inc.
    Contributed by Per Bothner, 1994-95.
    Based on CCCP program by Paul Rubin, June 1986
    Adapted to ANSI C, Richard Stallman, Jan 1987
@@ -427,6 +426,8 @@ search_line_sse42 (const uchar *s, const uchar *end)
   /* Check for unaligned input.  */
   if (si & 15)
     {
+      v16qi sv;
+
       if (__builtin_expect (end - s < 16, 0)
          && __builtin_expect ((si & 0xfff) > 0xff0, 0))
        {
@@ -439,8 +440,9 @@ search_line_sse42 (const uchar *s, const uchar *end)
 
       /* ??? The builtin doesn't understand that the PCMPESTRI read from
         memory need not be aligned.  */
-      __asm ("%vpcmpestri $0, (%1), %2"
-            : "=c"(index) : "r"(s), "x"(search), "a"(4), "d"(16));
+      sv = __builtin_ia32_loaddqu ((const char *) s);
+      index = __builtin_ia32_pcmpestri128 (search, 4, sv, 16, 0);
+
       if (__builtin_expect (index < 16, 0))
        goto found;
 
@@ -590,10 +592,10 @@ search_line_fast (const uchar *s, const uchar *end ATTRIBUTE_UNUSED)
   {
 #define N  (sizeof(vc) / sizeof(long))
 
-    typedef char check_count[(N == 2 || N == 4) * 2 - 1];
     union {
       vc v;
-      unsigned long l[N];
+      /* Statically assert that N is 2 or 4.  */
+      unsigned long l[(N == 2 || N == 4) ? N : -1];
     } u;
     unsigned long l, i = 0;
 
@@ -1091,6 +1093,7 @@ warn_about_normalization (cpp_reader *pfile,
       else
        cpp_warning_with_line (pfile, CPP_W_NORMALIZE, token->src_loc, 0,
                               "`%.*s' is not in NFC", (int) sz, buf);
+      free (buf);
     }
 }
 
@@ -1558,10 +1561,12 @@ lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base,
         from inttypes.h, we generate a warning and treat the ud-suffix as a
         separate preprocessing token.  This approach is under discussion by
         the standards committee, and has been adopted as a conforming
-        extension by other front ends such as clang. */
-      if (ISALPHA (*cur))
+        extension by other front ends such as clang.
+         A special exception is made for the suffix 's' which will be
+        standardized as a user-defined literal suffix for strings.  */
+      if (ISALPHA (*cur) && *cur != 's')
        {
-         // Raise a warning, but do not consume subsequent tokens.
+         /* Raise a warning, but do not consume subsequent tokens.  */
          if (CPP_OPTION (pfile, warn_literal_suffix))
            cpp_warning_with_line (pfile, CPP_W_LITERAL_SUFFIX,
                                   token->src_loc, 0,
@@ -1569,7 +1574,7 @@ lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base,
                                   "a space between literal and identifier");
        }
       /* Grab user defined literal suffix.  */
-      else if (*cur == '_')
+      else if (ISIDST (*cur))
        {
          type = cpp_userdef_string_add_type (type);
          ++cur;
@@ -1689,10 +1694,12 @@ lex_string (cpp_reader *pfile, cpp_token *token, const uchar *base)
         from inttypes.h, we generate a warning and treat the ud-suffix as a
         separate preprocessing token.  This approach is under discussion by
         the standards committee, and has been adopted as a conforming
-        extension by other front ends such as clang. */
-      if (ISALPHA (*cur))
+        extension by other front ends such as clang.
+         A special exception is made for the suffix 's' which will be
+        standardized as a user-defined literal suffix for strings.  */
+      if (ISALPHA (*cur) && *cur != 's')
        {
-         // Raise a warning, but do not consume subsequent tokens.
+         /* Raise a warning, but do not consume subsequent tokens.  */
          if (CPP_OPTION (pfile, warn_literal_suffix))
            cpp_warning_with_line (pfile, CPP_W_LITERAL_SUFFIX,
                                   token->src_loc, 0,
@@ -1700,7 +1707,7 @@ lex_string (cpp_reader *pfile, cpp_token *token, const uchar *base)
                                   "a space between literal and identifier");
        }
       /* Grab user defined literal suffix.  */
-      else if (*cur == '_')
+      else if (ISIDST (*cur))
        {
          type = cpp_userdef_char_add_type (type);
          type = cpp_userdef_string_add_type (type);
@@ -2286,6 +2293,17 @@ _cpp_lex_direct (cpp_reader *pfile)
        {
          if (*buffer->cur == ':')
            {
+             /* C++11 [2.5/3 lex.pptoken], "Otherwise, if the next
+                three characters are <:: and the subsequent character
+                is neither : nor >, the < is treated as a preprocessor
+                token by itself".  */
+             if (CPP_OPTION (pfile, cplusplus)
+                 && CPP_OPTION (pfile, lang) != CLK_CXX98
+                 && CPP_OPTION (pfile, lang) != CLK_GNUCXX
+                 && buffer->cur[1] == ':'
+                 && buffer->cur[2] != ':' && buffer->cur[2] != '>')
+               break;
+
              buffer->cur++;
              result->flags |= DIGRAPH;
              result->type = CPP_OPEN_SQUARE;
@@ -2828,8 +2846,17 @@ new_buff (size_t len)
     len = MIN_BUFF_SIZE;
   len = CPP_ALIGN (len);
 
+#ifdef ENABLE_VALGRIND_CHECKING
+  /* Valgrind warns about uses of interior pointers, so put _cpp_buff
+     struct first.  */
+  size_t slen = CPP_ALIGN2 (sizeof (_cpp_buff), 2 * DEFAULT_ALIGNMENT);
+  base = XNEWVEC (unsigned char, len + slen);
+  result = (_cpp_buff *) base;
+  base += slen;
+#else
   base = XNEWVEC (unsigned char, len + sizeof (_cpp_buff));
   result = (_cpp_buff *) (base + len);
+#endif
   result->base = base;
   result->cur = base;
   result->limit = base + len;
@@ -2916,7 +2943,11 @@ _cpp_free_buff (_cpp_buff *buff)
   for (; buff; buff = next)
     {
       next = buff->next;
+#ifdef ENABLE_VALGRIND_CHECKING
+      free (buff);
+#else
       free (buff->base);
+#endif
     }
 }