OSDN Git Service

PR bootstrap/50237
[pf3gnuchains/gcc-fork.git] / libcpp / init.c
index 93f12d0..ff006b1 100644 (file)
@@ -80,24 +80,25 @@ struct lang_flags
   char digraphs;
   char uliterals;
   char rliterals;
+  char user_literals;
 };
 
 static const struct lang_flags lang_defaults[] =
-{ /*              c99 c++ xnum xid std  //   digr ulit rlit */
-  /* GNUC89   */  { 0,  0,  1,   0,  0,   1,   1,   0,   0 },
-  /* GNUC99   */  { 1,  0,  1,   0,  0,   1,   1,   1,   1 },
-  /* GNUC1X   */  { 1,  0,  1,   0,  0,   1,   1,   1,   1 },
-  /* STDC89   */  { 0,  0,  0,   0,  1,   0,   0,   0,   0 },
-  /* STDC94   */  { 0,  0,  0,   0,  1,   0,   1,   0,   0 },
-  /* STDC99   */  { 1,  0,  1,   0,  1,   1,   1,   0,   0 },
-  /* STDC1X   */  { 1,  0,  1,   0,  1,   1,   1,   1,   0 },
-  /* GNUCXX   */  { 0,  1,  1,   0,  0,   1,   1,   0,   0 },
-  /* CXX98    */  { 0,  1,  1,   0,  1,   1,   1,   0,   0 },
-  /* GNUCXX0X */  { 1,  1,  1,   0,  0,   1,   1,   1,   1 },
-  /* CXX0X    */  { 1,  1,  1,   0,  1,   1,   1,   1,   1 },
-  /* ASM      */  { 0,  0,  1,   0,  0,   1,   0,   0,   0 }
-  /* xid should be 1 for GNUC99, STDC99, GNUCXX, CXX98, GNUCXX0X, and
-     CXX0X when no longer experimental (when all uses of identifiers
+{ /*              c99 c++ xnum xid std  //   digr ulit rlit user_literals */
+  /* GNUC89   */  { 0,  0,  1,   0,  0,   1,   1,   0,   0,    0 },
+  /* GNUC99   */  { 1,  0,  1,   0,  0,   1,   1,   1,   1,    0 },
+  /* GNUC1X   */  { 1,  0,  1,   0,  0,   1,   1,   1,   1,    0 },
+  /* STDC89   */  { 0,  0,  0,   0,  1,   0,   0,   0,   0,    0 },
+  /* STDC94   */  { 0,  0,  0,   0,  1,   0,   1,   0,   0,    0 },
+  /* STDC99   */  { 1,  0,  1,   0,  1,   1,   1,   0,   0,    0 },
+  /* STDC1X   */  { 1,  0,  1,   0,  1,   1,   1,   1,   0,    0 },
+  /* GNUCXX   */  { 0,  1,  1,   0,  0,   1,   1,   0,   0,    0 },
+  /* CXX98    */  { 0,  1,  1,   0,  1,   1,   1,   0,   0,    0 },
+  /* GNUCXX11 */  { 1,  1,  1,   0,  0,   1,   1,   1,   1,    1 },
+  /* CXX11    */  { 1,  1,  1,   0,  1,   1,   1,   1,   1,    1 },
+  /* ASM      */  { 0,  0,  1,   0,  0,   1,   0,   0,   0,    0 }
+  /* xid should be 1 for GNUC99, STDC99, GNUCXX, CXX98, GNUCXX11, and
+     CXX11 when no longer experimental (when all uses of identifiers
      in the compiler have been audited for correct handling of
      extended identifiers).  */
 };
@@ -120,6 +121,7 @@ cpp_set_lang (cpp_reader *pfile, enum c_lang lang)
   CPP_OPTION (pfile, digraphs)                  = l->digraphs;
   CPP_OPTION (pfile, uliterals)                         = l->uliterals;
   CPP_OPTION (pfile, rliterals)                         = l->rliterals;
+  CPP_OPTION (pfile, user_literals)             = l->user_literals;
 }
 
 /* Initialize library global state.  */
@@ -132,6 +134,8 @@ init_library (void)
     {
       initialized = 1;
 
+      _cpp_init_lexer ();
+
       /* Set up the trigraph map.  This doesn't need to do anything if
         we were compiled with a compiler that supports C99 designated
         initializers.  */
@@ -154,6 +158,7 @@ cpp_create_reader (enum c_lang lang, hash_table *table,
   init_library ();
 
   pfile = XCNEW (cpp_reader);
+  memset (&pfile->base_context, 0, sizeof (pfile->base_context));
 
   cpp_set_lang (pfile, lang);
   CPP_OPTION (pfile, warn_multichar) = 1;
@@ -213,7 +218,7 @@ cpp_create_reader (enum c_lang lang, hash_table *table,
 
   /* Initialize the base context.  */
   pfile->context = &pfile->base_context;
-  pfile->base_context.macro = 0;
+  pfile->base_context.c.macro = 0;
   pfile->base_context.prev = pfile->base_context.next = 0;
 
   /* Aligned and unaligned storage.  */
@@ -223,6 +228,9 @@ cpp_create_reader (enum c_lang lang, hash_table *table,
   /* Initialize table for push_macro/pop_macro.  */
   pfile->pushed_macros = 0;
 
+  /* Do not force token locations by default.  */
+  pfile->forced_token_location_p = NULL;
+
   /* The expression parser stack.  */
   _cpp_expand_op_stack (pfile);
 
@@ -455,7 +463,13 @@ cpp_init_builtins (cpp_reader *pfile, int hosted)
     _cpp_define_builtin (pfile, "__STDC__ 1");
 
   if (CPP_OPTION (pfile, cplusplus))
-    _cpp_define_builtin (pfile, "__cplusplus 199711L");
+    {
+      if (CPP_OPTION (pfile, lang) == CLK_CXX11
+          || CPP_OPTION (pfile, lang) == CLK_GNUCXX11)
+       _cpp_define_builtin (pfile, "__cplusplus 201103L");
+      else
+       _cpp_define_builtin (pfile, "__cplusplus 199711L");
+    }
   else if (CPP_OPTION (pfile, lang) == CLK_ASM)
     _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
   else if (CPP_OPTION (pfile, lang) == CLK_STDC94)
@@ -583,7 +597,9 @@ cpp_read_main_file (cpp_reader *pfile, const char *fname)
   if (CPP_OPTION (pfile, preprocessed))
     {
       read_original_filename (pfile);
-      fname = pfile->line_table->maps[pfile->line_table->used-1].to_file;
+      fname =
+       ORDINARY_MAP_FILE_NAME
+       ((LINEMAPS_LAST_ORDINARY_MAP (pfile->line_table)));
     }
   return fname;
 }