summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-06 00:48:47 +0000
committermrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-06 00:48:47 +0000
commitb9fc964a00ea1c9cbcc1b6ac7ca39cbf550a77b7 (patch)
tree926625ccb9f896a1998fbb4c463fe5a2b9ccaf39
parentb3487c3a5d9f1742cb449bbc85c2134d6ffab5c0 (diff)
downloadgcc-b9fc964a00ea1c9cbcc1b6ac7ca39cbf550a77b7.tar.gz
* c-common.c (targetcm): Add.
* c-opts.c (c_common_handle_option): Handle language specific target options. * opts.c (handle_option): Verify language for target options, if any are given. * opth-gen.awk: Add CL_LANG_ALL. * target-def.h (TARGET_HANDLE_C_OPTION): Add. (TARGETCM_INITIALIZER): Add. * target.h (struct gcc_targetcm): Add. (targetcm): Add. * targhooks.c (default_handle_c_option): Add. * targhooks.h (default_handle_c_option): Add. * doc/tm.texi (TARGET_HANDLE_C_OPTION): Add. * config/darwin.opt (iframework): Add. * config/darwin.h (TARGET_HAS_TARGETCM): Add. * config/darwin-c.c (handle_c_option): Add. (TARGET_HANDLE_C_OPTION): Add. (targetcm): Add. * doc/invoke.texi (Darwin Options): Add -iframework. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122590 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog23
-rw-r--r--gcc/c-common.c5
-rw-r--r--gcc/c-opts.c8
-rw-r--r--gcc/config/darwin-c.c40
-rw-r--r--gcc/config/darwin.h2
-rw-r--r--gcc/config/darwin.opt4
-rw-r--r--gcc/doc/invoke.texi9
-rw-r--r--gcc/doc/tm.texi13
-rw-r--r--gcc/opth-gen.awk1
-rw-r--r--gcc/opts.c9
-rw-r--r--gcc/target-def.h3
-rw-r--r--gcc/target.h12
-rw-r--r--gcc/targhooks.c8
-rw-r--r--gcc/targhooks.h1
14 files changed, 130 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f6a9af9a854..7ebd9d36419 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,26 @@
+2007-03-05 Mike Stump <mrs@apple.com>
+
+ * c-common.c (targetcm): Add.
+ * c-opts.c (c_common_handle_option): Handle language specific
+ target options.
+ * opts.c (handle_option): Verify language for target options, if
+ any are given.
+ * opth-gen.awk: Add CL_LANG_ALL.
+ * target-def.h (TARGET_HANDLE_C_OPTION): Add.
+ (TARGETCM_INITIALIZER): Add.
+ * target.h (struct gcc_targetcm): Add.
+ (targetcm): Add.
+ * targhooks.c (default_handle_c_option): Add.
+ * targhooks.h (default_handle_c_option): Add.
+ * doc/tm.texi (TARGET_HANDLE_C_OPTION): Add.
+
+ * config/darwin.opt (iframework): Add.
+ * config/darwin.h (TARGET_HAS_TARGETCM): Add.
+ * config/darwin-c.c (handle_c_option): Add.
+ (TARGET_HANDLE_C_OPTION): Add.
+ (targetcm): Add.
+ * doc/invoke.texi (Darwin Options): Add -iframework.
+
2007-03-05 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* convert.c (convert_to_integer): Fix nearbyint/rint -> *lrint
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 523ef464be5..1a35af79ffa 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -48,6 +48,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#include "opts.h"
#include "real.h"
#include "cgraph.h"
+#include "target-def.h"
cpp_reader *parse_in; /* Declared in c-pragma.h. */
@@ -6926,4 +6927,8 @@ c_build_cdtor_fns (void)
}
}
+#ifndef TARGET_HAS_TARGETCM
+struct gcc_targetcm targetcm = TARGETCM_INITIALIZER;
+#endif
+
#include "gt-c-common.h"
diff --git a/gcc/c-opts.c b/gcc/c-opts.c
index 11dcf0a0bde..bddbaad9d7f 100644
--- a/gcc/c-opts.c
+++ b/gcc/c-opts.c
@@ -39,6 +39,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#include "opts.h"
#include "options.h"
#include "mkdeps.h"
+#include "target.h"
#ifndef DOLLARS_IN_IDENTIFIERS
# define DOLLARS_IN_IDENTIFIERS true
@@ -278,7 +279,12 @@ c_common_handle_option (size_t scode, const char *arg, int value)
{
default:
if (cl_options[code].flags & (CL_C | CL_CXX | CL_ObjC | CL_ObjCXX))
- break;
+ {
+ if ((option->flags & CL_TARGET)
+ && ! targetcm.handle_c_option (scode, arg, value))
+ result = 0;
+ break;
+ }
#ifdef CL_Fortran
if (lang_fortran && (cl_options[code].flags & (CL_Fortran)))
break;
diff --git a/gcc/config/darwin-c.c b/gcc/config/darwin-c.c
index eefd5f6fc5f..dc03a9d96be 100644
--- a/gcc/config/darwin-c.c
+++ b/gcc/config/darwin-c.c
@@ -34,6 +34,8 @@ Boston, MA 02110-1301, USA. */
#include "tm_p.h"
#include "cppdefault.h"
#include "prefix.h"
+#include "target.h"
+#include "target-def.h"
/* Pragmas. */
@@ -42,13 +44,6 @@ Boston, MA 02110-1301, USA. */
static bool using_frameworks = false;
-/* Maintain a small stack of alignments. This is similar to pragma
- pack's stack, but simpler. */
-
-static void push_field_alignment (int);
-static void pop_field_alignment (void);
-static const char *find_subframework_file (const char *, const char *);
-static void add_system_framework_path (char *);
static const char *find_subframework_header (cpp_reader *pfile, const char *header,
cpp_dir **dirp);
@@ -60,6 +55,9 @@ typedef struct align_stack
static struct align_stack * field_align_stack = NULL;
+/* Maintain a small stack of alignments. This is similar to pragma
+ pack's stack, but simpler. */
+
static void
push_field_alignment (int bit_alignment)
{
@@ -619,3 +617,31 @@ darwin_cpp_builtins (cpp_reader *pfile)
builtin_define_with_value ("__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__",
version_as_macro(), false);
}
+
+/* Handle C family front-end options. */
+
+static bool
+handle_c_option (size_t code,
+ const char *arg,
+ int value ATTRIBUTE_UNUSED)
+{
+ switch (code)
+ {
+ default:
+ /* Unrecognized options that we said we'd handle turn into
+ errors if not listed here. */
+ return false;
+
+ case OPT_iframework:
+ add_system_framework_path (xstrdup (arg));
+ break;
+ }
+
+ /* We recognized the option. */
+ return true;
+}
+
+#undef TARGET_HANDLE_C_OPTION
+#define TARGET_HANDLE_C_OPTION handle_c_option
+
+struct gcc_targetcm targetcm = TARGETCM_INITIALIZER;
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index a1cc46cf43b..3d933995313 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -980,4 +980,6 @@ extern int flag_mkernel;
extern int flag_apple_kext;
#define TARGET_KEXTABI flag_apple_kext
+#define TARGET_HAS_TARGETCM 1
+
#endif /* CONFIG_DARWIN_H */
diff --git a/gcc/config/darwin.opt b/gcc/config/darwin.opt
index 28dd1c4cfa9..b27b3db75ca 100644
--- a/gcc/config/darwin.opt
+++ b/gcc/config/darwin.opt
@@ -42,3 +42,7 @@ Generate code for darwin loadable kernel extensions
mkernel
Target Report Var(flag_mkernel)
Generate code for the kernel or loadable kernel extensions
+
+iframework
+Target RejectNegative C ObjC C++ ObjC++ Joined Separate
+-iframework <dir> Add <dir> to the end of the system framework include path
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 85416349542..3d5c06ce3cf 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -462,6 +462,7 @@ Objective-C and Objective-C++ Dialects}.
-dynamic -dynamiclib -exported_symbols_list @gol
-filelist -flat_namespace -force_cpusubtype_ALL @gol
-force_flat_namespace -headerpad_max_install_names @gol
+-iframework @gol
-image_base -init -install_name -keep_private_externs @gol
-multi_module -multiply_defined -multiply_defined_unused @gol
-noall_load -no_dead_strip_inits_and_terms @gol
@@ -8463,6 +8464,14 @@ in @samp{"/System/Library/Frameworks"} and
the name of the framework and header.h is found in the
@samp{"PrivateHeaders"} or @samp{"Headers"} directory.
+@item -iframework@var{dir}
+@opindex iframework
+Like @option{-F} except the directory is a treated as a system
+directory. The main difference between this @option{-iframework} and
+@option{-F} is that with @option{-iframework} the compiler does not
+warn about constructs contained within header files found via
+@var{dir}. This option is valid only for the C family of languages.
+
@item -gused
@opindex -gused
Emit debugging information for symbols that are used. For STABS
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 2d9ef64eb47..c5920d09f51 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -773,6 +773,19 @@ argument. Otherwise @var{value} is 1 if the positive form of the
option was used and 0 if the ``no-'' form was.
@end deftypefn
+@deftypefn {Target Hook} bool TARGET_HANDLE_C_OPTION (size_t @var{code}, const char *@var{arg}, int @var{value})
+This target hook is called whenever the user specifies one of the
+target-specific C language family options described by the @file{.opt}
+definition files(@pxref{Options}). It has the opportunity to do some
+option-specific processing and should return true if the option is
+valid. The default definition does nothing but return false.
+
+In general, you should use @code{TARGET_HANDLE_OPTION} to handle
+options. However, if processing an option requires routines that are
+only available in the C (and related language) front ends, then you
+should use @code{TARGET_HANDLE_C_OPTION} instead.
+@end deftypefn
+
@defmac TARGET_VERSION
This macro is a C statement to print on @code{stderr} a string
describing the particular machine description choice. Every machine
diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk
index e7ffc1a646e..97abcf06b7a 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -139,6 +139,7 @@ for (i = 0; i < n_langs; i++) {
s = substr(" ", length (macros[i]))
print "#define " macros[i] s " (1 << " i ")"
}
+print "#define CL_LANG_ALL ((1 << " n_langs ") - 1)"
print ""
print "enum opt_code"
diff --git a/gcc/opts.c b/gcc/opts.c
index c84bc2a3c35..d3aea98ce98 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -268,6 +268,15 @@ handle_option (const char **argv, unsigned int lang_mask)
complain_wrong_lang (argv[0], option, lang_mask);
goto done;
}
+ else if ((option->flags & CL_TARGET)
+ && (option->flags & CL_LANG_ALL)
+ && !(option->flags & lang_mask))
+ {
+ /* Complain for target flag language mismatches if any languages
+ are specified. */
+ complain_wrong_lang (argv[0], option, lang_mask);
+ goto done;
+ }
if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
{
diff --git a/gcc/target-def.h b/gcc/target-def.h
index c9d5180840d..fb9af5a576a 100644
--- a/gcc/target-def.h
+++ b/gcc/target-def.h
@@ -730,5 +730,8 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
TARGET_ARM_EABI_UNWINDER \
}
+#define TARGET_HANDLE_C_OPTION default_handle_c_option
+#define TARGETCM_INITIALIZER { TARGET_HANDLE_C_OPTION }
+
#include "hooks.h"
#include "targhooks.h"
diff --git a/gcc/target.h b/gcc/target.h
index d312c9f88f1..029d1836d53 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -892,4 +892,16 @@ struct gcc_target
extern struct gcc_target targetm;
+struct gcc_targetcm {
+ /* Handle target switch CODE (an OPT_* value). ARG is the argument
+ passed to the switch; it is NULL if no argument was. VALUE is the
+ value of ARG if CODE specifies a UInteger option, otherwise it is
+ 1 if the positive form of the switch was used and 0 if the negative
+ form was. Return true if the switch was valid. */
+ bool (*handle_c_option) (size_t code, const char *arg, int value);
+};
+
+/* Each target can provide their own. */
+extern struct gcc_targetcm targetcm;
+
#endif /* GCC_TARGET_H */
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
index 982fcdb188e..f1e4637c0bb 100644
--- a/gcc/targhooks.c
+++ b/gcc/targhooks.c
@@ -614,4 +614,12 @@ default_narrow_bitfield (void)
return !STRICT_ALIGNMENT;
}
+bool
+default_handle_c_option (size_t code ATTRIBUTE_UNUSED,
+ const char *arg ATTRIBUTE_UNUSED,
+ int value ATTRIBUTE_UNUSED)
+{
+ return false;
+}
+
#include "gt-targhooks.h"
diff --git a/gcc/targhooks.h b/gcc/targhooks.h
index b6bd7000097..33b534803e0 100644
--- a/gcc/targhooks.h
+++ b/gcc/targhooks.h
@@ -82,3 +82,4 @@ extern enum reg_class default_secondary_reload (bool, rtx, enum reg_class,
enum machine_mode,
secondary_reload_info *);
extern void hook_void_bitmap (bitmap);
+extern bool default_handle_c_option (size_t, const char *, int);