This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

Re: unnamed #pragma fails to compile


On Feb 25, 2000, Zack Weinberg <zack@wolery.cumb.org> wrote:

> Well, technically, a pragma with no tokens causes implementation-
> defined behavior, but it would seem to fall under the category of
> 'unrecognized pragmas must be ignored'.

Yup, that's what I assumed.  Since the grammar lists the identifier
token that follows `#pragma' as optional, I thought it supported my
assumption.

> The wording in this segment could be a lot better.

Most definitely :-(

> You appear to have been trying to remove the duplicate cleanup code

Yup, sorry

> Furthermore, the name skip_no_error is misleading since you don't
> actually call skip_rest_of_line

Yep.  I hadn't associated the `skip' label with `skip_rest_of_line'.
I had read it as `skip most of this function's body' :-)

> Just put an 'empty' label right after the skip_rest_of_line call at
> the end of the function, and go straight there from if (token ==
> CPP_VSPACE).

> With that change, the patch is approved.

Thanks, I'm installing the following patch:

Index: gcc/ChangeLog
from  Alexandre Oliva  <oliva@lsd.ic.unicamp.br>
	
	* cpplib.c (do_pragma): Accept #pragma without consecutive token.
	
Index: gcc/cpplib.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpplib.c,v
retrieving revision 1.118
diff -p -u -r1.118 cpplib.c
--- gcc/cpplib.c	2000/02/26 05:59:31	1.118
+++ gcc/cpplib.c	2000/02/27 06:21:14
@@ -1615,14 +1615,21 @@ do_pragma (pfile, keyword)
   long here, key;
   U_CHAR *buf;
   int pop;
+  enum cpp_token token;
 
   here = CPP_WRITTEN (pfile);
   CPP_PUTS (pfile, "#pragma ", 8);
 
   key = CPP_WRITTEN (pfile);
   pfile->no_macro_expand++;
-  if (get_directive_token (pfile) != CPP_NAME)
-    goto skip;
+  token = get_directive_token (pfile);
+  if (token != CPP_NAME)
+    {
+      if (token == CPP_VSPACE)
+	goto empty;
+      else
+	goto skip;
+    }
 
   buf = pfile->token_buffer + key;
   CPP_PUTC (pfile, ' ');
@@ -1649,6 +1656,7 @@ do_pragma (pfile, keyword)
  skip:
   cpp_error (pfile, "malformed #pragma directive");
   skip_rest_of_line (pfile);
+ empty:
   CPP_SET_WRITTEN (pfile, here);
   pfile->no_macro_expand--;
   return 0;

-- 
Alexandre Oliva     http://www.ic.unicamp.br/~oliva/     Enjoy Guaranį
Cygnus Solutions, a Red Hat company        aoliva@{redhat, cygnus}.com
Free Software Developer and Evangelist    CS PhD student at IC-Unicamp
oliva@{lsd.ic.unicamp.br, gnu.org}   Write to mailing lists, not to me

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