c-pragma patch/c++ & #pragma pack work again

Robert Lipe robertl@dgii.com
Fri Oct 9 23:19:00 GMT 1998


With Nick's most recent patch in c-pragma, C now handles
	#pragma pack(4)
once again.  Unfortunately, C++ yields a 'malformed prama' error
on any occurence of the above line.

Parsers aren't really my bag, but the difference seems to be in the
"string" passed to handle_pragma_token() between cp/lex.c and lex.c.
Since the code seems to be going to some amount of trouble to pass
args in two different ways, I just tried to fix the C++ way.

In cc1 the problematic string is passed to handle_pragma_token() as a
null terminated string containing "4".

In cc1plus, the problematic string is passed with a pointer valued 4.
(Thank heavens we never try to dereference this sucker.)  The code at
the top of handle_pragma_token goes to some amount of trouble to accept
this, so I'm not questioning it.  I've tried to propogate the same test
down and use the value in the token instead of in the passed in string.

This makes my testuite much, much less noisy but I'm not certain it's
correct.   Comments, please.

	* c-pragma.c (handle_pragma_token): If passed a token instead
	of a tree, use that as the pack value.

Index: c-pragma.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/c-pragma.c,v
retrieving revision 1.10
diff -u -p -r1.10 c-pragma.c
--- c-pragma.c  1998/10/07 14:41:42     1.10
+++ c-pragma.c  1998/10/10 06:05:41
@@ -384,7 +384,11 @@ handle_pragma_token (string, token)
       break;

     case ps_left:
-      align = atoi (string);
+
+      if (TREE_CODE(token) == INTEGER_CST)
+       align = TREE_INT_CST_LOW(token);
+      else
+       align = atoi (string);
       switch (align)
        {
        case 1:




More information about the Gcc-patches mailing list