darwin.h (REGISTER_TARGET_PRAGMAS): Define.
* config/darwin.h (REGISTER_TARGET_PRAGMAS): Define. * config/darwin-c.c: New file. * config/darwin-protos.h: Declare new functions. * config/rs6000/t-darwin (darwin-c.o): New rule. * config.gcc (powerpc-*-darwin*): Define c_target_objs and cxx_target_objs. * doc/extend.texi (Pragmas): New section. * gcc.dg/pragma-darwin.c: New test. From-SVN: r43645
This commit is contained in:
parent
d475215a7b
commit
0168a84948
@ -1,3 +1,13 @@
|
||||
2001-06-28 Stan Shebs <shebs@apple.com>
|
||||
|
||||
* config/darwin.h (REGISTER_TARGET_PRAGMAS): Define.
|
||||
* config/darwin-c.c: New file.
|
||||
* config/darwin-protos.h: Declare new functions.
|
||||
* config/rs6000/t-darwin (darwin-c.o): New rule.
|
||||
* config.gcc (powerpc-*-darwin*): Define c_target_objs and
|
||||
cxx_target_objs.
|
||||
* doc/extend.texi (Pragmas): New section.
|
||||
|
||||
Thu Jun 28 20:13:11 CEST 2001 Jan Hubicka <jh@suse.cz>
|
||||
|
||||
* flow.c (try_merge_block): Rename to try_optimize_cfg;
|
||||
|
@ -2569,6 +2569,8 @@ powerpc-*-darwin*)
|
||||
# fixed and we can get rid of this silliness.
|
||||
xm_defines="HAVE_DESIGNATED_INITIALIZERS=0"
|
||||
extra_objs="darwin.o"
|
||||
c_target_objs="darwin-c.o"
|
||||
cxx_target_objs="darwin-c.o"
|
||||
# Darwin linker does collect2 functionality
|
||||
use_collect2=no
|
||||
;;
|
||||
|
153
gcc/config/darwin-c.c
Normal file
153
gcc/config/darwin-c.c
Normal file
@ -0,0 +1,153 @@
|
||||
/* Darwin support needed only by C/C++ frontends.
|
||||
Copyright (C) 2001
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by Apple Computer Inc.
|
||||
|
||||
This file is part of GNU CC.
|
||||
|
||||
GNU CC is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU CC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU CC; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "cpplib.h"
|
||||
#include "tree.h"
|
||||
#include "c-pragma.h"
|
||||
#include "c-lex.h"
|
||||
#include "c-tree.h"
|
||||
#include "toplev.h"
|
||||
#include "tm_p.h"
|
||||
|
||||
/* Pragmas. */
|
||||
|
||||
#define BAD(msgid) do { warning (msgid); return; } while (0)
|
||||
|
||||
/* Maintain a small stack of alignments. This is similar to pragma
|
||||
pack's stack, but simpler. */
|
||||
|
||||
static void push_field_alignment PARAMS ((int));
|
||||
static void pop_field_alignment PARAMS ((void));
|
||||
|
||||
typedef struct align_stack
|
||||
{
|
||||
int alignment;
|
||||
struct align_stack * prev;
|
||||
} align_stack;
|
||||
|
||||
static struct align_stack * field_align_stack = NULL;
|
||||
|
||||
static void
|
||||
push_field_alignment (bit_alignment)
|
||||
int bit_alignment;
|
||||
{
|
||||
align_stack *entry = (align_stack *) xmalloc (sizeof (align_stack));
|
||||
|
||||
entry->alignment = maximum_field_alignment;
|
||||
entry->prev = field_align_stack;
|
||||
field_align_stack = entry;
|
||||
|
||||
maximum_field_alignment = bit_alignment;
|
||||
}
|
||||
|
||||
static void
|
||||
pop_field_alignment ()
|
||||
{
|
||||
if (field_align_stack)
|
||||
{
|
||||
align_stack *entry = field_align_stack;
|
||||
|
||||
maximum_field_alignment = entry->alignment;
|
||||
field_align_stack = entry->prev;
|
||||
free (entry);
|
||||
}
|
||||
else
|
||||
error ("too many #pragma options align=reset");
|
||||
}
|
||||
|
||||
/* Handlers for Darwin-specific pragmas. */
|
||||
|
||||
void
|
||||
darwin_pragma_ignore (pfile)
|
||||
cpp_reader *pfile ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* Do nothing. */
|
||||
}
|
||||
|
||||
/* #pragma options align={mac68k|power|reset} */
|
||||
|
||||
void
|
||||
darwin_pragma_options (pfile)
|
||||
cpp_reader *pfile ATTRIBUTE_UNUSED;
|
||||
{
|
||||
char *arg;
|
||||
tree t, x;
|
||||
|
||||
if (c_lex (&t) != CPP_NAME)
|
||||
BAD ("malformed '#pragma options', ignoring");
|
||||
arg = IDENTIFIER_POINTER (t);
|
||||
if (strcmp (arg, "align"))
|
||||
BAD ("malformed '#pragma options', ignoring");
|
||||
if (c_lex (&t) != CPP_EQ)
|
||||
BAD ("malformed '#pragma options', ignoring");
|
||||
if (c_lex (&t) != CPP_NAME)
|
||||
BAD ("malformed '#pragma options', ignoring");
|
||||
|
||||
if (c_lex (&x) != CPP_EOF)
|
||||
warning ("junk at end of '#pragma options'");
|
||||
|
||||
arg = IDENTIFIER_POINTER (t);
|
||||
if (!strcmp (arg, "mac68k"))
|
||||
push_field_alignment (16);
|
||||
else if (!strcmp (arg, "power"))
|
||||
push_field_alignment (0);
|
||||
else if (!strcmp (arg, "reset"))
|
||||
pop_field_alignment ();
|
||||
else
|
||||
warning ("malformed '#pragma options align={mac68k|power|reset}', ignoring");
|
||||
}
|
||||
|
||||
/* #pragma unused ([var {, var}*]) */
|
||||
|
||||
void
|
||||
darwin_pragma_unused (pfile)
|
||||
cpp_reader *pfile ATTRIBUTE_UNUSED;
|
||||
{
|
||||
tree decl, x;
|
||||
int tok;
|
||||
|
||||
if (c_lex (&x) != CPP_OPEN_PAREN)
|
||||
BAD ("missing '(' after '#pragma unused', ignoring");
|
||||
|
||||
while (1)
|
||||
{
|
||||
tok = c_lex (&decl);
|
||||
if (tok == CPP_NAME && decl)
|
||||
{
|
||||
tree local = IDENTIFIER_LOCAL_VALUE (decl);
|
||||
if (local && (TREE_CODE (local) == PARM_DECL
|
||||
|| TREE_CODE (local) == VAR_DECL))
|
||||
TREE_USED (local) = 1;
|
||||
tok = c_lex (&x);
|
||||
if (tok != CPP_COMMA)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tok != CPP_CLOSE_PAREN)
|
||||
BAD ("missing ')' after '#pragma unused', ignoring");
|
||||
|
||||
if (c_lex (&x) != CPP_EOF)
|
||||
warning ("junk at end of '#pragma unused'");
|
||||
}
|
@ -56,3 +56,10 @@ extern void darwin_encode_section_info PARAMS ((tree));
|
||||
#endif /* TREE_CODE */
|
||||
|
||||
extern void machopic_finish PARAMS ((FILE *));
|
||||
|
||||
#ifdef GCC_C_PRAGMA_H
|
||||
extern void darwin_init_pragma PARAMS ((int (*) (tree *)));
|
||||
extern void darwin_pragma_ignore PARAMS ((cpp_reader *));
|
||||
extern void darwin_pragma_options PARAMS ((cpp_reader *));
|
||||
extern void darwin_pragma_unused PARAMS ((cpp_reader *));
|
||||
#endif
|
||||
|
@ -780,3 +780,10 @@ enum machopic_addr_class {
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define REGISTER_TARGET_PRAGMAS(PFILE) \
|
||||
do { \
|
||||
cpp_register_pragma (PFILE, 0, "mark", darwin_pragma_ignore); \
|
||||
cpp_register_pragma (PFILE, 0, "options", darwin_pragma_options); \
|
||||
cpp_register_pragma (PFILE, 0, "segment", darwin_pragma_ignore); \
|
||||
cpp_register_pragma (PFILE, 0, "unused", darwin_pragma_unused); \
|
||||
} while (0)
|
||||
|
@ -12,9 +12,14 @@ fp-bit.c: $(srcdir)/config/fp-bit.c
|
||||
|
||||
darwin.o: $(srcdir)/config/darwin.c $(CONFIG_H) $(SYSTEM_H) $(RTL_BASE_H) \
|
||||
$(REGS_H) hard-reg-set.h insn-config.h conditions.h output.h \
|
||||
insn-attr.h flags.h $(TREE_H) $(EXPR_H) reload.h $(C_TREE_H) \
|
||||
insn-attr.h flags.h $(TREE_H) $(EXPR_H) reload.h \
|
||||
function.h $(GGC_H) $(TM_P_H)
|
||||
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(srcdir)/config/darwin.c
|
||||
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
|
||||
|
||||
darwin-c.o: $(srcdir)/config/darwin-c.c $(CONFIG_H) $(SYSTEM_H) \
|
||||
$(TREE_H) $(C_TREE_H) c-lex.h c-pragma.h toplev.h cpplib.h \
|
||||
$(TM_P_H)
|
||||
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
|
||||
|
||||
# Build the libraries for both hard and soft floating point
|
||||
|
||||
|
@ -73,6 +73,7 @@ extensions, accepted by GCC in C89 mode and in C++.
|
||||
function.
|
||||
* Return Address:: Getting the return or frame address of a function.
|
||||
* Other Builtins:: Other built-in functions.
|
||||
* Pragmas:: Pragmas accepted by GCC.
|
||||
@end menu
|
||||
@end ifset
|
||||
@ifclear INTERNALS
|
||||
@ -125,6 +126,7 @@ extensions, accepted by GCC in C89 mode and in C++.
|
||||
function.
|
||||
* Return Address:: Getting the return or frame address of a function.
|
||||
* Other Builtins:: Other built-in functions.
|
||||
* Pragmas:: Pragmas accepted by GCC.
|
||||
@end menu
|
||||
@end ifclear
|
||||
|
||||
@ -3909,6 +3911,83 @@ if (__builtin_expect (ptr != NULL, 1))
|
||||
when testing pointer or floating-point values.
|
||||
@end deftypefn
|
||||
|
||||
@node Pragmas
|
||||
@section Pragmas Accepted by GCC
|
||||
@cindex pragmas
|
||||
@cindex #pragma
|
||||
|
||||
GCC supports several types of pragmas, primarily in order to compile
|
||||
code originally written for other compilers. Note that in general
|
||||
we do not recommend the use of pragmas; @xref{Function Attributes},
|
||||
for further explanation.
|
||||
|
||||
@menu
|
||||
* ARM Pragmas::
|
||||
* Darwin Pragmas::
|
||||
@end menu
|
||||
|
||||
@node ARM Pragmas
|
||||
@subsection ARM Pragmas
|
||||
|
||||
The ARM target defines pragmas for controlling the default addition of
|
||||
@code{long_call} and @code{short_call} attributes to functions.
|
||||
@xref{Function Attributes}, for information about the effects of these
|
||||
attributes.
|
||||
|
||||
@table @code
|
||||
@item long_calls
|
||||
@cindex pragma, long_calls
|
||||
Set all subsequent functions to have the @code{long_call} attribute.
|
||||
|
||||
@item no_long_calls
|
||||
@cindex pragma, no_long_calls
|
||||
Set all subsequent functions to have the @code{short_call} attribute.
|
||||
|
||||
@item long_calls_off
|
||||
@cindex pragma, long_calls_off
|
||||
Do not affect the @code{long_call} or @code{short_call} attributes of
|
||||
subsequent functions.
|
||||
@end table
|
||||
|
||||
@c Describe c4x pragmas here.
|
||||
@c Describe h8300 pragmas here.
|
||||
@c Describe i370 pragmas here.
|
||||
@c Describe i960 pragmas here.
|
||||
@c Describe sh pragmas here.
|
||||
@c Describe v850 pragmas here.
|
||||
|
||||
@node Darwin Pragmas
|
||||
@subsection Darwin Pragmas
|
||||
|
||||
The following pragmas are available for all architectures running the
|
||||
Darwin operating system. These are useful for compatibility with other
|
||||
MacOS compilers.
|
||||
|
||||
@table @code
|
||||
@item mark @var{tokens}@dots{}
|
||||
@cindex pragma, mark
|
||||
This pragma is accepted, but has no effect.
|
||||
|
||||
@item options align=@var{alignment}
|
||||
@cindex pragma, options align
|
||||
This pragma sets the alignment of fields in structures. The values of
|
||||
@var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
|
||||
@code{power}, to emulate PowerPC alignment. Uses of this pragma nest
|
||||
properly; to restore the previous setting, use @code{reset} for the
|
||||
@var{alignment}.
|
||||
|
||||
@item segment @var{tokens}@dots{}
|
||||
@cindex pragma, segment
|
||||
This pragma is accepted, but has no effect.
|
||||
|
||||
@item unused (@var{var} [, @var{var}]@dots{})
|
||||
@cindex pragma, unused
|
||||
This pragma declares variables to be possibly unused. GCC will not
|
||||
produce warnings for the listed variables. The effect is similar to
|
||||
that of the @code{unused} attribute, except that this pragma may appear
|
||||
anywhere within the variables' scopes.
|
||||
@end table
|
||||
|
||||
@node C++ Extensions
|
||||
@chapter Extensions to the C++ Language
|
||||
@cindex extensions, C++ language
|
||||
|
@ -1,3 +1,7 @@
|
||||
2001-06-28 Stan Shebs <shebs@apple.com>
|
||||
|
||||
* gcc.dg/pragma-darwin.c: New test.
|
||||
|
||||
2001-06-28 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
|
||||
|
||||
* lib/objc.exp (objc_target_compile): Don't need -lposix4 on any
|
||||
|
59
gcc/testsuite/gcc.dg/pragma-darwin.c
Normal file
59
gcc/testsuite/gcc.dg/pragma-darwin.c
Normal file
@ -0,0 +1,59 @@
|
||||
/* Darwin (Mac OS X) pragma exercises. */
|
||||
|
||||
/* { dg-do run { target powerpc-*-darwin* } } */
|
||||
/* { dg-options "-O -Wunused" } */
|
||||
|
||||
/* The mark pragma is to help decorate IDEs. */
|
||||
|
||||
#pragma mark hey hey ho
|
||||
|
||||
/* The options pragma used to do a lot, now it's only for emulating
|
||||
m68k alignment rules in structs. */
|
||||
|
||||
#pragma options 23 /* { dg-error "malformed '#pragma options'" } */
|
||||
#pragma options align /* { dg-error "malformed '#pragma options'" } */
|
||||
#pragma options align mac68k /* { dg-error "malformed '#pragma options'" } */
|
||||
#pragma options align=45 /* { dg-error "malformed '#pragma options'" } */
|
||||
#pragma options align=foo /* { dg-error "malformed '#pragma options align" } */
|
||||
|
||||
#pragma options align=mac68k
|
||||
struct s1 { short f1; int f2; };
|
||||
#pragma options align=power
|
||||
struct s2 { short f1; int f2; };
|
||||
#pragma options align=mac68k
|
||||
struct s3 { short f1; int f2; };
|
||||
#pragma options align=reset
|
||||
struct s4 { short f1; int f2; };
|
||||
|
||||
#pragma options align=mac68k foo /* { dg-warning "junk at end of '#pragma options'" } */
|
||||
|
||||
/* Segment pragmas don't do anything anymore. */
|
||||
|
||||
#pragma segment foo
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int x, z; /* { dg-warning "unused variable" } */
|
||||
#pragma unused (x, y)
|
||||
|
||||
if (sizeof (struct s1) != 6)
|
||||
abort ();
|
||||
if (sizeof (struct s2) != 8)
|
||||
abort ();
|
||||
if (sizeof (struct s3) != 6)
|
||||
abort ();
|
||||
if (sizeof (struct s4) != 8)
|
||||
abort ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
unused_err_test ()
|
||||
{
|
||||
int a, b;
|
||||
/* Trying to match on '(' or ')' gives regexp headaches, use . instead. */
|
||||
#pragma unused /* { dg-error "missing '.' after '#pragma unused" } */
|
||||
#pragma unused (a /* { dg-error "missing '.' after '#pragma unused" } */
|
||||
#pragma unused (b) foo /* { dg-warning "junk at end of '#pragma unused'" } */
|
||||
}
|
Loading…
Reference in New Issue
Block a user