mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
symtab: Fix init and fini priority to reset to default [PR120030]
Right now if try to reset the priority of a constructor to the default (65535), there is an ICE. To fix this the assert is wrong and intead we should check if the priority is already the default if not then we should just update it. Bootstrapped and tested on x86_64-linux-gnu. PR middle-end/120030 gcc/ChangeLog: * symtab.cc (symtab_node::set_init_priority): Better handle the case of setting the priority back to default. (cgraph_node::set_fini_priority): Likewise. gcc/testsuite/ChangeLog: * gcc.dg/constructor-2.c: New test. Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
This commit is contained in:
@@ -1897,11 +1897,9 @@ symtab_node::set_init_priority (priority_type priority)
|
||||
if (is_a <cgraph_node *> (this))
|
||||
gcc_assert (DECL_STATIC_CONSTRUCTOR (this->decl));
|
||||
|
||||
if (priority == DEFAULT_INIT_PRIORITY)
|
||||
{
|
||||
gcc_assert (get_init_priority() == priority);
|
||||
return;
|
||||
}
|
||||
if (priority == DEFAULT_INIT_PRIORITY
|
||||
&& get_init_priority() == priority)
|
||||
return;
|
||||
h = priority_info ();
|
||||
h->init = priority;
|
||||
}
|
||||
@@ -1915,11 +1913,9 @@ cgraph_node::set_fini_priority (priority_type priority)
|
||||
|
||||
gcc_assert (DECL_STATIC_DESTRUCTOR (this->decl));
|
||||
|
||||
if (priority == DEFAULT_INIT_PRIORITY)
|
||||
{
|
||||
gcc_assert (get_fini_priority() == priority);
|
||||
return;
|
||||
}
|
||||
if (priority == DEFAULT_INIT_PRIORITY
|
||||
&& get_fini_priority() == priority)
|
||||
return;
|
||||
h = priority_info ();
|
||||
h->fini = priority;
|
||||
}
|
||||
|
||||
7
gcc/testsuite/gcc.dg/constructor-2.c
Normal file
7
gcc/testsuite/gcc.dg/constructor-2.c
Normal file
@@ -0,0 +1,7 @@
|
||||
/* { dg-do compile { target init_priority } } */
|
||||
/* { dg-options "" } */
|
||||
|
||||
/* PR middle-end/120030 */
|
||||
|
||||
void f() __attribute__ ((constructor (140))) __attribute__ ((constructor));
|
||||
void g() __attribute__ ((destructor (140))) __attribute__ ((destructor));
|
||||
Reference in New Issue
Block a user