* cgraph.h (struct cgraph_node): Remove externally_visible
bitfield.
* cgraphunit.c (process_function_and_variable_attributes): Set
local.externally_visible rather than externally_visible.
PR c/28744
* c-common.c (handle_externally_visible_attribute): First look
at TREE_CODE and only if it is function or var decl, check for
non-public objects. Don't warn for DECL_EXTERNAL.
* cgraphunit.c (process_function_and_variable_attributes): Warn
if externally_visible attribute is used on non-public object.
* gcc.dg/attr-externally-visible-1.c: New test.
* gcc.dg/attr-externally-visible-2.c: New test.
* g++.dg/parse/attr-externally-visible-1.C: New test.
* g++.dg/parse/attr-externally-visible-2.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116222
138bc75d-0d04-0410-961f-
82ee72b054a4
+2006-08-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/28744
+ * cgraph.h (struct cgraph_node): Remove externally_visible
+ bitfield.
+ * cgraphunit.c (process_function_and_variable_attributes): Set
+ local.externally_visible rather than externally_visible.
+
+ PR c/28744
+ * c-common.c (handle_externally_visible_attribute): First look
+ at TREE_CODE and only if it is function or var decl, check for
+ non-public objects. Don't warn for DECL_EXTERNAL.
+ * cgraphunit.c (process_function_and_variable_attributes): Warn
+ if externally_visible attribute is used on non-public object.
+
2006-08-17 Jan Hubicka <jh@suse.cz>
PR tree-optimization/27865
{
tree node = *pnode;
- if ((!TREE_STATIC (node) && TREE_CODE (node) != FUNCTION_DECL)
- || !TREE_PUBLIC (node))
+ if (TREE_CODE (node) == FUNCTION_DECL || TREE_CODE (node) == VAR_DECL)
{
- warning (OPT_Wattributes,
- "%qE attribute have effect only on public objects", name);
- *no_add_attrs = true;
+ if ((!TREE_STATIC (node) && TREE_CODE (node) != FUNCTION_DECL
+ && !DECL_EXTERNAL (node)) || !TREE_PUBLIC (node))
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute have effect only on public objects", name);
+ *no_add_attrs = true;
+ }
}
- else if (TREE_CODE (node) == FUNCTION_DECL
- || TREE_CODE (node) == VAR_DECL)
- ;
else
{
warning (OPT_Wattributes, "%qE attribute ignored", name);
unsigned analyzed : 1;
/* Set when function is scheduled to be assembled. */
unsigned output : 1;
- /* Set when function is visible by other units. */
- unsigned externally_visible : 1;
/* Set for aliases once they got through assemble_alias. */
unsigned alias : 1;
}
if (lookup_attribute ("externally_visible", DECL_ATTRIBUTES (decl)))
{
- if (node->local.finalized)
- cgraph_mark_needed_node (node);
- node->externally_visible = true;
+ if (! TREE_PUBLIC (node->decl))
+ warning (OPT_Wattributes,
+ "%J%<externally_visible%> attribute have effect only on public objects",
+ node->decl);
+ else
+ {
+ if (node->local.finalized)
+ cgraph_mark_needed_node (node);
+ node->local.externally_visible = true;
+ }
}
}
for (vnode = cgraph_varpool_nodes; vnode != first_var; vnode = vnode->next)
}
if (lookup_attribute ("externally_visible", DECL_ATTRIBUTES (decl)))
{
- if (vnode->finalized)
- cgraph_varpool_mark_needed_node (vnode);
- vnode->externally_visible = true;
+ if (! TREE_PUBLIC (vnode->decl))
+ warning (OPT_Wattributes,
+ "%J%<externally_visible%> attribute have effect only on public objects",
+ vnode->decl);
+ else
+ {
+ if (vnode->finalized)
+ cgraph_varpool_mark_needed_node (vnode);
+ vnode->externally_visible = true;
+ }
}
}
}
+2006-08-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/28744
+ * gcc.dg/attr-externally-visible-1.c: New test.
+ * gcc.dg/attr-externally-visible-2.c: New test.
+ * g++.dg/parse/attr-externally-visible-1.C: New test.
+ * g++.dg/parse/attr-externally-visible-2.C: New test.
+
2006-08-17 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/28606
--- /dev/null
+// { dg-do compile }
+// { dg-options "-O3 -fwhole-program" }
+// { dg-final { scan-assembler "foo1" } }
+// { dg-final { scan-assembler "foo2" } }
+// { dg-final { scan-assembler "foo3" } }
+// { dg-final { scan-assembler "foo4" } }
+// { dg-final { scan-assembler "foo5" } }
+// { dg-final { scan-assembler-not "foo6" } }
+// { dg-final { scan-assembler "bar1" } }
+// { dg-final { scan-assembler "bar2" } }
+// { dg-final { scan-assembler "bar3" } }
+// { dg-final { scan-assembler "bar4" } }
+// { dg-final { scan-assembler "bar5" } }
+// { dg-final { scan-assembler-not "bar6" } }
+
+extern void foo1 (void) __attribute__((externally_visible));
+void foo1 (void) { }
+
+extern void foo2 (void) __attribute__((externally_visible));
+__attribute__((externally_visible)) void foo2 (void) { }
+
+extern void foo3 (void);
+__attribute__((externally_visible)) void foo3 (void) { }
+
+__attribute__((externally_visible)) void foo4 (void) { }
+
+void foo5 (void) { }
+extern void foo5 (void) __attribute__((externally_visible));
+
+void foo6 (void) { }
+
+extern char *bar1 __attribute__((externally_visible));
+char *bar1;
+
+extern char *bar2 __attribute__((externally_visible));
+char *bar2 __attribute__((externally_visible));
+
+extern char *bar3;
+char *bar3 __attribute__((externally_visible));
+
+char *bar4 __attribute__((externally_visible));
+
+char *bar5;
+extern char *bar5 __attribute__((externally_visible));
+
+char *bar6;
+
+int main (void) { }
--- /dev/null
+// { dg-do compile }
+// { dg-options "-O -fwhole-program" }
+
+static void foo1 (void) { } // { dg-warning "have effect only on public" }
+extern void foo1 (void) __attribute__((externally_visible));
+
+struct C
+{
+ __attribute__((externally_visible)) void foo3 (void) { }
+};
+
+__attribute__((externally_visible)) static void foo3 (void) { } // { dg-warning "have effect only on public" }
+
+static int bar1;
+extern int bar1 __attribute__((externally_visible)); // { dg-warning "have effect only on public" }
+
+static int bar2 __attribute__((externally_visible)); // { dg-warning "have effect only on public" }
+
+void fn1 (void)
+{
+ static int bar3 __attribute__((externally_visible)); // { dg-warning "have effect only on public" }
+}
+
+void fn2 (void)
+{
+ int bar4 __attribute__((externally_visible)); // { dg-warning "have effect only on public" }
+}
+
+struct A
+{
+} __attribute__((externally_visible)); // { dg-warning "does not apply to types" }
+
+typedef int B __attribute__((externally_visible)); // { dg-warning "attribute ignored" }
+
+struct D
+{
+ static int d __attribute__((externally_visible));
+};
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O3 -fwhole-program" } */
+/* { dg-final { scan-assembler "foo1" } } */
+/* { dg-final { scan-assembler "foo2" } } */
+/* { dg-final { scan-assembler "foo3" } } */
+/* { dg-final { scan-assembler "foo4" } } */
+/* { dg-final { scan-assembler "foo5" } } */
+/* { dg-final { scan-assembler-not "foo6" } } */
+/* { dg-final { scan-assembler "bar1" } } */
+/* { dg-final { scan-assembler "bar2" } } */
+/* { dg-final { scan-assembler "bar3" } } */
+/* { dg-final { scan-assembler "bar4" } } */
+/* { dg-final { scan-assembler "bar5" } } */
+/* { dg-final { scan-assembler-not "bar6" } } */
+
+extern void foo1 (void) __attribute__((externally_visible));
+void foo1 (void) { }
+
+extern void foo2 (void) __attribute__((externally_visible));
+__attribute__((externally_visible)) void foo2 (void) { }
+
+extern void foo3 (void);
+__attribute__((externally_visible)) void foo3 (void) { }
+
+__attribute__((externally_visible)) void foo4 (void) { }
+
+void foo5 (void) { }
+extern void foo5 (void) __attribute__((externally_visible));
+
+void foo6 (void) { }
+
+extern char *bar1 __attribute__((externally_visible));
+char *bar1;
+
+extern char *bar2 __attribute__((externally_visible));
+char *bar2 __attribute__((externally_visible));
+
+extern char *bar3;
+char *bar3 __attribute__((externally_visible));
+
+char *bar4 __attribute__((externally_visible));
+
+char *bar5;
+extern char *bar5 __attribute__((externally_visible));
+
+char *bar6;
+
+int main (void) { }
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O -fwhole-program" } */
+
+static void foo1 (void) { } /* { dg-warning "have effect only on public" } */
+extern void foo1 (void) __attribute__((externally_visible));
+
+void foo2 (void)
+{
+ __attribute__((externally_visible)) void foo3 (void) { } /* { dg-warning "have effect only on public" } */
+}
+
+__attribute__((externally_visible)) static void foo3 (void) { } /* { dg-warning "have effect only on public" } */
+
+static int bar1;
+extern int bar1 __attribute__((externally_visible)); /* { dg-warning "have effect only on public" } */
+
+static int bar2 __attribute__((externally_visible)); /* { dg-warning "have effect only on public" } */
+
+void fn1 (void)
+{
+ static int bar3 __attribute__((externally_visible)); /* { dg-warning "have effect only on public" } */
+}
+
+void fn2 (void)
+{
+ int bar4 __attribute__((externally_visible)); /* { dg-warning "have effect only on public" } */
+}
+
+struct A
+{
+} __attribute__((externally_visible)); /* { dg-warning "does not apply to types" } */
+
+typedef int B __attribute__((externally_visible)); /* { dg-warning "attribute ignored" } */