c-common.c (targetcm): Add.
authorMike Stump <mrs@apple.com>
Tue, 6 Mar 2007 00:48:47 +0000 (00:48 +0000)
committerMike Stump <mrs@gcc.gnu.org>
Tue, 6 Mar 2007 00:48:47 +0000 (00:48 +0000)
* 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.

From-SVN: r122590

14 files changed:
gcc/ChangeLog
gcc/c-common.c
gcc/c-opts.c
gcc/config/darwin-c.c
gcc/config/darwin.h
gcc/config/darwin.opt
gcc/doc/invoke.texi
gcc/doc/tm.texi
gcc/opth-gen.awk
gcc/opts.c
gcc/target-def.h
gcc/target.h
gcc/targhooks.c
gcc/targhooks.h

index f6a9af9a8541966b6ba9b0576e1880ad79dbc81f..7ebd9d3641990b2b2eeb6cb81871c20ebf03d442 100644 (file)
@@ -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
index 523ef464be565f20fbf8dec5f5d745930073effd..1a35af79ffaaa1a95783013e8a9b1dcb40da081b 100644 (file)
@@ -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"
index 11dcf0a0bdec0ee2aeb208cf4a2a729474fb60b6..bddbaad9d7f69d48e25ff4210c86c403024ca799 100644 (file)
@@ -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;
index eefd5f6fc5fdd02f34005f6c17d367074567af04..dc03a9d96be4d7a36665868e4bf6215da24990ab 100644 (file)
@@ -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;
index a1cc46cf43bef014927f67817f212c5b5ab7d3e8..3d93399531323b11321cc61efdb8df61f9609bd0 100644 (file)
@@ -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 */
index 28dd1c4cfa938b7a1d3b132b6e3b89f4f29135f0..b27b3db75caac5cee03358719122ff82475c5573 100644 (file)
@@ -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
index 85416349542e3bb4c3c05f4630d63a53fd57a0b8..3d5c06ce3cf0977976edd2ef867d93a7d49c5e3e 100644 (file)
@@ -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
index 2d9ef64eb4798f28e1a727ca9a8094b6d8a79680..c5920d09f5166982054da581a209be56add9355c 100644 (file)
@@ -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
index e7ffc1a646ebbc96ff69e52a3b19544f634285e5..97abcf06b7a6ead19b99acb9605e61707d7ad2e2 100644 (file)
@@ -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"
index c84bc2a3c3593fe59356ed7e266f6572b6e34da7..d3aea98ce98693c6e715c36fade7e290c36d830d 100644 (file)
@@ -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)))
     {
index c9d5180840d25352c34b6026b16965056de08013..fb9af5a576abc93166827bc66f786f92b744d59a 100644 (file)
@@ -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"
index d312c9f88f1ce8600fa666395f238c130e477be9..029d1836d53d327dee4a18680e0413155964fb12 100644 (file)
@@ -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 */
index 982fcdb188ed030f1d2edb1b041dc794bb566087..f1e4637c0bbd18f56c3f297bc1822742e7dd44d9 100644 (file)
@@ -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"
index b6bd700009742ff53f8d32400e95e4fdaf2addf6..33b534803e083cd84edf9f051ded54c46f80b364 100644 (file)
@@ -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);