This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

merge visibility attribute


The recent visibility attribute rewrite broke merging of the
visibility attribute when merging multiple declarations of the same
name.  This patch fixes it.  Bootstrapped on i686-pc-linux-gnu.  Ok to
install?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* c-decl.c (duplicate_decls): Merge visibility attributes.

Index: gcc/c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.458
diff -u -p -r1.458 c-decl.c
--- gcc/c-decl.c 24 Nov 2003 20:12:05 -0000 1.458
+++ gcc/c-decl.c 5 Dec 2003 19:52:01 -0000
@@ -1257,6 +1257,54 @@ duplicate_decls (tree newdecl, tree oldd
 	    TREE_TYPE (newdecl)
 	      = TREE_TYPE (olddecl)
 		= common_type (newtype, oldtype);
+
+	  /* Merge visibility attributes.  */
+	  if (DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl)
+	      && DECL_VISIBILITY (olddecl) != VISIBILITY_DEFAULT)
+	    {
+	      if (DECL_VISIBILITY (newdecl) == VISIBILITY_DEFAULT)
+		DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl);
+	      else
+		{
+		  const char *vis;
+
+		  switch (DECL_VISIBILITY (newdecl))
+		    {
+		    case VISIBILITY_INTERNAL:
+		      vis = "internal";
+		      break;
+		    case VISIBILITY_HIDDEN:
+		      vis = "hidden";
+		      break;
+		    case VISIBILITY_PROTECTED:
+		      vis = "protected";
+		      break;
+		    default:
+		      abort ();
+		    }
+
+		  error ("%Jconflicting visibility(\"%s\") attribute for `%D'",
+			 newdecl, vis, newdecl);
+
+		  switch (DECL_VISIBILITY (olddecl))
+		    {
+		    case VISIBILITY_INTERNAL:
+		      vis = "internal";
+		      break;
+		    case VISIBILITY_HIDDEN:
+		      vis = "hidden";
+		      break;
+		    case VISIBILITY_PROTECTED:
+		      vis = "protected";
+		      break;
+		    default:
+		      abort ();
+		    }
+
+		  error ("%Jprevious declaration had visibility(\"%s\")",
+			 olddecl, vis);
+		}
+	    }
 	}
 
       /* Lay the type out, unless already done.  */
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]