OSDN Git Service

PR fortran/20842
[pf3gnuchains/gcc-fork.git] / gcc / c-pragma.c
index c018189..7e028cb 100644 (file)
@@ -1,5 +1,5 @@
 /* Handle #pragma, system V.4 style.  Supports #pragma weak and #pragma pack.
-   Copyright (C) 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+   Copyright (C) 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -16,8 +16,8 @@ for more details.
 
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.  */
+Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.  */
 
 #include "config.h"
 #include "system.h"
@@ -34,10 +34,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "c-common.h"
 #include "output.h"
 #include "tm_p.h"
+#include "vec.h"
 #include "target.h"
 
-#define GCC_BAD(msgid) do { warning (0, msgid); return; } while (0)
-#define GCC_BAD2(msgid, arg) do { warning (0, msgid, arg); return; } while (0)
+#define GCC_BAD(gmsgid) do { warning (0, gmsgid); return; } while (0)
+#define GCC_BAD2(gmsgid, arg) \
+  do { warning (0, gmsgid, arg); return; } while (0)
 
 typedef struct align_stack GTY(())
 {
@@ -257,8 +259,8 @@ apply_pragma_weak (tree decl, tree value)
   if (SUPPORTS_WEAK && DECL_EXTERNAL (decl) && TREE_USED (decl)
       && !DECL_WEAK (decl) /* Don't complain about a redundant #pragma.  */
       && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
-    warning (0, "%Japplying #pragma weak %qD after first use results "
-             "in unspecified behavior", decl, decl);
+    warning (0, "applying #pragma weak %q+D after first use results "
+             "in unspecified behavior", decl);
 
   declare_weak (decl);
 }
@@ -418,7 +420,8 @@ handle_pragma_redefine_extname (cpp_reader * ARG_UNUSED (dummy))
   if (!flag_mudflap && !targetm.handle_pragma_redefine_extname)
     {
       if (warn_unknown_pragmas > in_system_header)
-       warning (0, "#pragma redefine_extname not supported on this target");
+       warning (OPT_Wunknown_pragmas,
+                "#pragma redefine_extname not supported on this target");
       return;
     }
 
@@ -486,7 +489,8 @@ handle_pragma_extern_prefix (cpp_reader * ARG_UNUSED (dummy))
     /* Note that the length includes the null terminator.  */
     pragma_extern_prefix = (TREE_STRING_LENGTH (prefix) > 1 ? prefix : NULL);
   else if (warn_unknown_pragmas > in_system_header)
-    warning (0, "#pragma extern_prefix not supported on this target");
+    warning (OPT_Wunknown_pragmas,
+            "#pragma extern_prefix not supported on this target");
 }
 
 /* Hook from the front ends to apply the results of one of the preceding
@@ -583,15 +587,20 @@ maybe_apply_renaming_pragma (tree decl, tree asmname)
 #ifdef HANDLE_PRAGMA_VISIBILITY
 static void handle_pragma_visibility (cpp_reader *);
 
+typedef enum symbol_visibility visibility;
+DEF_VEC_I (visibility);
+DEF_VEC_ALLOC_I (visibility, heap);
+
 /* Sets the default visibility for symbols to something other than that
    specified on the command line.  */
 static void
 handle_pragma_visibility (cpp_reader *dummy ATTRIBUTE_UNUSED)
-{ /* Form is #pragma GCC visibility push(hidden)|pop */
-  static int visstack [16], visidx;
+{
+  /* Form is #pragma GCC visibility push(hidden)|pop */
   tree x;
   enum cpp_ttype token;
   enum { bad, push, pop } action = bad;
+  static VEC (visibility, heap) *visstack;
  
   token = c_lex (&x);
   if (token == CPP_NAME)
@@ -608,14 +617,15 @@ handle_pragma_visibility (cpp_reader *dummy ATTRIBUTE_UNUSED)
     {
       if (pop == action)
         {
-          if (!visidx)
+          if (!VEC_length (visibility, visstack))
             {
               GCC_BAD ("No matching push for %<#pragma GCC visibility pop%>");
             }
           else
             {
-              default_visibility = visstack[--visidx];
-              visibility_options.inpragma = (visidx>0);
+             default_visibility = VEC_pop (visibility, visstack);
+             visibility_options.inpragma
+               = VEC_length (visibility, visstack) != 0;
             }
         }
       else
@@ -627,14 +637,11 @@ handle_pragma_visibility (cpp_reader *dummy ATTRIBUTE_UNUSED)
             {
               GCC_BAD ("malformed #pragma GCC visibility push");
             }
-          else if (visidx >= 16)
-            {
-              GCC_BAD ("No more than sixteen #pragma GCC visibility pushes allowed at once");
-            }
           else
             {
               const char *str = IDENTIFIER_POINTER (x);
-              visstack[visidx++] = default_visibility;
+             VEC_safe_push (visibility, heap, visstack,
+                            default_visibility);
               if (!strcmp (str, "default"))
                 default_visibility = VISIBILITY_DEFAULT;
               else if (!strcmp (str, "internal"))