/* Generate the NTBS name of a type. */ static tree tinfo_name (tree type) { const char *name; tree name_string; name = mangle_type_string (type); name_string = fix_string_type (build_string (strlen (name) + 1, name)); return name_string; }
static enum cpp_ttype lex_string (const cpp_token *tok, tree *valp, bool objc_string) { tree value; bool wide = false; size_t concats = 0; struct obstack str_ob; cpp_string istr; /* Try to avoid the overhead of creating and destroying an obstack for the common case of just one string. */ cpp_string str = tok->val.str; cpp_string *strs = &str; if (tok->type == CPP_WSTRING) wide = true; retry: tok = cpp_get_token (parse_in); switch (tok->type) { case CPP_PADDING: goto retry; case CPP_ATSIGN: if (c_dialect_objc ()) { objc_string = true; goto retry; } /* FALLTHROUGH */ default: break; case CPP_WSTRING: wide = true; /* FALLTHROUGH */ case CPP_STRING: if (!concats) { gcc_obstack_init (&str_ob); obstack_grow (&str_ob, &str, sizeof (cpp_string)); } concats++; obstack_grow (&str_ob, &tok->val.str, sizeof (cpp_string)); goto retry; } /* We have read one more token than we want. */ _cpp_backup_tokens (parse_in, 1); if (concats) strs = XOBFINISH (&str_ob, cpp_string *); if (concats && !objc_string && !in_system_header) warning (OPT_Wtraditional, "traditional C rejects string constant concatenation"); if ((c_lex_string_translate ? cpp_interpret_string : cpp_interpret_string_notranslate) (parse_in, strs, concats + 1, &istr, wide)) { value = build_string (istr.len, (char *) istr.text); free ((void *) istr.text); if (c_lex_string_translate == -1) { int xlated = cpp_interpret_string_notranslate (parse_in, strs, concats + 1, &istr, wide); /* Assume that, if we managed to translate the string above, then the untranslated parsing will always succeed. */ gcc_assert (xlated); if (TREE_STRING_LENGTH (value) != (int) istr.len || 0 != strncmp (TREE_STRING_POINTER (value), (char *) istr.text, istr.len)) { /* Arrange for us to return the untranslated string in *valp, but to set up the C type of the translated one. */ *valp = build_string (istr.len, (char *) istr.text); valp = &TREE_CHAIN (*valp); } free ((void *) istr.text); } } else { /* Callers cannot generally handle error_mark_node in this context, so return the empty string instead. cpp_interpret_string has issued an error. */ if (wide) value = build_string (TYPE_PRECISION (wchar_type_node) / TYPE_PRECISION (char_type_node), "\0\0\0"); /* widest supported wchar_t is 32 bits */ else value = build_string (1, ""); } TREE_TYPE (value) = wide ? wchar_array_type_node : char_array_type_node; *valp = fix_string_type (value); if (concats) obstack_free (&str_ob, 0); return objc_string ? CPP_OBJC_STRING : wide ? CPP_WSTRING : CPP_STRING; }