public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [ADA PATCH]: Fix -Wc++-compat warnings in the ada directory
@ 2008-06-27  0:44 Kaveh R. GHAZI
  2008-06-27  7:49 ` Arnaud Charlet
  0 siblings, 1 reply; 2+ messages in thread
From: Kaveh R. GHAZI @ 2008-06-27  0:44 UTC (permalink / raw)
  To: charlet, gcc-patches

This patch cleans up the -Wc++-compat warnings in the ada directory. Note
adaint.c cannot use the libiberty allocator macros because it seems that
it's used on the host as well as the target.  In the target case it does
not include libiberty.h to get the macros, so I used casts in that file.

Tested by bootstrapping on x86_64-unknown-linux-gnu with languages=c,ada
and there were no unexpected failures in the gnat or acats testsuites.

Okay for mainline?

		Thanks,
		--Kaveh


2008-06-26  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* ada-tree.h (SET_TYPE_LANG_SPECIFIC, SET_DECL_LANG_SPECIFIC): Fix
	-Wc++-compat warnings.
	* adaint.c (__gnat_locate_regular_file, __gnat_locate_exec,
	__gnat_locate_exec_on_path): Likewise.
	* decl.c (annotate_value): Likewise.
	* misc.c (gnat_handle_option): Likewise.
	* trans.c (gnat_to_gnu, extract_encoding, decode_name,
	post_error_ne_tree): Likewise.

diff -rup orig/egcc-SVN20080626/gcc/ada/ada-tree.h egcc-SVN20080626/gcc/ada/ada-tree.h
--- orig/egcc-SVN20080626/gcc/ada/ada-tree.h	2008-06-22 02:02:33.000000000 +0200
+++ egcc-SVN20080626/gcc/ada/ada-tree.h	2008-06-26 18:46:11.000000000 +0200
@@ -39,7 +39,7 @@ struct lang_type GTY(()) {tree t; };
 #define SET_TYPE_LANG_SPECIFIC(NODE, X)	\
  (TYPE_LANG_SPECIFIC (NODE)			\
   = (TYPE_LANG_SPECIFIC (NODE)			\
-     ? TYPE_LANG_SPECIFIC (NODE) : ggc_alloc (sizeof (struct lang_type))))   \
+     ? TYPE_LANG_SPECIFIC (NODE) : GGC_NEW (struct lang_type)))   \
  ->t = X;

 #define GET_DECL_LANG_SPECIFIC(NODE) \
@@ -47,7 +47,7 @@ struct lang_type GTY(()) {tree t; };
 #define SET_DECL_LANG_SPECIFIC(NODE, VALUE)	\
  (DECL_LANG_SPECIFIC (NODE)			\
   = (DECL_LANG_SPECIFIC (NODE)			\
-     ? DECL_LANG_SPECIFIC (NODE) : ggc_alloc (sizeof (struct lang_decl))))   \
+     ? DECL_LANG_SPECIFIC (NODE) : GGC_NEW (struct lang_decl)))   \
  ->t = VALUE;

 /* Flags added to GCC type nodes.  */
diff -rup orig/egcc-SVN20080626/gcc/ada/adaint.c egcc-SVN20080626/gcc/ada/adaint.c
--- orig/egcc-SVN20080626/gcc/ada/adaint.c	2008-05-21 02:02:41.000000000 +0200
+++ egcc-SVN20080626/gcc/ada/adaint.c	2008-06-27 00:23:47.000000000 +0200
@@ -2147,7 +2147,7 @@ char *
 __gnat_locate_regular_file (char *file_name, char *path_val)
 {
   char *ptr;
-  char *file_path = alloca (strlen (file_name) + 1);
+  char *file_path = (char *) alloca (strlen (file_name) + 1);
   int absolute;

   /* Return immediately if file_name is empty */
@@ -2196,7 +2196,7 @@ __gnat_locate_regular_file (char *file_n

   {
     /* The result has to be smaller than path_val + file_name.  */
-    char *file_path = alloca (strlen (path_val) + strlen (file_name) + 2);
+    char *file_path = (char *) alloca (strlen (path_val) + strlen (file_name) + 2);

     for (;;)
       {
@@ -2245,7 +2245,7 @@ __gnat_locate_exec (char *exec_name, cha
   if (!strstr (exec_name, HOST_EXECUTABLE_SUFFIX))
     {
       char *full_exec_name
-        = alloca (strlen (exec_name) + strlen (HOST_EXECUTABLE_SUFFIX) + 1);
+        = (char *) alloca (strlen (exec_name) + strlen (HOST_EXECUTABLE_SUFFIX) + 1);

       strcpy (full_exec_name, exec_name);
       strcat (full_exec_name, HOST_EXECUTABLE_SUFFIX);
@@ -2298,7 +2298,7 @@ __gnat_locate_exec_on_path (char *exec_n
   char *path_val = getenv ("PATH");
 #endif
   if (path_val == NULL) return NULL;
-  apath_val = alloca (strlen (path_val) + 1);
+  apath_val = (char *) alloca (strlen (path_val) + 1);
   strcpy (apath_val, path_val);
   return __gnat_locate_exec (exec_name, apath_val);
 #endif
diff -rup orig/egcc-SVN20080626/gcc/ada/decl.c egcc-SVN20080626/gcc/ada/decl.c
--- orig/egcc-SVN20080626/gcc/ada/decl.c	2008-06-14 02:02:05.000000000 +0200
+++ egcc-SVN20080626/gcc/ada/decl.c	2008-06-26 18:46:11.000000000 +0200
@@ -6774,7 +6774,7 @@ annotate_value (tree gnu_size)
   /* Save the result in the cache.  */
   if (h)
     {
-      *h = ggc_alloc (sizeof (struct tree_int_map));
+      *h = GGC_NEW (struct tree_int_map);
       (*h)->base.from = gnu_size;
       (*h)->to = ret;
     }
diff -rup orig/egcc-SVN20080626/gcc/ada/misc.c egcc-SVN20080626/gcc/ada/misc.c
--- orig/egcc-SVN20080626/gcc/ada/misc.c	2008-06-22 02:02:33.000000000 +0200
+++ egcc-SVN20080626/gcc/ada/misc.c	2008-06-26 18:46:11.000000000 +0200
@@ -232,7 +232,7 @@ gnat_handle_option (size_t scode, const
   switch (code)
     {
     case OPT_I:
-      q = xmalloc (sizeof("-I") + strlen (arg));
+      q = XNEWVEC (char, sizeof("-I") + strlen (arg));
       strcpy (q, "-I");
       strcat (q, arg);
       gnat_argv[gnat_argc] = q;
@@ -289,7 +289,7 @@ gnat_handle_option (size_t scode, const

     case OPT_gnat:
       /* Recopy the switches without the 'gnat' prefix.  */
-      gnat_argv[gnat_argc] = xmalloc (strlen (arg) + 2);
+      gnat_argv[gnat_argc] = XNEWVEC (char, strlen (arg) + 2);
       gnat_argv[gnat_argc][0] = '-';
       strcpy (gnat_argv[gnat_argc] + 1, arg);
       gnat_argc++;
diff -rup orig/egcc-SVN20080626/gcc/ada/trans.c egcc-SVN20080626/gcc/ada/trans.c
--- orig/egcc-SVN20080626/gcc/ada/trans.c	2008-06-07 02:02:42.000000000 +0200
+++ egcc-SVN20080626/gcc/ada/trans.c	2008-06-26 18:46:11.000000000 +0200
@@ -3273,7 +3273,7 @@ gnat_to_gnu (Node_Id gnat_node)
 	  int i;
 	  char *string;
 	  if (length >= ALLOCA_THRESHOLD)
-             string = xmalloc (length + 1); /* in case of large strings */
+             string = XNEWVEC (char, length + 1); /* in case of large strings */
           else
              string = (char *) alloca (length + 1);

@@ -6922,7 +6922,7 @@ set_expr_location_from_node (tree node,
 static const char *
 extract_encoding (const char *name)
 {
-  char *encoding = ggc_alloc (strlen (name));
+  char *encoding = GGC_NEWVEC (char, strlen (name));

   get_encoding (name, encoding);

@@ -6934,7 +6934,7 @@ extract_encoding (const char *name)
 static const char *
 decode_name (const char *name)
 {
-  char *decoded = ggc_alloc (strlen (name) * 2 + 60);
+  char *decoded = GGC_NEWVEC (char, strlen (name) * 2 + 60);

   __gnat_decode (name, decoded, 0);

@@ -6998,7 +6998,7 @@ post_error_ne_num (const char *msg, Node
 void
 post_error_ne_tree (const char *msg, Node_Id node, Entity_Id ent, tree t)
 {
-  char *newmsg = alloca (strlen (msg) + 1);
+  char *newmsg = XALLOCAVEC (char, strlen (msg) + 1);
   String_Template temp = {1, 0};
   Fat_Pointer fp;
   char start_yes, end_yes, start_no, end_no;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ADA PATCH]: Fix -Wc++-compat warnings in the ada directory
  2008-06-27  0:44 [ADA PATCH]: Fix -Wc++-compat warnings in the ada directory Kaveh R. GHAZI
@ 2008-06-27  7:49 ` Arnaud Charlet
  0 siblings, 0 replies; 2+ messages in thread
From: Arnaud Charlet @ 2008-06-27  7:49 UTC (permalink / raw)
  To: Kaveh R. GHAZI; +Cc: charlet, gcc-patches

> This patch cleans up the -Wc++-compat warnings in the ada directory. Note
> adaint.c cannot use the libiberty allocator macros because it seems that
> it's used on the host as well as the target.  In the target case it does
> not include libiberty.h to get the macros, so I used casts in that file.
> 
> Tested by bootstrapping on x86_64-unknown-linux-gnu with languages=c,ada
> and there were no unexpected failures in the gnat or acats testsuites.
> 
> Okay for mainline?

Patch is OK.

Arno

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-06-27  7:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-27  0:44 [ADA PATCH]: Fix -Wc++-compat warnings in the ada directory Kaveh R. GHAZI
2008-06-27  7:49 ` Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).