From 4c400d5ea7c935bd544aa6998c3faa896b2d1cef Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 28 Jul 2000 05:05:20 +0000 Subject: [PATCH] comment-finding hack for hppa-linux. --- gas/ChangeLog | 12 ++++++++++++ gas/app.c | 4 ++++ gas/as.h | 6 ++++++ gas/config/tc-hppa.c | 24 ++++++++++++++++++++++++ gas/config/tc-hppa.h | 9 +++++++++ gas/read.c | 11 +++++++++++ 6 files changed, 66 insertions(+) diff --git a/gas/ChangeLog b/gas/ChangeLog index f7d1e2abed2..c356ef28229 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,15 @@ +2000-07-28 Alan Modra + + * as.h (warn_comment, found_comment, found_comment_file): Declare. + * app.c (do_scrub_chars): Record where first comment found. + * read.c (read_a_source_file): Init found_comment on entry, and + notify whether comments found on exit. + * config/tc-hppa.c (md_shortopts): Add "c". + (md_longopts): Add warn-comment. + (md_parse_option): Handle it. + (md_show_usage): Show available options. + * config/tc-hppa.h (WARN_COMMENTS): Define if TE_LINUX + Thu Jul 27 11:25:01 2000 Andrew Cagney * config/tc-mn10300.c (md_convert_frag): Fix printfs. diff --git a/gas/app.c b/gas/app.c index 09c795cd282..915b1badb12 100644 --- a/gas/app.c +++ b/gas/app.c @@ -1170,6 +1170,10 @@ do_scrub_chars (get, tostart, tolen) as default if so. This is a hack. */ if ((symver_state != NULL) && (*symver_state == 0)) goto de_fault; +#endif +#ifdef WARN_COMMENTS + if (!found_comment) + as_where (&found_comment_file, &found_comment); #endif do { diff --git a/gas/as.h b/gas/as.h index e56d6cda782..852d9395a54 100644 --- a/gas/as.h +++ b/gas/as.h @@ -640,6 +640,12 @@ COMMON int flag_m68k_mri; #define flag_m68k_mri 0 #endif +#ifdef WARN_COMMENTS +COMMON int warn_comment; +COMMON unsigned int found_comment; +COMMON char *found_comment_file; +#endif + #ifndef NUMBERS_WITH_SUFFIX #define NUMBERS_WITH_SUFFIX 0 #endif diff --git a/gas/config/tc-hppa.c b/gas/config/tc-hppa.c index ab227eafd0a..7e59b4288a7 100644 --- a/gas/config/tc-hppa.c +++ b/gas/config/tc-hppa.c @@ -4345,12 +4345,23 @@ md_estimate_size_before_relax (fragP, segment) } #ifdef OBJ_ELF +# ifdef WARN_COMMENTS +const char *md_shortopts = "Vc"; +# else const char *md_shortopts = "V"; +# endif #else +# ifdef WARN_COMMENTS +const char *md_shortopts = "c"; +# else const char *md_shortopts = ""; +# endif #endif struct option md_longopts[] = { +#ifdef WARN_COMMENTS + {"warn-comment", no_argument, NULL, 'c'}, +#endif {NULL, no_argument, NULL, 0} }; size_t md_longopts_size = sizeof(md_longopts); @@ -4369,6 +4380,11 @@ md_parse_option (c, arg) case 'V': print_version_id (); break; +#endif +#ifdef WARN_COMMENTS + case 'c': + warn_comment = 1; + break; #endif } @@ -4379,6 +4395,14 @@ void md_show_usage (stream) FILE *stream ATTRIBUTE_UNUSED; { +#ifdef OBJ_ELF + fprintf (stream, _("\ + -Q ignored\n")); +#endif +#ifdef WARN_COMMENTS + fprintf (stream, _("\ + -c print a warning if a comment is found\n")); +#endif } /* We have no need to default values of symbols. */ diff --git a/gas/config/tc-hppa.h b/gas/config/tc-hppa.h index 69de41a8162..1ea9daa3d45 100644 --- a/gas/config/tc-hppa.h +++ b/gas/config/tc-hppa.h @@ -61,6 +61,15 @@ #define TARGET_FORMAT "som" #endif +#ifdef TE_LINUX +/* Define to compile in an extra assembler option, -c, which enables a + warning (once per file) when a comment is encountered. + The hppa comment char is a `;' which tends to occur in random C asm + statements. A semicolon is a line separator for most assemblers. + It's hard to find these lurking semicolons. Thus... */ +#define WARN_COMMENTS 1 +#endif + /* FIXME. Why oh why aren't these defined somewhere globally? */ #ifndef FALSE #define FALSE (0) diff --git a/gas/read.c b/gas/read.c index 30ad92c4ec1..b2eb2fd03f5 100644 --- a/gas/read.c +++ b/gas/read.c @@ -521,6 +521,10 @@ read_a_source_file (name) register int temp; pseudo_typeS *pop; +#ifdef WARN_COMMENTS + found_comment = 0; +#endif + buffer = input_scrub_new_file (name); listing_file (name); @@ -1082,6 +1086,13 @@ read_a_source_file (name) #endif /* Close the input file. */ input_scrub_close (); +#ifdef WARN_COMMENTS + { + if (warn_comment && found_comment) + as_warn_where (found_comment_file, found_comment, + "first comment found here"); + } +#endif } /* For most MRI pseudo-ops, the line actually ends at the first -- 2.30.2