From 6ee2c979428ff9f8e2abc37f42f63380cff632ed Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Sat, 11 Sep 1999 05:38:06 +0000 Subject: [PATCH] cppalloc.c (xstrdup): Use memcpy. 1999-09-10 22:37 -0700 Zack Weinberg * cppalloc.c (xstrdup): Use memcpy. * cpperror.c (cpp_print_containing_files): Don't use cpp_notice. * cpplib.c (conditional_skip): Set temp->lineno. (do_endif): Make error message less obscure. (if_directive_name): New function. (cpp_get_token [case EOF]): Unwind the if stack and generate error messages for each unterminated conditional in this file. (parse_string): Do not behave differently if -traditional. From-SVN: r29279 --- gcc/ChangeLog | 80 +++++++++++++++++++++++++++++--------------------- gcc/cppalloc.c | 6 ++-- gcc/cpperror.c | 4 +-- gcc/cpplib.c | 73 +++++++++++++++++++++++++++++++-------------- 4 files changed, 102 insertions(+), 61 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fc88dc39dd1..6b969622fd8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +1999-09-10 22:37 -0700 Zack Weinberg + + * cppalloc.c (xstrdup): Use memcpy. + * cpperror.c (cpp_print_containing_files): Don't use + cpp_notice. + * cpplib.c (conditional_skip): Set temp->lineno. + (do_endif): Make error message less obscure. + (if_directive_name): New function. + (cpp_get_token [case EOF]): Unwind the if stack and generate + error messages for each unterminated conditional in this file. + (parse_string): Do not behave differently if -traditional. + Fri Sep 10 14:04:07 1999 Richard Henderson * builtins.c (expand_builtin_va_arg): Cope with an array-type @@ -110,7 +122,7 @@ Thu Sep 9 16:42:06 1999 Richard Henderson * i386.h (CC1_CPU_SPEC): Don't add -march=foo. Remove -mno-foo. (CPP_486_SPEC, CPP_586_SPEC, CPP_686_SPEC): Delete. (CPP_CPU_DEFAULT_SPEC): Define to __tune_foo__. - (CC1_CPU_SPEC): Make -march=foo define __foo__, and provide + (CC1_CPU_SPEC): Make -march=foo define __foo__, and provide __tune_foo__ if no -mcpu. Make -mcpu=bar define __tune_bar__. (EXTRA_SPECS): Remove deleted specs. @@ -124,7 +136,7 @@ Thu Sep 9 14:36:31 1999 Mark Mitchell * ggc.h (lang_cleanup_tree): Remove. * gcc-simple.c (ggc_free_tree): Don't call lang_cleanup_tree. * ggc-callbacks.c (lang_cleanup_tree): Remove. - + * c-decl.c (finish_struct): Use ggc_alloc to allocate TYPE_LANG_SPECIFIC when garbage collecting. (lang_mark_tree): Mark TYPE_LANG_SPECIFIC. @@ -152,7 +164,7 @@ Thu Sep 9 09:40:58 1999 Mark Mitchell (free_lang_status): Likewise. (push_function_context_to): Don't set function::decl here. (free_after_copmilation): Make decl parameter implicit. Call - free_lang_status if defined. + free_lang_status if defined. (prepare_function_start): Call init_lang_status if defined. (init_function_start): Set function::decl here. * profile.c (output_func_start_profiler): Don't call pushdecl @@ -161,7 +173,7 @@ Thu Sep 9 09:40:58 1999 Mark Mitchell * toplev.c (rest_of_compilation): Don't pass decl to free_after_compilation. * varasm.c (free_varasm_status): Likewise. - + Thu Sep 9 17:23:19 1999 Bernd Schmidt * except.c (call_get_eh_context): Add root when allocating static @@ -195,7 +207,7 @@ Thu Sep 9 03:37:31 1999 Richard Henderson Use IS_MARKED. Use ggc_free_any. 1999-09-09 Scott Bambrough - + * config/arm/linux-elf.h: define NO_IMPLICIT_EXTERN_C Thu Sep 9 01:55:21 1999 Richard Henderson @@ -254,8 +266,8 @@ Thu Sep 9 13:46:06 1999 Geoffrey Keating (do_xifdef): Handle `#ifdef xxx' for poisoned xxx. * cccp.c: Add T_POISON node type. - (special_symbol): Handle `defined(xxx)' and plain `xxx' for - poisoned xxx. + (special_symbol): Handle `defined(xxx)' and plain `xxx' for + poisoned xxx. (do_define): Generalise to handle poisoned definitions, redefining poisoned identifiers, etc. (do_undef): Don't allow poisoned identifiers to be undefined. @@ -287,7 +299,7 @@ Wed Sep 8 16:41:27 1999 Richard Henderson Wed Sep 8 16:07:52 1999 Richard Henderson - * gengenrtl.c (CONST_DOUBLE_FORMAT): Take the size REAL_ARITHMETIC + * gengenrtl.c (CONST_DOUBLE_FORMAT): Take the size REAL_ARITHMETIC will use into account. Expand the max width to 5. * rtl.c: Likewise. @@ -312,7 +324,7 @@ Wed Sep 8 15:32:16 1999 Kaveh R. Ghazi NEED_DECLARATION_REALLOC test. * mips-tdump.c (malloc, calloc, realloc): Don't prototype. - + Wed Sep 8 11:40:47 1999 Kaveh R. Ghazi * gansidecl.h (__attribute__, ATTRIBUTE_UNUSED_LABEL, @@ -325,7 +337,7 @@ Wed Sep 8 11:40:47 1999 Kaveh R. Ghazi * cccp.c (pcfinclude): Likewise. * global.c (allocno_compare): Likewise. - + * haifa-sched.c (rank_for_schedule): Likewise. * local-alloc.c (qty_sugg_compare_1, qty_compare_1): Likewise. @@ -378,7 +390,7 @@ Wed Sep 8 00:33:43 1999 Alasdair Baird Wed Sep 8 18:55:17 1999 Michael Hayes - * config/c4x/c4x.c: Include ggc.h. + * config/c4x/c4x.c: Include ggc.h. (c4x_add_gc_roots): New function. (c4x_override_options): Call c4x_add_gc_roots. @@ -485,7 +497,7 @@ Tue Sep 7 21:41:38 1999 Richard Henderson Tue Sep 7 17:15:21 1999 Mark Mitchell Add some machine-dependent GC roots. - * sparc.c: Include ggc.h. + * sparc.c: Include ggc.h. (sparc_add_gc_roots): New function. (mark_ultrasparc_pipeline_state): Likewise. (override_options): Call sparc_add_gc_roots. @@ -564,7 +576,7 @@ Tue Sep 7 00:47:52 1999 Mark Mitchell (free_varasm_status): Likewise. (free_emit_status): Likewise. (free_stmt_status): New function. - * ggc-simple.c (rtx, vecs, trees, strings, bytes_alloced_since_gc): + * ggc-simple.c (rtx, vecs, trees, strings, bytes_alloced_since_gc): Remove, replacing with ... (ggc_status): New structure. (ggc_chain): New variable. @@ -593,7 +605,7 @@ Tue Sep 7 00:47:52 1999 Mark Mitchell (push_obstacks_nochange): Likewise. (pop_obstacks): Liekwise. * varasm.c (free_varasm_status): Take decl as a parameter. - + Tue Sep 7 08:15:49 1999 Gavin Romig-Koch * config/mips/mips.h (MULTILIB_ENDIAN_DEFAULT) : New macro. @@ -779,12 +791,12 @@ Sun Sep 5 18:57:42 1999 Mark Mitchell (ggc_add_tree_hash_table_root): Likewise. * varray.h (const_equiv_data): Use struct rtx_def *, rather than rtx, when defining fields. - + Sun Sep 5 18:57:42 1999 Bernd Schmidt * profile.c (output_func_start_profiler): Remove apparently nonsensical call to start_sequence. - + Sun Sep 5 17:34:33 1999 Richard Henderson * clipper/clipper.c (clipper_va_start): Fix typos. @@ -802,14 +814,14 @@ Sun Sep 5 19:11:01 1999 Michael Meissner defines. Sun Sep 5 09:31:56 1999 Richard Henderson - Bernd Schmidt + Bernd Schmidt * integrate.c (function_cannot_inline_p): Do not inline functions with forced labels. Sun Sep 5 00:35:17 1999 Richard Henderson - Bernd Schmidt - Mark Mitchell + Bernd Schmidt + Mark Mitchell * Makefile.in (ggc-simple.o): Depend on varray.h. (rtl.o): Depend on ggc.h. @@ -866,15 +878,15 @@ Sun Sep 5 00:35:17 1999 Richard Henderson (tree_cons): Likewise. (build1): Likewise. (type_hash_canon): Don't call obstack_free when GC'ing. - + Sat Sep 4 21:52:32 1999 Richard Henderson * haifa-sched.c (schedule_block): Use next_nonnote_insn instead of NEXT_INSN when examining speculative insns for SCHED_GROUP_P. Sat Sep 4 20:40:19 1999 Richard Henderson - Bernd Schmidt - Mark Mitchell + Bernd Schmidt + Mark Mitchell * Makefile.in (stor-layout.o): Depend on ggc.h. (expr.o): Depend on ggc.h. @@ -893,9 +905,9 @@ Sat Sep 4 20:40:19 1999 Richard Henderson (set_sizetype): Add gc root. (init_stor_layout_once): New function. * toplev.c (compile_file): Call it. - + Sat Sep 4 19:26:25 1999 Richard Henderson - Bernd Schmidt + Bernd Schmidt Mark Mitchell * Makefile.in (tree.o): Depend on ggc.h. @@ -943,7 +955,7 @@ Sat Sep 4 19:26:25 1999 Richard Henderson * varasm.c: Include ggc.h. (mark_pool_constant): New function. (mark_varasm_state): New function. - + Sat Sep 4 22:28:56 1999 Kaveh R. Ghazi * ggc-simple.c (ggc_root, ggc_collect): Wrap prototype with PROTO. @@ -1042,7 +1054,7 @@ Sat Sep 4 11:19:52 1999 Richard Henderson (all_time): New variable. (compile_file): Print gc time. (print_time): Calculate percentage of the whole. - + Sat Sep 4 13:11:01 1999 Bernd Schmidt Change obstack memory management and varasm constant pool handling so @@ -1148,7 +1160,7 @@ Fri Sep 3 19:02:38 1999 Bernd Schmidt (restore_lang_status): Likewise. (push_function_context_to): Call language-specific save function. (pop_function_context_from): Call language-specific restore function. - + Fri Sep 3 01:16:18 1999 Alasdair Baird * i386.md (movsf_1): Check REG_P before use of REGNO. @@ -1167,7 +1179,7 @@ Sat Sep 4 11:37:15 1999 Michael Hayes (c4x_shiftable_constant): Declare. * config/c4x/c4x.md (loadqi_big_constant, loadhi_big_constant, ashlqi3_noclobber): Add new patterns and associated splitters. - + Fri Sep 3 16:22:17 1999 Richard Henderson * dbxout.c (dbxout_init): Use xcalloc instead of xmalloc+bzero. @@ -1239,11 +1251,11 @@ Fri Sep 3 15:10:20 1999 Kaveh R. Ghazi scan_linker_output): Constify a char*. (symbol_hash_newfunc, file_hash_newfunc, demangled_hash_newfunc, do_tlink): Mark parameters with ATTRIBUTE_UNUSED. - + Fri Sep 3 18:09:24 1999 Andrew Haley * config/m68k/m68kelf.h: Set USE_GAS; this makes gcc generate jbsr - (relative) rather than jsr (absolute) subroutine call insns. + (relative) rather than jsr (absolute) subroutine call insns. * config/m68k/m68k-coff.h: Ditto. Fri Sep 3 17:24:31 1999 Richard Earnshaw @@ -1458,7 +1470,7 @@ Tue Aug 31 13:35:42 1999 Richard Henderson * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. - + * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. @@ -2652,7 +2664,7 @@ Fri Aug 20 22:32:17 1999 Michael Hayes * gencheck.c: Do not define any *_CHECK1 macros. Thu Aug 19 14:42:38 1999 Mike Stump - Mark Mitchell + Mark Mitchell * c-common.c (c_get_alias_set): Fix support for poitners and references. @@ -5119,7 +5131,7 @@ Fri Jul 2 01:36:36 1999 Robert Lipe ntohs. Fri Jul 2 00:46:47 1999 Richard Henderson - Jeff Law + Jeff Law * ginclude/varargs.h (va_dcl): Use word_mode for type of __builtin_va_list. @@ -5878,7 +5890,7 @@ Mon Jun 7 22:05:03 1999 Mark Kettenis * fixinc/fixincl.x, fixinc/fixincl.sh: Rebuilt. Mon Jun 7 20:34:20 1999 Robert Lipe - Jeffrey A Law (law@cygnus.com) + Jeffrey A Law (law@cygnus.com) * varasm.c (assemble_start_function): Remove the function from the pending weak decls list when we define a function. diff --git a/gcc/cppalloc.c b/gcc/cppalloc.c index b42e523d8a5..47712e7a1ae 100644 --- a/gcc/cppalloc.c +++ b/gcc/cppalloc.c @@ -74,8 +74,8 @@ char * xstrdup (input) const char *input; { - unsigned size = strlen (input); - char *output = xmalloc (size + 1); - strcpy (output, input); + size_t size = strlen (input) + 1; + char *output = xmalloc (size); + memcpy (output, input, size); return output; } diff --git a/gcc/cpperror.c b/gcc/cpperror.c index 99c5a5d913c..bf335814f09 100644 --- a/gcc/cpperror.c +++ b/gcc/cpperror.c @@ -63,8 +63,8 @@ cpp_print_containing_files (pfile) if (first) { first = 0; - cpp_notice ("In file included from %s:%ld", - ip->nominal_fname, line); + cpp_message (pfile, -1, "In file included from %s:%ld", + ip->nominal_fname, line); } else cpp_message (pfile, -1, ",\n from %s:%ld", diff --git a/gcc/cpplib.c b/gcc/cpplib.c index e274df9d234..b3151861218 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -1944,9 +1944,7 @@ conditional_skip (pfile, skip, type, control_macro) temp = (IF_STACK_FRAME *) xcalloc (1, sizeof (IF_STACK_FRAME)); temp->fname = CPP_BUFFER (pfile)->nominal_fname; -#if 0 temp->lineno = CPP_BUFFER (pfile)->lineno; -#endif temp->next = pfile->if_stack; temp->control_macro = control_macro; pfile->if_stack = temp; @@ -2177,7 +2175,7 @@ do_endif (pfile, keyword) skip_rest_of_line (pfile); if (pfile->if_stack == CPP_BUFFER (pfile)->if_stack) - cpp_error (pfile, "unbalanced `#endif'"); + cpp_error (pfile, "`#endif' not within a conditional"); else { IF_STACK_FRAME *temp = pfile->if_stack; @@ -2235,6 +2233,25 @@ validate_else (pfile, directive) "text following `%s' violates ANSI standard", directive); } +/* Convert T_IF, etc. to a string. Used in error messages. */ +static const char * +if_directive_name (pfile, ifs) + cpp_reader *pfile; + struct if_stack *ifs; +{ + switch (ifs->type) + { + case T_IF: return "#if"; + case T_IFDEF: return "#ifdef"; + case T_IFNDEF: return "#ifndef"; + case T_ELIF: return "#elif"; + case T_ELSE: return "#else"; + default: + cpp_fatal (pfile, "impossible if_stack->type value %d", ifs->type); + return "unknown"; + } +} + /* Get the next token, and add it to the text in pfile->token_buffer. Return the kind of token we got. */ @@ -2265,9 +2282,23 @@ cpp_get_token (pfile) } else { - cpp_buffer *next_buf - = CPP_PREV_BUFFER (CPP_BUFFER (pfile)); - CPP_BUFFER (pfile)->seen_eof = 1; + cpp_buffer *next_buf = CPP_PREV_BUFFER (CPP_BUFFER (pfile)); + struct if_stack *ifs, *nifs; + + /* Unwind the conditional stack and generate error messages. */ + for (ifs = pfile->if_stack; + ifs != CPP_BUFFER (pfile)->if_stack; + ifs = nifs) + { + cpp_error_with_line (pfile, ifs->lineno, -1, + "unterminated `%s' conditional", + if_directive_name (pfile, ifs)); + + nifs = ifs->next; + free (ifs); + } + pfile->if_stack = ifs; + if (CPP_BUFFER (pfile)->nominal_fname && next_buf != CPP_NULL_BUFFER (pfile)) { @@ -2280,6 +2311,8 @@ cpp_get_token (pfile) output_line_command (pfile, leave_file); CPP_BUFFER (pfile) = cur_buffer; } + + CPP_BUFFER (pfile)->seen_eof = 1; return CPP_POP; } } @@ -2824,17 +2857,15 @@ parse_string (pfile, c) cpp_pop_buffer (pfile); continue; } - if (!CPP_TRADITIONAL (pfile)) - { - cpp_error_with_line (pfile, start_line, start_column, - "unterminated string or character constant"); - if (pfile->multiline_string_line != start_line - && pfile->multiline_string_line != 0) - cpp_error_with_line (pfile, - pfile->multiline_string_line, -1, - "possible real start of unterminated constant"); - pfile->multiline_string_line = 0; - } + + cpp_error_with_line (pfile, start_line, start_column, + "unterminated string or character constant"); + if (pfile->multiline_string_line != start_line + && pfile->multiline_string_line != 0) + cpp_error_with_line (pfile, + pfile->multiline_string_line, -1, + "possible real start of unterminated constant"); + pfile->multiline_string_line = 0; break; } CPP_PUTC (pfile, cc); @@ -2843,11 +2874,9 @@ parse_string (pfile, c) case '\n': CPP_BUMP_LINE (pfile); pfile->lineno++; - /* Traditionally, end of line ends a string constant with - no error. */ - if (CPP_TRADITIONAL (pfile)) - return; - /* Character constants may not extend over multiple lines. */ + /* Character constants may not extend over multiple lines. + In ANSI, neither may strings. We accept multiline strings + as an extension. */ if (c == '\'') { cpp_error_with_line (pfile, start_line, start_column, -- 2.30.2