This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: A comment-finding hack for hppa I found useful


Hi Nick,
  I've cleaned up this patch a little, taking into account the preference
stated here for using #ifdef rather than #if, and commited it.

Regards, Alan
-- 
Linuxcare.  Support for the Revolution.


gas/ChangeLog
	* 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

Index: app.c
===================================================================
RCS file: /cvs/src/src/gas/app.c,v
retrieving revision 1.10
diff -u -p -r1.10 app.c
--- app.c	2000/06/09 00:00:02	1.10
+++ app.c	2000/07/28 03:20:44
@@ -1171,6 +1171,10 @@ do_scrub_chars (get, tostart, tolen)
 	  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
 	    {
 	      ch = GET ();
Index: as.h
===================================================================
RCS file: /cvs/src/src/gas/as.h,v
retrieving revision 1.13
diff -u -p -r1.13 as.h
--- as.h	2000/05/08 10:24:05	1.13
+++ as.h	2000/07/28 03:20:46
@@ -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
Index: read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.25
diff -u -p -r1.25 read.c
--- read.c	2000/07/20 17:12:25	1.25
+++ read.c	2000/07/28 03:20:58
@@ -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
Index: config/tc-hppa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-hppa.c,v
retrieving revision 1.61
diff -u -p -r1.61 tc-hppa.c
--- tc-hppa.c	2000/07/19 06:30:49	1.61
+++ tc-hppa.c	2000/07/28 03:21:15
@@ -4345,12 +4345,23 @@ md_estimate_size_before_relax (fragP, se
 }
 
 #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);
@@ -4370,6 +4381,11 @@ md_parse_option (c, arg)
       print_version_id ();
       break;
 #endif
+#ifdef WARN_COMMENTS
+    case 'c':
+      warn_comment = 1;
+      break;
+#endif
     }
 
   return 1;
@@ -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.  */
Index: config/tc-hppa.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-hppa.h,v
retrieving revision 1.8
diff -u -p -r1.8 tc-hppa.h
--- tc-hppa.h	2000/07/09 08:16:21	1.8
+++ tc-hppa.h	2000/07/28 03:21:15
@@ -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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]