From c76dc2277e85475c9cc0e08c3efaaeb5758ba247 Mon Sep 17 00:00:00 2001 From: Wouter van Oortmerssen Date: Sat, 17 Jun 2023 14:45:46 -0700 Subject: [PATCH] New gcc dislikes partial template specialization inside classes --- dev/src/lobster/idents.h | 47 ++++++++++++++++++++-------------------- dev/src/lobster/parser.h | 6 ++--- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/dev/src/lobster/idents.h b/dev/src/lobster/idents.h index 44db89afc..4d97e5e3f 100644 --- a/dev/src/lobster/idents.h +++ b/dev/src/lobster/idents.h @@ -497,8 +497,30 @@ struct Function : Named { } }; -inline string TypeName(TypeRef type, int flen = 0); +template void Unregister(const T *x, unordered_map &dict) { + auto it = dict.find(x->name); + if (it != dict.end()) dict.erase(it); +} + +template void ErasePrivate(unordered_map &dict) { + auto it = dict.begin(); + while (it != dict.end()) { + auto n = it->second; + it++; + if (n->isprivate) Unregister(n, dict); + } +} +template<> void ErasePrivate(unordered_map &dict) { + auto it = dict.begin(); + while (it != dict.end()) { + auto n = it->second; + it++; + if (n->g.isprivate) Unregister(n, dict); + } +} + +inline string TypeName(TypeRef type, int flen = 0); struct SymbolTable { Lex &lex; @@ -764,29 +786,6 @@ struct SymbolTable { } } - template void Unregister(const T *x, unordered_map &dict) { - auto it = dict.find(x->name); - if (it != dict.end()) dict.erase(it); - } - - template void ErasePrivate(unordered_map &dict) { - auto it = dict.begin(); - while (it != dict.end()) { - auto n = it->second; - it++; - if (n->isprivate) Unregister(n, dict); - } - } - - template<> void ErasePrivate(unordered_map &dict) { - auto it = dict.begin(); - while (it != dict.end()) { - auto n = it->second; - it++; - if (n->g.isprivate) Unregister(n, dict); - } - } - void StartOfInclude() { namespace_stack.push_back(current_namespace); current_namespace = {}; diff --git a/dev/src/lobster/parser.h b/dev/src/lobster/parser.h index ff81a63b1..b6255d7bd 100644 --- a/dev/src/lobster/parser.h +++ b/dev/src/lobster/parser.h @@ -113,13 +113,13 @@ struct Parser { // See also Block::TypeCheck for (auto def : list->children) { if (auto er = Is(def)) { - st.Unregister(er->e, st.enums); + Unregister(er->e, st.enums); } else if (auto sr = Is(def)) { if (sr->gudt->predeclaration) Error("pre-declared struct ", Q(sr->gudt->name), " never defined"); - st.Unregister(sr->gudt, st.gudts); + Unregister(sr->gudt, st.gudts); } else if (auto sr = Is(def)) { - st.Unregister(sr->udt, st.udts); + Unregister(sr->udt, st.udts); } else if (auto fr = Is(def)) { auto f = fr->sf->parent; if (!f->anonymous) st.Unregister(f);