This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
merge visibility attribute
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 05 Dec 2003 22:59:51 -0200
- Subject: merge visibility attribute
- Organization: GCC Team, Red Hat
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