https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116847
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
CC| |dmalcolm at gcc dot gnu.org
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Actually, pilot error. It actually does reproduce with it, and reproduces
since like forever.
c=/opt/notnfs/gcc-bisect/obj/gcc/cc1plus.r15-3886; $c -quiet -D_GNU_SOURCE
pr116847.h --output-pch pr116847.h.gch; $c -quiet -D_GNU_SOURCE -Winvalid-pch
pr116847.C
pr116847.h: In instantiation of ‘static int S<N>::bar() [with int N = 0]’:
pr116847.C:3:19: required from here
3 | int a = S<0>::bar ();
| ~~~~~~~~~~^~
pr116847.h:6:32: warning: ‘int foo()’ is deprecated [-Wdeprecated-declarations]
6 | static int bar () { return foo (); }
| ~~~~^~
pr116847.h:1:20: note: declared here
1 | [[deprecated]] int foo () { return 42; }
| ^~~
pr116847.h:6:32: warning: ‘int foo()’ is deprecated [-Wdeprecated-declarations]
6 | static int bar () { return foo (); }
| ~~~~^~
pr116847.h:1:20: note: declared here
1 | [[deprecated]] int foo () { return 42; }
| ^~~
pr116847.h:6:32: warning: ‘int foo()’ is deprecated [-Wdeprecated-declarations]
6 | static int bar () { return foo (); }
| ~~~~^~
pr116847.h:1:20: note: declared here
1 | [[deprecated]] int foo () { return 42; }
| ^~~
Same all the way to r13-282, before that we didn't support --output-pch space
argument, but changing that to --output-pch=pr116847.h.gch and far earlier
changing [[deprecated]] to __attribute__((deprecated)) all the way to
r0-100966-g5e88be0d153ec
when the diagnostic history has been introduced.
I think the reason is simple, neither global_dc nor
global_dc->m_option_classifier->m_option_classifier and
global_dc->m_option_classifier->m_n_classification_history are in GC, so
effectively after PCH restore there is empty history.
Dunno if we want to support say:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwhatever"
in a header which is compiled with PCH and #pragma GCC diagnostic pop in the
main source or another header, if yes, we need to save/restore more stuff, like
m_classify_diagnostic and m_push_list and m_n_push, if not, I think we need to
save/restore just the classification history.
That can be done either by making that stuff GTY, or by explicitly
saving/restoring the stuff that needs saving/restoring, like e.g.
cpp_write_pch_state/cpp_read_state does.
OT, is there a reason why diagnostic.{h,cc} doesn't use vec.h and uses its own
vectors instead?
m_push_list = (int *) xrealloc (m_push_list, (m_n_push + 1) * sizeof (int));
m_push_list[m_n_push ++] = m_n_classification_history;
or
i = m_n_classification_history;
m_classification_history =
(diagnostic_classification_change_t *) xrealloc
(m_classification_history, (i + 1)
* sizeof
(diagnostic_classification_change_t));
m_classification_history[i].location = where;
m_classification_history[i].option = option_id.m_idx;
m_classification_history[i].kind = new_kind;
m_n_classification_history ++;
is simply terrible for many reasons:
1) linear growth rather than exponential growth
2) not using XRESIZEVEC macro, m_push_list = XRESIZEVEC (int, m_push_list,
m_n_push + 1);
3) = shouldn't be at the end of line
4) space before ++
If yes, say because of it is also linked into gen* utilities and if they can't
link with vec.o, then at least the formatting
should be fixed and exponential growth should be added, especially now that the
pragmas are widely used.
I see 159 #pragma GCC diagnostic ignored and 147 #pragma GCC diagnostic pop
pragmas in libstdc++ headers, so if one includes lots of STL headers,
that is ~300 reallocations on the history and wonder how many on the other
vectors.