+2018-10-04 Vinay Kumar <vinay.kumar@blackfigtech.com>
+
+ * doc/invoke.texi (-Wno-prio-ctor-dtor): Document new warning
+ -Wno-prio-ctor-dtor.
+
2018-10-04 David Malcolm <dmalcolm@redhat.com>
* Makefile.in (OBJS): Add opt-problem.o.
+2018-10-04 Vinay Kumar <vinay.kumar@blackfigtech.com>
+
+ * c-attribs.c (get_priority): Add a warning flag warn_prio_ctor_dtor
+ to generate constructor destructor priority warning.
+ * c.opt (-Wprio-ctor-dtor): New option.
+
2018-10-01 Jason Merrill <jason@redhat.com>
* c-lex.c (c_common_has_attribute): Add no_unique_address.
if (pri <= MAX_RESERVED_INIT_PRIORITY)
{
if (is_destructor)
- warning (0,
+ warning (OPT_Wprio_ctor_dtor,
"destructor priorities from 0 to %d are reserved "
"for the implementation",
MAX_RESERVED_INIT_PRIORITY);
else
- warning (0,
+ warning (OPT_Wprio_ctor_dtor,
"constructor priorities from 0 to %d are reserved "
"for the implementation",
MAX_RESERVED_INIT_PRIORITY);
C ObjC C++ ObjC++ Var(warn_pragmas) Init(1) Warning
Warn about misuses of pragmas.
+Wprio-ctor-dtor
+C ObjC C++ ObjC++ Var(warn_prio_ctor_dtor) Init(1) Warning
+Warn if constructor or destructors with priorities from 0 to 100 are used.
+
Wproperty-assign-default
ObjC ObjC++ Var(warn_property_assign_default) Init(1) Warning
Warn if a property for an Objective-C object has no assign semantics specified.
-Wparentheses -Wno-pedantic-ms-format @gol
-Wplacement-new -Wplacement-new=@var{n} @gol
-Wpointer-arith -Wpointer-compare -Wno-pointer-to-int-cast @gol
--Wno-pragmas -Wredundant-decls -Wrestrict -Wno-return-local-addr @gol
+-Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol
+-Wrestrict -Wno-return-local-addr @gol
-Wreturn-type -Wsequence-point -Wshadow -Wno-shadow-ivar @gol
-Wshadow=global, -Wshadow=local, -Wshadow=compatible-local @gol
-Wshift-overflow -Wshift-overflow=@var{n} @gol
invalid syntax, or conflicts between pragmas. See also
@option{-Wunknown-pragmas}.
+@item -Wno-prio-ctor-dtor
+@opindex Wno-prio-ctor-dtor
+@opindex Wprio-ctor-dtor
+Do not warn if a priority from 0 to 100 is used for constructor or destructor.
+The use of constructor and destructor attributes allow you to assign a
+priority to the constructor/destructor to control its order of execution
+before @code{main} is called or after it returns. The priority values must be
+greater than 100 as the compiler reserves priority values between 0--100 for
+the implementation.
+
@item -Wstrict-aliasing
@opindex Wstrict-aliasing
@opindex Wno-strict-aliasing
+2018-10-04 Vinay Kumar <vinay.kumar@blackfigtech.com>
+
+ * c-c++-common/Wprio-ctor-dtor.c: New test.
+
2018-10-04 David Malcolm <dmalcolm@redhat.com>
* gcc.dg/vect/nodump-vect-opt-info-2.c: New test.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-Wno-prio-ctor-dtor" } */
+
+void construct1 () __attribute__ ((constructor (10)));
+void construct2 () __attribute__ ((constructor (100)));
+void construct2 () __attribute__ ((constructor (101)));
+void destruct1 () __attribute__ ((destructor (1)));
+void destruct2 () __attribute__ ((destructor (02)));
+void destruct2 () __attribute__ ((destructor (102)));