tools/gcc-plugins: fix for GCC 13

As usual, new GCC version, new small random changes in the API.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2023-09-03 22:56:57 +02:00
parent 640b59a8b0
commit 2821d3b91b
3 changed files with 23 additions and 8 deletions

View file

@ -5,11 +5,15 @@ CXX=g++-9
PLUGBASE=`$(CXX) -print-file-name=plugin`
CPPFLAGS=-I$(PLUGBASE)/include -I$(PLUGBASE)/include/c-family
# NB: compiler flags must match those used to build gcc, otherwise inlining
# behavior is different and linker errors will result due to missing symbols
# (which should in fact be inlined)
frr-format.so: frr-format.o
$(CXX) -g -shared -o $@ $^
$(CXX) -fno-rtti -fno-exceptions -fasynchronous-unwind-tables -ggdb -shared -o $@ $^
frr-format.o: frr-format.c gcc-common.h
$(CXX) -g $(CPPFLAGS) -fPIC -Wall -Wextra -Wno-unused-parameter -c -o $@ $<
$(CXX) -fno-rtti -fno-exceptions -fasynchronous-unwind-tables -ggdb $(CPPFLAGS) -fPIC -Wall -Wextra -Wno-unused-parameter -c -o $@ $<
install:
install -d $(DESTDIR)$(PLUGBASE)

View file

@ -3464,7 +3464,7 @@ class frr_range_label_for_type_mismatch : public range_label
{
}
label_text get_text (unsigned range_idx) const OVERRIDE;
label_text get_text (unsigned range_idx) const override;
protected:
tree m_labelled_type;
@ -3564,19 +3564,26 @@ class range_label_for_format_type_mismatch
{
}
label_text get_text (unsigned range_idx) const FINAL OVERRIDE
#if BUILDING_GCC_VERSION >= 13000
#define text_get(text) text.get()
#define text_return(text, result) return label_text::take(result)
#else
#define text_get(text) text.m_buffer
#define text_return(text, result) text.maybe_free(); return label_take(result)
#endif
label_text get_text (unsigned range_idx) const final override
{
label_text text = range_label_for_type_mismatch::get_text (range_idx);
if (text.m_buffer == NULL)
if (text_get(text) == NULL)
return text;
indirection_suffix suffix (m_pointer_count);
char *p = (char *) alloca (suffix.get_buffer_size ());
suffix.fill_buffer (p);
char *result = concat (text.m_buffer, p, NULL);
text.maybe_free ();
return label_take(result);
char *result = concat (text_get(text), p, NULL);
text_return(text, result);
}
private:

View file

@ -111,6 +111,10 @@
#include "varasm.h"
#include "stor-layout.h"
#include "internal-fn.h"
#if BUILDING_GCC_VERSION >= 13000
#include "gimple.h"
#include "gimple-iterator.h"
#endif
#include "gimple-expr.h"
#include "gimple-fold.h"
#include "context.h"