+2007-09-29 Jason Merrill <jason@redhat.com>
+
+ PR c++/33094
+ * decl.c (make_rtl_for_nonlocal_decl): It's ok for a member
+ constant to not have DECL_EXTERNAL if it's file-local.
+
2007-09-28 Ollie Wild <aaw@google.com>
Revert
/* DECL_EXTERNAL must be set on a decl until the decl is actually emitted,
so that assemble_external will work properly. So we have this flag to
- tell us whether the decl is really not external. */
+ tell us whether the decl is really not external.
+
+ This flag does not indicate whether or not the decl is defined in the
+ current translation unit; it indicates whether or not we should emit the
+ decl at the end of compilation if it is defined and needed. */
#define DECL_NOT_REALLY_EXTERN(NODE) \
(DECL_LANG_SPECIFIC (NODE)->decl_flags.not_really_extern)
/* An in-class declaration of a static data member should be
external; it is only a declaration, and not a definition. */
if (init == NULL_TREE)
- gcc_assert (DECL_EXTERNAL (decl));
+ gcc_assert (DECL_EXTERNAL (decl) || !TREE_PUBLIC (decl));
}
/* We don't create any RTL for local variables. */
return type;
}
\f
+/* DECL is a VAR_DECL for a vtable: walk through the entries in the vtable
+ and mark them as needed. */
+
static void
mark_vtable_entries (tree decl)
{
--- /dev/null
+// PR c++/33094
+// { dg-final { scan-assembler "1BIiE1cE" } }
+// { dg-final { scan-assembler-not "globl.*1BIiE1cE" } }
+// { dg-final { scan-assembler-not "1CIiE1cE" } }
+
+// Test that B<int>::c is emitted as an internal symbol, and C<int>::c is
+// not emitted.
+
+namespace
+{
+ template <typename T>
+ class A
+ {
+ virtual T f1() { return c; }
+ static const T c = 0;
+ };
+
+ template <typename T>
+ class B
+ {
+ static const T c = 0;
+ };
+
+ template <typename T> const T B<T>::c;
+
+ template class A<int>;
+ template class B<int>;
+}