📄 lex.c
字号:
if (TREE_PURPOSE (defarg_parm) && TREE_CODE (TREE_PURPOSE (defarg_parm)) == DEFAULT_ARG) { feed_defarg (defarg_fn, defarg_parm); /* Return to the parser, which will process this defarg and call us again. */ return; } if (TREE_CODE (defarg_fn) == FUNCTION_DECL) { maybe_end_member_template_processing (); check_default_args (defarg_fn); } poplevel (0, 0, 0); pop_nested_class (); }}/* Build a default function named NAME for type TYPE. KIND says what to build. When KIND == 0, build default destructor. When KIND == 1, build virtual destructor. When KIND == 2, build default constructor. When KIND == 3, build default X(const X&) constructor. When KIND == 4, build default X(X&) constructor. When KIND == 5, build default operator = (const X&). When KIND == 6, build default operator = (X&). */treecons_up_default_function (type, full_name, kind) tree type, full_name; int kind;{ extern tree void_list_node; tree declspecs = NULL_TREE; tree fn, args = NULL_TREE; tree argtype; int retref = 0; tree name = constructor_name (full_name); switch (kind) { /* Destructors. */ case 1: declspecs = build_decl_list (NULL_TREE, ridpointers [(int) RID_VIRTUAL]); /* Fall through... */ case 0: name = build_parse_node (BIT_NOT_EXPR, name); args = void_list_node; break; case 2: /* Default constructor. */ args = void_list_node; break; case 3: type = build_qualified_type (type, TYPE_QUAL_CONST); /* Fall through... */ case 4: /* According to ARM $12.8, the default copy ctor will be declared, but not defined, unless it's needed. */ argtype = build_reference_type (type); args = tree_cons (NULL_TREE, build_tree_list (hash_tree_chain (argtype, NULL_TREE), get_identifier ("_ctor_arg")), void_list_node); break; case 5: case 6: retref = 1; declspecs = build_decl_list (NULL_TREE, type); if (kind == 5) type = build_qualified_type (type, TYPE_QUAL_CONST); name = ansi_opname [(int) MODIFY_EXPR]; argtype = build_reference_type (type); args = tree_cons (NULL_TREE, build_tree_list (hash_tree_chain (argtype, NULL_TREE), get_identifier ("_ctor_arg")), void_list_node); break; default: my_friendly_abort (59); } declspecs = decl_tree_cons (NULL_TREE, ridpointers [(int) RID_INLINE], declspecs); TREE_PARMLIST (args) = 1; { tree declarator = make_call_declarator (name, args, NULL_TREE, NULL_TREE); if (retref) declarator = build_parse_node (ADDR_EXPR, declarator); fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE, NULL_TREE); } if (fn == void_type_node) return fn; if (kind > 2) SET_DECL_ARTIFICIAL (TREE_CHAIN (DECL_ARGUMENTS (fn)));#if 0 if (processing_template_defn) { SET_DECL_IMPLICIT_INSTANTIATION (fn); repo_template_used (fn); }#endif#if 0 if (CLASSTYPE_INTERFACE_KNOWN (type)) { DECL_INTERFACE_KNOWN (fn) = 1; DECL_NOT_REALLY_EXTERN (fn) = (!CLASSTYPE_INTERFACE_ONLY (type) && flag_implement_inlines); } else#endif DECL_NOT_REALLY_EXTERN (fn) = 1; mark_inline_for_output (fn);#ifdef DEBUG_DEFAULT_FUNCTIONS { char *fn_type = NULL; tree t = name; switch (kind) { case 0: fn_type = "default destructor"; break; case 1: fn_type = "virtual destructor"; break; case 2: fn_type = "default constructor"; break; case 3: fn_type = "default X(const X&)"; break; case 4: fn_type = "default X(X&)"; break; } if (fn_type) { if (TREE_CODE (name) == BIT_NOT_EXPR) t = TREE_OPERAND (name, 0); fprintf (stderr, "[[[[ %s for %s:\n%s]]]]\n", fn_type, IDENTIFIER_POINTER (t), func_buf); } }#endif /* DEBUG_DEFAULT_FUNCTIONS */ /* Show that this function was generated by the compiler. */ SET_DECL_ARTIFICIAL (fn); return fn;}/* Heuristic to tell whether the user is missing a semicolon after a struct or enum declaration. Emit an error message if we know the user has blown it. */voidcheck_for_missing_semicolon (type) tree type;{ if (yychar < 0) yychar = yylex (); if ((yychar > 255 && yychar != SCSPEC && yychar != IDENTIFIER && yychar != TYPENAME && yychar != CV_QUALIFIER && yychar != SELFNAME) || end_of_file) { if (ANON_AGGRNAME_P (TYPE_IDENTIFIER (type))) error ("semicolon missing after %s declaration", TREE_CODE (type) == ENUMERAL_TYPE ? "enum" : "struct"); else cp_error ("semicolon missing after declaration of `%T'", type); shadow_tag (build_tree_list (0, type)); } /* Could probably also hack cases where class { ... } f (); appears. */ clear_anon_tags ();}voidnote_got_semicolon (type) tree type;{ if (TREE_CODE_CLASS (TREE_CODE (type)) != 't') my_friendly_abort (60); if (CLASS_TYPE_P (type)) CLASSTYPE_GOT_SEMICOLON (type) = 1;}voidnote_list_got_semicolon (declspecs) tree declspecs;{ tree link; for (link = declspecs; link; link = TREE_CHAIN (link)) { tree type = TREE_VALUE (link); if (TREE_CODE_CLASS (TREE_CODE (type)) == 't') note_got_semicolon (type); } clear_anon_tags ();}/* If C is not whitespace, return C. Otherwise skip whitespace and return first nonwhite char read. */static intskip_white_space (c) register int c;{ for (;;) { switch (c) { case '\n': c = check_newline (); break; case ' ': case '\t': case '\f': case '\r': case '\v': case '\b': do c = getch (); while (c == ' ' || c == '\t'); break; case '\\': c = getch (); if (c == '\n') lineno++; else error ("stray '\\' in program"); c = getch (); break; default: return (c); } }}/* Make the token buffer longer, preserving the data in it. P should point to just beyond the last valid character in the old buffer. The value we return is a pointer to the new buffer at a place corresponding to P. */static char *extend_token_buffer (p) const char *p;{ int offset = p - token_buffer; maxtoken = maxtoken * 2 + 10; token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2); return token_buffer + offset;}static intget_last_nonwhite_on_line (){ register int c; /* Is this the last nonwhite stuff on the line? */ if (nextchar >= 0) c = nextchar, nextchar = -1; else c = getch (); while (c == ' ' || c == '\t') c = getch (); return c;}#if defined HANDLE_PRAGMA/* Local versions of these macros, that can be passed as function pointers. */static intpragma_getc (){ int c; if (nextchar != EOF) { c = nextchar; nextchar = EOF; } else c = getch (); return c;}static voidpragma_ungetc (arg) int arg;{ yyungetc (arg, 0);}#endif /* HANDLE_PRAGMA *//* At the beginning of a line, increment the line number and process any #-directive on this line. If the line is a #-directive, read the entire line and return a newline. Otherwise, return the line's first non-whitespace character. */int linemode;static intcheck_newline (){ register int c; register int token; int saw_line = 0; /* Read first nonwhite char on the line. Do this before incrementing the line number, in case we're at the end of saved text. */ do c = getch (); while (c == ' ' || c == '\t'); lineno++; if (c != '#') { /* If not #, return it so caller will use it. */ return c; } /* Don't read beyond this line. */ linemode = 1; /* Read first nonwhite char after the `#'. */ do c = getch (); while (c == ' ' || c == '\t'); /* If a letter follows, then if the word here is `line', skip it and ignore it; otherwise, ignore the line, with an error if the word isn't `pragma'. */ if (ISALPHA (c)) { if (c == 'p') { if (getch () == 'r' && getch () == 'a' && getch () == 'g' && getch () == 'm' && getch () == 'a') { token = real_yylex (); if (token == IDENTIFIER && TREE_CODE (yylval.ttype) == IDENTIFIER_NODE) { /* If this is 1, we handled it; if it's -1, it was one we wanted but had something wrong with it. Only if it's 0 was it not handled. */ if (handle_cp_pragma (IDENTIFIER_POINTER (yylval.ttype))) goto skipline; } else if (token == END_OF_LINE) goto skipline;#ifdef HANDLE_PRAGMA /* We invoke HANDLE_PRAGMA before HANDLE_GENERIC_PRAGMAS (if both are defined), in order to give the back end a chance to override the interpretation of SYSV style pragmas. */ if (HANDLE_PRAGMA (pragma_getc, pragma_ungetc, IDENTIFIER_POINTER (yylval.ttype))) goto skipline;#endif /* HANDLE_PRAGMA */ #ifdef HANDLE_GENERIC_PRAGMAS if (handle_generic_pragma (token)) goto skipline;#endif /* HANDLE_GENERIC_PRAGMAS */ /* Issue a warning message if we have been asked to do so. Ignoring unknown pragmas in system header file unless an explcit -Wunknown-pragmas has been given. */ if (warn_unknown_pragmas > 1 || (warn_unknown_pragmas && ! in_system_header)) warning ("ignoring pragma: %s", token_buffer); } goto skipline; } else if (c == 'd') { if (getch () == 'e' && getch () == 'f' && getch () == 'i' && getch () == 'n' && getch () == 'e' && ((c = getch ()) == ' ' || c == '\t')) { debug_define (lineno, GET_DIRECTIVE_LINE ()); goto skipline; } } else if (c == 'u') { if (getch () == 'n' && getch () == 'd' && getch () == 'e' && getch () == 'f' && ((c = getch ()) == ' ' || c == '\t')) { debug_undef (lineno, GET_DIRECTIVE_LINE ()); goto skipline; } } else if (c == 'l') { if (getch () == 'i' && getch () == 'n' && getch () == 'e' && ((c = getch ()) == ' ' || c == '\t')) { saw_line = 1; goto linenum; } } else if (c == 'i') { if (getch () == 'd' && getch () == 'e' && getch () == 'n' && getch () == 't' && ((c = getch ()) == ' ' || c == '\t')) { /* #ident. The pedantic warning is now in cccp.c. */ /* Here we have just seen `#ident '. A string constant should follow. */ token = real_yylex (); if (token == END_OF_LINE) goto skipline; if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST) { error ("invalid #ident"); goto ski
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -