diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-11-23 23:25:40 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-11-23 23:25:40 +0000 |
commit | 68bf2ad934202d583d12eff842fdeb4114f9c783 (patch) | |
tree | c218ffe339a9fcc74872e3e0827398246b77ded8 /gcc | |
parent | ae21cabb6d56d24385469959a35d824e26ae3dfe (diff) | |
download | gcc-68bf2ad934202d583d12eff842fdeb4114f9c783.tar.gz |
gcc:
2004-11-23 Daniel Jacobowitz <dan@codesourcery.com>
Joseph Myers <joseph@codesourcery.com>
* config/sol2-c.c (solaris_register_pragmas): Use
c_register_pragma_with_expansion.
* config/sol2.h (HANDLE_PRAGMA_PACK_WITH_EXPANSION): Define.
* c-pragma.c (c_register_pragma): Update call to
cpp_register_pragma.
(c_register_pragma_with_expansion): New function.
(init_pragma): Honor HANDLE_PRAGMA_PACK_WITH_EXPANSION.
* c-pragma.h (c_register_pragma_with_expansion): New prototype.
* doc/extend.texi (Solaris Pragmas): Mention macro expansion for
#pragma align.
* doc/tm.texi (c_register_pragma_with_expansion,
HANDLE_PRAGMA_PACK_WITH_EXPANSION): Document.
gcc/testsuite:
2004-11-23 Daniel Jacobowitz <dan@codesourcery.com>
* gcc.dg/pragma-align-2.c: Test macro expansion.
* gcc.dg/pragma-pack-2.c: New test.
libcpp:
2004-11-23 Daniel Jacobowitz <dan@codesourcery.com>
Joseph Myers <joseph@codesourcery.com>
* internal.h (struct lexer_state): Add in_deferred_pragma.
* directives.c (struct pragma_entry): Add allow_expansion.
(insert_pragma_entry): Take allow_expansion flag.
(register_pragma): Likewise.
(cpp_register_pragma): Likewise.
(_cpp_init_internal_pragmas): Update calls to cpp_register_pragma.
(do_pragma): Honor allow_expansion.
(cpp_handle_deferred_pragma): Set in_deferred_pragma.
* include/cpplib.h (cpp_register_pragma): Update prototype.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@91117 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 16 | ||||
-rw-r--r-- | gcc/c-pragma.c | 15 | ||||
-rw-r--r-- | gcc/c-pragma.h | 4 | ||||
-rw-r--r-- | gcc/config/sol2-c.c | 2 | ||||
-rw-r--r-- | gcc/config/sol2.h | 3 | ||||
-rw-r--r-- | gcc/doc/extend.texi | 5 | ||||
-rw-r--r-- | gcc/doc/tm.texi | 18 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pragma-align-2.c | 14 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pragma-pack-2.c | 48 |
10 files changed, 121 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d1e06e7d822..16c3403e0de 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2004-11-23 Daniel Jacobowitz <dan@codesourcery.com> + Joseph Myers <joseph@codesourcery.com> + + * config/sol2-c.c (solaris_register_pragmas): Use + c_register_pragma_with_expansion. + * config/sol2.h (HANDLE_PRAGMA_PACK_WITH_EXPANSION): Define. + * c-pragma.c (c_register_pragma): Update call to + cpp_register_pragma. + (c_register_pragma_with_expansion): New function. + (init_pragma): Honor HANDLE_PRAGMA_PACK_WITH_EXPANSION. + * c-pragma.h (c_register_pragma_with_expansion): New prototype. + * doc/extend.texi (Solaris Pragmas): Mention macro expansion for + #pragma align. + * doc/tm.texi (c_register_pragma_with_expansion, + HANDLE_PRAGMA_PACK_WITH_EXPANSION): Document. + 2004-11-23 Richard Henderson <rth@redhat.com> * emit-rtl.c, rtl.h (subreg_hard_regno): Remove. diff --git a/gcc/c-pragma.c b/gcc/c-pragma.c index 24c166658b4..91efc4aa384 100644 --- a/gcc/c-pragma.c +++ b/gcc/c-pragma.c @@ -627,13 +627,20 @@ handle_pragma_visibility (cpp_reader *dummy ATTRIBUTE_UNUSED) #endif -/* Front-end wrapper for pragma registration to avoid dragging +/* Front-end wrappers for pragma registration to avoid dragging cpplib.h in almost everywhere. */ void c_register_pragma (const char *space, const char *name, void (*handler) (struct cpp_reader *)) { - cpp_register_pragma (parse_in, space, name, handler); + cpp_register_pragma (parse_in, space, name, handler, 0); +} + +void +c_register_pragma_with_expansion (const char *space, const char *name, + void (*handler) (struct cpp_reader *)) +{ + cpp_register_pragma (parse_in, space, name, handler, 1); } /* Set up front-end pragmas. */ @@ -641,8 +648,12 @@ void init_pragma (void) { #ifdef HANDLE_PRAGMA_PACK +#ifdef HANDLE_PRAGMA_PACK_WITH_EXPANSION + c_register_pragma_with_expansion (0, "pack", handle_pragma_pack); +#else c_register_pragma (0, "pack", handle_pragma_pack); #endif +#endif #ifdef HANDLE_PRAGMA_WEAK c_register_pragma (0, "weak", handle_pragma_weak); #endif diff --git a/gcc/c-pragma.h b/gcc/c-pragma.h index 92741ff5cb5..669d122e695 100644 --- a/gcc/c-pragma.h +++ b/gcc/c-pragma.h @@ -53,10 +53,12 @@ extern struct cpp_reader* parse_in; extern void init_pragma (void); -/* Front-end wrapper for pragma registration to avoid dragging +/* Front-end wrappers for pragma registration to avoid dragging cpplib.h in almost everywhere. */ extern void c_register_pragma (const char *, const char *, void (*) (struct cpp_reader *)); +extern void c_register_pragma_with_expansion (const char *, const char *, + void (*) (struct cpp_reader *)); extern void maybe_apply_pragma_weak (tree); extern tree maybe_apply_renaming_pragma (tree, tree); extern void add_to_renaming_pragma_list (tree, tree); diff --git a/gcc/config/sol2-c.c b/gcc/config/sol2-c.c index 616448413c8..784d20b2c7a 100644 --- a/gcc/config/sol2-c.c +++ b/gcc/config/sol2-c.c @@ -266,7 +266,7 @@ solaris_pragma_fini (cpp_reader *pfile ATTRIBUTE_UNUSED) void solaris_register_pragmas (void) { - c_register_pragma (0, "align", solaris_pragma_align); + c_register_pragma_with_expansion (0, "align", solaris_pragma_align); c_register_pragma (0, "init", solaris_pragma_init); c_register_pragma (0, "fini", solaris_pragma_fini); } diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h index 86d359c178b..1aa6aa84f44 100644 --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -245,3 +245,6 @@ __enable_execute_stack (void *addr) \ extern GTY(()) tree solaris_pending_aligns; extern GTY(()) tree solaris_pending_inits; extern GTY(()) tree solaris_pending_finis; + +/* Allow macro expansion in #pragma pack. */ +#define HANDLE_PRAGMA_PACK_WITH_EXPANSION diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index ef725b1aebe..dcb27f5642b 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -8603,7 +8603,10 @@ The Solaris target supports @code{#pragma redefine_extname} Increase the minimum alignment of each @var{variable} to @var{alignment}. This is the same as GCC's @code{aligned} attribute @pxref{Variable -Attributes}). +Attributes}). Macro expansion occurs on the arguments to this pragma +when compiling C and Objective-C. It does not currently occur when +compiling C++, but this is a bug which may be fixed in a future +release. @item fini (@var{function} [, @var{function}]...) @cindex pragma, fini diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 72d49f3a9b6..409559e5a2c 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -9029,7 +9029,8 @@ C++, which is to pretend that the file's contents are enclosed in @defmac REGISTER_TARGET_PRAGMAS () Define this macro if you want to implement any target-specific pragmas. If defined, it is a C expression which makes a series of calls to -@code{c_register_pragma} for each pragma. The macro may also do any +@code{c_register_pragma} or @code{c_register_pragma_with_expansion} +for each pragma. The macro may also do any setup required for the pragmas. The primary reason to define this macro is to provide compatibility with @@ -9045,8 +9046,10 @@ silently ignored, unless the user specifies @option{-Wunknown-pragmas}. @end defmac @deftypefun void c_register_pragma (const char *@var{space}, const char *@var{name}, void (*@var{callback}) (struct cpp_reader *)) +@deftypefunx void c_register_pragma_with_expansion (const char *@var{space}, const char *@var{name}, void (*@var{callback}) (struct cpp_reader *)) -Each call to @code{c_register_pragma} establishes one pragma. The +Each call to @code{c_register_pragma} or +@code{c_register_pragma_with_expansion} establishes one pragma. The @var{callback} routine will be called when the preprocessor encounters a pragma of the form @@ -9060,7 +9063,10 @@ routine receives @var{pfile} as its first argument, which can be passed on to cpplib's functions if necessary. You can lex tokens after the @var{name} by calling @code{c_lex}. Tokens that are not read by the callback will be silently ignored. The end of the line is indicated by -a token of type @code{CPP_EOF} +a token of type @code{CPP_EOF}. Macro expansion occurs on the +arguments of pragmas registered with +@code{c_register_pragma_with_expansion} but not on the arguments of +pragmas registered with @code{c_register_pragma}. For an example use of this routine, see @file{c4x.h} and the callback routines defined in @file{c4x-c.c}. @@ -9124,6 +9130,12 @@ that invocations of @samp{#pragma pack(pop)} will return to the previous value. @end defmac +@defmac HANDLE_PRAGMA_PACK_WITH_EXPANSION +Define this macro, as well as +@code{HANDLE_SYSV_PRAGMA}, if macros should be expanded in the +arguments of @samp{#pragma pack}. +@end defmac + @defmac TARGET_DEFAULT_PACK_STRUCT If your target requires a structure packing default other than 0 (meaning the machine default), define this macro the the necessary value (in bytes). diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b395dd02d5c..36b75e00776 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-11-23 Daniel Jacobowitz <dan@codesourcery.com> + + * gcc.dg/pragma-align-2.c: Test macro expansion. + * gcc.dg/pragma-pack-2.c: New test. + 2004-11-23 Richard Henderson <rth@redhat.com> * gcc.dg/vect/pr18425.c: Use effective target vect_long. diff --git a/gcc/testsuite/gcc.dg/pragma-align-2.c b/gcc/testsuite/gcc.dg/pragma-align-2.c index 3d5e0da3270..e33f24a27da 100644 --- a/gcc/testsuite/gcc.dg/pragma-align-2.c +++ b/gcc/testsuite/gcc.dg/pragma-align-2.c @@ -11,6 +11,12 @@ void abort (void); #pragma align 64(x64) #pragma align 128(x128) +#define MACRO 128 +#define MACRO2(A) A + +#pragma align MACRO(y128) +#pragma align MACRO2(MACRO) (z128) + #pragma align 8(not_defined) #pragma align 9(odd_align) /* { dg-error "invalid alignment" } */ @@ -19,7 +25,7 @@ void abort (void); #pragma align bad_align /* { dg-error "malformed" } */ #pragma align 1(bad_align /* { dg-error "malformed" } */ -int x, x1, x2, x4, x8, y8, z8, x16, x32, x64, x128; +int x, x1, x2, x4, x8, y8, z8, x16, x32, x64, x128, y128, z128; #pragma align 16(x) /* { dg-error "must appear before" } */ @@ -50,5 +56,11 @@ main () if (__alignof__ (x128) < 128) abort (); + if (__alignof__ (y128) < 128) + abort (); + + if (__alignof__ (z128) < 128) + abort (); + return 0; } diff --git a/gcc/testsuite/gcc.dg/pragma-pack-2.c b/gcc/testsuite/gcc.dg/pragma-pack-2.c new file mode 100644 index 00000000000..f44f8dbba33 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pragma-pack-2.c @@ -0,0 +1,48 @@ +/* On Solaris, #pragma pack should accept macro expansion. */ + +/* { dg-do run { target *-*-solaris2.* } } */ + +extern void abort (void); + +struct { + char one; + long two; +} defaultalign; + +#define ALIGNHIGH 16 + +#pragma pack(ALIGNHIGH) +struct { + char one; + long two; +} sixteen; + +#define ALIGN1(X) 1 +#pragma pack(ALIGN1(4)) +struct { + char one; + long two; +} two; + +#define ALIGN2(X) X +#pragma pack(ALIGN2(2)) +struct { + char one; + long two; +} three; + +#define EMPTY +#pragma pack(EMPTY) +struct { + char one; + long two; +} resetalign; + +main() +{ + if(sizeof(sixteen) < sizeof(defaultalign)) abort(); + if(sizeof(two) >= sizeof(defaultalign)) abort(); + if(sizeof(three) <= sizeof(two)) abort(); + if(sizeof(resetalign) != sizeof(defaultalign)) abort(); + return 0; +} |