pt.c (instantiate_class_template_1): If DECL_PRESERVE_P is set on a member function or static data member...
* pt.c (instantiate_class_template_1): If DECL_PRESERVE_P is set on a member function or static data member, call mark_used. From-SVN: r177811
This commit is contained in:
parent
098416302b
commit
4951efb6c9
5 changed files with 36 additions and 0 deletions
|
@ -1,5 +1,8 @@
|
||||||
2011-08-16 Jason Merrill <jason@redhat.com>
|
2011-08-16 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
* pt.c (instantiate_class_template_1): If DECL_PRESERVE_P is set
|
||||||
|
on a member function or static data member, call mark_used.
|
||||||
|
|
||||||
PR c++/50054
|
PR c++/50054
|
||||||
* typeck2.c (cxx_incomplete_type_diagnostic): Handle
|
* typeck2.c (cxx_incomplete_type_diagnostic): Handle
|
||||||
init_list_type_node.
|
init_list_type_node.
|
||||||
|
|
|
@ -8675,6 +8675,9 @@ instantiate_class_template_1 (tree type)
|
||||||
--processing_template_decl;
|
--processing_template_decl;
|
||||||
set_current_access_from_decl (r);
|
set_current_access_from_decl (r);
|
||||||
finish_member_declaration (r);
|
finish_member_declaration (r);
|
||||||
|
/* Instantiate members marked with attribute used. */
|
||||||
|
if (r != error_mark_node && DECL_PRESERVE_P (r))
|
||||||
|
mark_used (r);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -8724,6 +8727,9 @@ instantiate_class_template_1 (tree type)
|
||||||
/*init_const_expr_p=*/false,
|
/*init_const_expr_p=*/false,
|
||||||
/*asmspec_tree=*/NULL_TREE,
|
/*asmspec_tree=*/NULL_TREE,
|
||||||
/*flags=*/0);
|
/*flags=*/0);
|
||||||
|
/* Instantiate members marked with attribute used. */
|
||||||
|
if (r != error_mark_node && DECL_PRESERVE_P (r))
|
||||||
|
mark_used (r);
|
||||||
}
|
}
|
||||||
else if (TREE_CODE (r) == FIELD_DECL)
|
else if (TREE_CODE (r) == FIELD_DECL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3647,6 +3647,10 @@ for the function even if it appears that the function is not referenced.
|
||||||
This is useful, for example, when the function is referenced only in
|
This is useful, for example, when the function is referenced only in
|
||||||
inline assembly.
|
inline assembly.
|
||||||
|
|
||||||
|
When applied to a member function of a C++ class template, the
|
||||||
|
attribute also means that the function will be instantiated if the
|
||||||
|
class itself is instantiated.
|
||||||
|
|
||||||
@item version_id
|
@item version_id
|
||||||
@cindex @code{version_id} attribute
|
@cindex @code{version_id} attribute
|
||||||
This IA64 HP-UX attribute, attached to a global variable or function, renames a
|
This IA64 HP-UX attribute, attached to a global variable or function, renames a
|
||||||
|
@ -4457,6 +4461,10 @@ variable.
|
||||||
This attribute, attached to a variable, means that the variable must be
|
This attribute, attached to a variable, means that the variable must be
|
||||||
emitted even if it appears that the variable is not referenced.
|
emitted even if it appears that the variable is not referenced.
|
||||||
|
|
||||||
|
When applied to a static data member of a C++ class template, the
|
||||||
|
attribute also means that the member will be instantiated if the
|
||||||
|
class itself is instantiated.
|
||||||
|
|
||||||
@item vector_size (@var{bytes})
|
@item vector_size (@var{bytes})
|
||||||
This attribute specifies the vector size for the variable, measured in
|
This attribute specifies the vector size for the variable, measured in
|
||||||
bytes. For example, the declaration:
|
bytes. For example, the declaration:
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
2011-08-16 Jason Merrill <jason@redhat.com>
|
2011-08-16 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
* g++.dg/ext/attr-used-1.C: New.
|
||||||
|
|
||||||
PR c++/50054
|
PR c++/50054
|
||||||
* g++.dg/cpp0x/initlist56.C: New.
|
* g++.dg/cpp0x/initlist56.C: New.
|
||||||
|
|
||||||
|
|
17
gcc/testsuite/g++.dg/ext/attr-used-1.C
Normal file
17
gcc/testsuite/g++.dg/ext/attr-used-1.C
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// Attribute used on a member function or static data member
|
||||||
|
// of a template should cause them to be instantiated along
|
||||||
|
// with the class itself.
|
||||||
|
|
||||||
|
// { dg-final { scan-assembler "_ZN1AIiE1fEv" } }
|
||||||
|
// { dg-final { scan-assembler "_ZN1AIiE1tE" } }
|
||||||
|
|
||||||
|
template <class T> struct A
|
||||||
|
{
|
||||||
|
void f() __attribute ((used));
|
||||||
|
static T t __attribute ((used));
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T> void A<T>::f() { }
|
||||||
|
template <class T> T A<T>::t;
|
||||||
|
|
||||||
|
A<int> a;
|
Loading…
Add table
Reference in a new issue