diff --git a/source/sema.h b/source/sema.h index 7ff07df67..fa02c52a4 100644 --- a/source/sema.h +++ b/source/sema.h @@ -1505,9 +1505,15 @@ class sema return true; } - auto check(declaration_node const& n) + auto check( + declaration_node const& n, + bool emit_errors = true // pass false to validate checks only + ) -> bool { + std::vector devnull; + auto& errors = emit_errors ? this->errors : devnull; + if (n.has_name("operator")) { errors.emplace_back( n.position(), diff --git a/source/to_cpp1.h b/source/to_cpp1.h index 7064b0cb4..8a197af43 100644 --- a/source/to_cpp1.h +++ b/source/to_cpp1.h @@ -5492,11 +5492,8 @@ class cppfront // Declarations are handled in multiple passes, - // but we only want to do the sema checks once - if ( - printer.get_phase() == printer.phase2_func_defs - && !sema.check(n) - ) + // but we only want to emit the error messages once (in phase 2) + if (!sema.check(n, printer.get_phase() == printer.phase2_func_defs)) { return; }