From 75038aa6aa5b562e6358108619d66ef2ccab9a53 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Fri, 17 Jan 2020 09:50:33 -0500 Subject: analyzer: introduce namespace to avoid ODR clashes (PR 93307) PR analyzer/93307 reports that in an LTO bootstrap, there are ODR violations between: - the "region" type: gcc/analyzer/region-model.h:792 vs: gcc/sched-int.h:1443 - the "constraint" type: gcc/analyzer/constraint-manager.h:121 vs: gcc/tree-ssa-structalias.c:533 This patches solves this clash by putting all of the analyzer names within a namespace. I chose "ana" as it is short (to save typing). The analyzer selftests are moved from namespace "selftest" to "ana::selftest". There are various places where the namespace has to be closed and reopened, to allow e.g. for specializations of templates in the global namespace. gcc/analyzer/ChangeLog: PR analyzer/93307 * analysis-plan.h: Wrap everything namespace "ana". * analyzer-logging.cc: Likewise. * analyzer-logging.h: Likewise. * analyzer-pass.cc (pass_analyzer::execute): Update for "ana" namespace. * analyzer-selftests.cc: Wrap everything namespace "ana". * analyzer-selftests.h: Likewise. * analyzer.h: Likewise for forward decls of types. * call-string.h: Likewise. * checker-path.cc: Likewise. * checker-path.h: Likewise. * constraint-manager.cc: Likewise. * constraint-manager.h: Likewise. * diagnostic-manager.cc: Likewise. * diagnostic-manager.h: Likewise. * engine.cc: Likewise. * engine.h: Likewise. * exploded-graph.h: Likewise. * function-set.cc: Likewise. * function-set.h: Likewise. * pending-diagnostic.cc: Likewise. * pending-diagnostic.h: Likewise. * program-point.cc: Likewise. * program-point.h: Likewise. * program-state.cc: Likewise. * program-state.h: Likewise. * region-model.cc: Likewise. * region-model.h: Likewise. * sm-file.cc: Likewise. * sm-malloc.cc: Likewise. * sm-pattern-test.cc: Likewise. * sm-sensitive.cc: Likewise. * sm-signal.cc: Likewise. * sm-taint.cc: Likewise. * sm.cc: Likewise. * sm.h: Likewise. * state-purge.h: Likewise. * supergraph.cc: Likewise. * supergraph.h: Likewise. gcc/ChangeLog: PR analyzer/93307 * gdbinit.in (break-on-saved-diagnostic): Update for move of diagnostic_manager into "ana" namespace. * selftest-run-tests.c (selftest::run_tests): Update for move of selftest::run_analyzer_selftests to ana::selftest::run_analyzer_selftests. --- gcc/analyzer/sm-pattern-test.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/analyzer/sm-pattern-test.cc') diff --git a/gcc/analyzer/sm-pattern-test.cc b/gcc/analyzer/sm-pattern-test.cc index 571e13e..cac78e7 100644 --- a/gcc/analyzer/sm-pattern-test.cc +++ b/gcc/analyzer/sm-pattern-test.cc @@ -39,6 +39,8 @@ along with GCC; see the file COPYING3. If not see #if ENABLE_ANALYZER +namespace ana { + namespace { /* A state machine for use in DejaGnu tests, to check that @@ -149,4 +151,6 @@ make_pattern_test_state_machine (logger *logger) return new pattern_test_state_machine (logger); } +} // namespace ana + #endif /* #if ENABLE_ANALYZER */ -- cgit v1.1