feat(sem)补充常量求值

feature/sem
mxr 2 weeks ago
parent 7eed5fe6f6
commit 40403e955d

377
bug

@ -0,0 +1,377 @@
gmake[1]: Warning: File 'CMakeFiles/Makefile2' has modification time 0.69 s in the future
gmake[2]: Warning: File 'src/ir/CMakeFiles/ir_core.dir/flags.make' has modification time 0.67 s in the future
gmake[2]: Warning: File 'src/utils/CMakeFiles/utils.dir/flags.make' has modification time 0.66 s in the future
gmake[2]: Warning: File 'CMakeFiles/antlr4_runtime.dir/flags.make' has modification time 0.64 s in the future
gmake[2]: warning: Clock skew detected. Your build may be incomplete.
gmake[2]: warning: Clock skew detected. Your build may be incomplete.
gmake[2]: Warning: File 'src/utils/CMakeFiles/utils.dir/flags.make' has modification time 0.64 s in the future
gmake[2]: Warning: File 'src/ir/CMakeFiles/ir_core.dir/flags.make' has modification time 0.65 s in the future
gmake[2]: warning: Clock skew detected. Your build may be incomplete.
[ 0%] Building CXX object src/ir/CMakeFiles/ir_core.dir/Context.cpp.o
[ 0%] Building CXX object src/ir/CMakeFiles/ir_core.dir/GlobalValue.cpp.o
[ 2%] Building CXX object src/ir/CMakeFiles/ir_core.dir/BasicBlock.cpp.o
[ 2%] Building CXX object src/ir/CMakeFiles/ir_core.dir/Module.cpp.o
[ 2%] Building CXX object src/utils/CMakeFiles/utils.dir/Log.cpp.o
[ 2%] Building CXX object src/ir/CMakeFiles/ir_core.dir/Value.cpp.o
[ 2%] Building CXX object src/ir/CMakeFiles/ir_core.dir/Function.cpp.o
[ 3%] Building CXX object src/utils/CMakeFiles/utils.dir/CLI.cpp.o
[ 4%] Building CXX object src/ir/CMakeFiles/ir_core.dir/IRBuilder.cpp.o
[ 6%] Building CXX object src/ir/CMakeFiles/ir_core.dir/Type.cpp.o
[ 6%] Building CXX object src/ir/CMakeFiles/ir_core.dir/Instruction.cpp.o
gmake[2]: Warning: File 'CMakeFiles/antlr4_runtime.dir/flags.make' has modification time 0.61 s in the future
[ 6%] Building CXX object src/ir/CMakeFiles/ir_core.dir/IRPrinter.cpp.o
[ 6%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/ANTLRFileStream.cpp.o
[ 7%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/ANTLRErrorStrategy.cpp.o
[ 8%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/ANTLRInputStream.cpp.o
[ 8%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/ANTLRErrorListener.cpp.o
[ 8%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/BailErrorStrategy.cpp.o
[ 9%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/BaseErrorListener.cpp.o
[ 9%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/BufferedTokenStream.cpp.o
[ 10%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/CharStream.cpp.o
[ 11%] Linking CXX static library libutils.a
[ 11%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/CommonToken.cpp.o
[ 12%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/CommonTokenFactory.cpp.o
[ 12%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/CommonTokenStream.cpp.o
[ 13%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/ConsoleErrorListener.cpp.o
[ 13%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/DefaultErrorStrategy.cpp.o
[ 14%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/DiagnosticErrorListener.cpp.o
[ 14%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/Exceptions.cpp.o
[ 15%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/FailedPredicateException.cpp.o
[ 16%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/InputMismatchException.cpp.o
[ 17%] Linking CXX static library libir_core.a
[ 17%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/IntStream.cpp.o
[ 18%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/InterpreterRuleContext.cpp.o
[ 18%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/Lexer.cpp.o
[ 19%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/LexerInterpreter.cpp.o
[ 19%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/LexerNoViableAltException.cpp.o
[ 20%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/ListTokenSource.cpp.o
gmake[2]: warning: Clock skew detected. Your build may be incomplete.
[ 20%] Built target utils
gmake[2]: warning: Clock skew detected. Your build may be incomplete.
[ 20%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/NoViableAltException.cpp.o
[ 20%] Built target ir_core
[ 21%] Building CXX object src/ir/analysis/CMakeFiles/ir_analysis.dir/DominatorTree.cpp.o
[ 21%] Building CXX object src/ir/analysis/CMakeFiles/ir_analysis.dir/LoopInfo.cpp.o
[ 22%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/Parser.cpp.o
[ 23%] Linking CXX static library libir_analysis.a
[ 23%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/ParserInterpreter.cpp.o
[ 23%] Built target ir_analysis
[ 23%] Building CXX object src/ir/passes/CMakeFiles/ir_passes.dir/PassManager.cpp.o
[ 24%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/ParserRuleContext.cpp.o
[ 25%] Building CXX object src/ir/passes/CMakeFiles/ir_passes.dir/Mem2Reg.cpp.o
[ 25%] Building CXX object src/ir/passes/CMakeFiles/ir_passes.dir/ConstFold.cpp.o
[ 25%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/ProxyErrorListener.cpp.o
[ 26%] Building CXX object src/ir/passes/CMakeFiles/ir_passes.dir/ConstProp.cpp.o
[ 27%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/RecognitionException.cpp.o
[ 27%] Building CXX object src/ir/passes/CMakeFiles/ir_passes.dir/CSE.cpp.o
[ 27%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/Recognizer.cpp.o
[ 28%] Building CXX object src/ir/passes/CMakeFiles/ir_passes.dir/DCE.cpp.o
[ 29%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.cpp.o
[ 29%] Building CXX object src/ir/passes/CMakeFiles/ir_passes.dir/CFGSimplify.cpp.o
[ 30%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContextWithAltNum.cpp.o
[ 31%] Linking CXX static library libir_passes.a
[ 31%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/RuntimeMetaData.cpp.o
[ 31%] Built target ir_passes
[ 32%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/Token.cpp.o
[ 32%] Building CXX object src/mir/CMakeFiles/mir_core.dir/MIRContext.cpp.o
[ 32%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/TokenSource.cpp.o
[ 33%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/TokenStream.cpp.o
[ 33%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/TokenStreamRewriter.cpp.o
[ 34%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/UnbufferedCharStream.cpp.o
[ 34%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/UnbufferedTokenStream.cpp.o
[ 35%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/Vocabulary.cpp.o
[ 35%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/WritableToken.cpp.o
[ 36%] Building CXX object src/mir/CMakeFiles/mir_core.dir/MIRFunction.cpp.o
[ 37%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/ATN.cpp.o
[ 37%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/ATNConfig.cpp.o
[ 38%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/ATNConfigSet.cpp.o
[ 38%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/ATNDeserializationOptions.cpp.o
[ 39%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/ATNDeserializer.cpp.o
[ 40%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/ATNSimulator.cpp.o
[ 40%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/ATNState.cpp.o
[ 40%] Building CXX object src/mir/CMakeFiles/mir_core.dir/MIRBasicBlock.cpp.o
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/Vocabulary.cpp: In static member function static void antlr4::dfa::Vocabulary::__static_initialization_and_destruction_0():
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/Vocabulary.cpp:12:18: warning: antlr4::dfa::Vocabulary::EMPTY_VOCABULARY is deprecated: Use the default constructor of Vocabulary instead. [-Wdeprecated-declarations]
12 | const Vocabulary Vocabulary::EMPTY_VOCABULARY;
| ^~~~~~~~~~
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/Vocabulary.cpp:12:18: note: declared here
[ 41%] Building CXX object src/mir/CMakeFiles/mir_core.dir/MIRInstr.cpp.o
[ 42%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/ATNStateType.cpp.o
[ 42%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/ActionTransition.cpp.o
[ 43%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/AmbiguityInfo.cpp.o
[ 43%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/ArrayPredictionContext.cpp.o
[ 44%] Building CXX object src/mir/CMakeFiles/mir_core.dir/Register.cpp.o
[ 45%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/AtomTransition.cpp.o
[ 45%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/ContextSensitivityInfo.cpp.o
[ 46%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/DecisionEventInfo.cpp.o
[ 46%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/DecisionInfo.cpp.o
[ 47%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/DecisionState.cpp.o
[ 47%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/EpsilonTransition.cpp.o
[ 47%] Building CXX object src/mir/CMakeFiles/mir_core.dir/Lowering.cpp.o
[ 48%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/ErrorInfo.cpp.o
[ 48%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/LL1Analyzer.cpp.o
[ 49%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/LexerATNConfig.cpp.o
[ 49%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/LexerATNSimulator.cpp.o
[ 50%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/LexerAction.cpp.o
[ 51%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/LexerActionExecutor.cpp.o
[ 51%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/LexerChannelAction.cpp.o
[ 52%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/LexerCustomAction.cpp.o
[ 52%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/LexerIndexedCustomAction.cpp.o
[ 53%] Building CXX object src/mir/CMakeFiles/mir_core.dir/RegAlloc.cpp.o
[ 54%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/LexerModeAction.cpp.o
[ 54%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/LexerMoreAction.cpp.o
[ 55%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/LexerPopModeAction.cpp.o
[ 55%] Building CXX object src/mir/CMakeFiles/mir_core.dir/FrameLowering.cpp.o
[ 55%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/LexerPushModeAction.cpp.o
[ 56%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/LexerSkipAction.cpp.o
[ 56%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/LexerTypeAction.cpp.o
[ 57%] Building CXX object src/mir/CMakeFiles/mir_core.dir/AsmPrinter.cpp.o
[ 58%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/LookaheadEventInfo.cpp.o
[ 58%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/NotSetTransition.cpp.o
[ 59%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/OrderedATNConfigSet.cpp.o
[ 60%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/ParserATNSimulator.cpp.o
[ 60%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/ParseInfo.cpp.o
[ 61%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/PrecedencePredicateTransition.cpp.o
[ 61%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/PredicateEvalInfo.cpp.o
[ 62%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/PredicateTransition.cpp.o
[ 62%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/PredictionContext.cpp.o
[ 63%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/PredictionContextCache.cpp.o
[ 63%] Linking CXX static library libmir_core.a
[ 63%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/PredictionContextMergeCache.cpp.o
[ 63%] Built target mir_core
[ 64%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/PredictionMode.cpp.o
[ 64%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/ProfilingATNSimulator.cpp.o
[ 65%] Building CXX object src/mir/passes/CMakeFiles/mir_passes.dir/PassManager.cpp.o
[ 65%] Building CXX object src/mir/passes/CMakeFiles/mir_passes.dir/Peephole.cpp.o
[ 66%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/RangeTransition.cpp.o
[ 66%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/RuleTransition.cpp.o
[ 67%] Linking CXX static library libmir_passes.a
[ 67%] Built target mir_passes
[ 68%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/SemanticContext.cpp.o
[ 68%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/SetTransition.cpp.o
[ 69%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/SingletonPredictionContext.cpp.o
[ 69%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/StarLoopbackState.cpp.o
[ 70%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/Transition.cpp.o
[ 71%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/TransitionType.cpp.o
[ 71%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/atn/WildcardTransition.cpp.o
[ 72%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/dfa/DFA.cpp.o
[ 72%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/dfa/DFASerializer.cpp.o
[ 73%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/dfa/DFAState.cpp.o
[ 73%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/dfa/LexerDFASerializer.cpp.o
[ 74%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/internal/Synchronization.cpp.o
[ 74%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/misc/InterpreterDataReader.cpp.o
[ 75%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/misc/Interval.cpp.o
[ 75%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/misc/IntervalSet.cpp.o
[ 76%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/misc/MurmurHash.cpp.o
[ 76%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/misc/Predicate.cpp.o
[ 77%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/support/Any.cpp.o
[ 77%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/support/Arrays.cpp.o
[ 78%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/support/CPPUtils.cpp.o
[ 78%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/support/StringUtils.cpp.o
[ 79%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/support/Utf8.cpp.o
[ 80%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/ErrorNodeImpl.cpp.o
[ 80%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/IterativeParseTreeWalker.cpp.o
[ 81%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/ParseTree.cpp.o
[ 81%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/ParseTreeListener.cpp.o
[ 82%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/ParseTreeVisitor.cpp.o
[ 82%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/ParseTreeWalker.cpp.o
[ 83%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/TerminalNodeImpl.cpp.o
[ 83%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/Trees.cpp.o
[ 84%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/pattern/Chunk.cpp.o
[ 84%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/pattern/ParseTreeMatch.cpp.o
[ 85%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/pattern/ParseTreePattern.cpp.o
[ 85%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp.o
[ 86%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/pattern/RuleTagToken.cpp.o
[ 86%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/pattern/TagChunk.cpp.o
[ 87%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/pattern/TextChunk.cpp.o
[ 88%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/pattern/TokenTagToken.cpp.o
[ 88%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/xpath/XPath.cpp.o
[ 89%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/xpath/XPathElement.cpp.o
[ 89%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/xpath/XPathLexer.cpp.o
[ 90%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/xpath/XPathLexerErrorListener.cpp.o
[ 90%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/xpath/XPathRuleAnywhereElement.cpp.o
[ 91%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/xpath/XPathRuleElement.cpp.o
[ 91%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/xpath/XPathTokenAnywhereElement.cpp.o
[ 92%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/xpath/XPathTokenElement.cpp.o
[ 92%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/xpath/XPathWildcardAnywhereElement.cpp.o
[ 93%] Building CXX object CMakeFiles/antlr4_runtime.dir/third_party/antlr4-runtime-4.13.2/runtime/src/tree/xpath/XPathWildcardElement.cpp.o
[ 93%] Linking CXX static library libantlr4_runtime.a
gmake[2]: warning: Clock skew detected. Your build may be incomplete.
[ 93%] Built target antlr4_runtime
[ 93%] Building CXX object src/sem/CMakeFiles/sem.dir/Sema.cpp.o
[ 93%] Building CXX object src/sem/CMakeFiles/sem.dir/ConstEval.cpp.o
[ 93%] Building CXX object src/frontend/CMakeFiles/frontend.dir/__/__/generated/antlr4/SysYBaseVisitor.cpp.o
[ 95%] Building CXX object src/frontend/CMakeFiles/frontend.dir/__/__/generated/antlr4/SysYLexer.cpp.o
[ 95%] Building CXX object src/frontend/CMakeFiles/frontend.dir/__/__/generated/antlr4/SysYParser.cpp.o
[ 94%] Building CXX object src/sem/CMakeFiles/sem.dir/SymbolTable.cpp.o
[ 96%] Building CXX object src/frontend/CMakeFiles/frontend.dir/__/__/generated/antlr4/SysYVisitor.cpp.o
[ 97%] Building CXX object src/frontend/CMakeFiles/frontend.dir/AntlrDriver.cpp.o
[ 98%] Building CXX object src/frontend/CMakeFiles/frontend.dir/SyntaxTreePrinter.cpp.o
In file included from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/ParserRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/InterpreterRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/antlr4-runtime.h:30,
from /home/mxr/compiler/build/generated/antlr4/SysYParser.h:7,
from /home/mxr/compiler/include/sem/Sema.h:8,
from /home/mxr/compiler/src/sem/Sema.cpp:1:
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/tree/ParseTree.h:50:18: warning: virtual bool antlr4::tree::ParseTree::operator==(const antlr4::tree::ParseTree&) const was hidden [-Woverloaded-virtual=]
50 | virtual bool operator == (const ParseTree &other) const;
| ^~~~~~~~
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:135:10: note: by bool antlr4::RuleContext::operator==(const antlr4::RuleContext&)
135 | bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
| ^~~~~~~~
In file included from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/ParserRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/InterpreterRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/antlr4-runtime.h:30,
from /home/mxr/compiler/build/generated/antlr4/SysYLexer.h:7,
from /home/mxr/compiler/include/frontend/AntlrDriver.h:7,
from /home/mxr/compiler/src/frontend/AntlrDriver.cpp:2:
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/tree/ParseTree.h:50:18: warning: virtual bool antlr4::tree::ParseTree::operator==(const antlr4::tree::ParseTree&) const was hidden [-Woverloaded-virtual=]
50 | virtual bool operator == (const ParseTree &other) const;
| ^~~~~~~~
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:135:10: note: by bool antlr4::RuleContext::operator==(const antlr4::RuleContext&)
135 | bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
| ^~~~~~~~
In file included from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/ParserRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/InterpreterRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/antlr4-runtime.h:30,
from /home/mxr/compiler/build/generated/antlr4/SysYVisitor.h:7,
from /home/mxr/compiler/build/generated/antlr4/SysYParser.cpp:5:
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/tree/ParseTree.h:50:18: warning: virtual bool antlr4::tree::ParseTree::operator==(const antlr4::tree::ParseTree&) const was hidden [-Woverloaded-virtual=]
50 | virtual bool operator == (const ParseTree &other) const;
| ^~~~~~~~
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:135:10: note: by bool antlr4::RuleContext::operator==(const antlr4::RuleContext&)
135 | bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
| ^~~~~~~~
In file included from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/ParserRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/InterpreterRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/antlr4-runtime.h:30,
from /home/mxr/compiler/include/frontend/SyntaxTreePrinter.h:5,
from /home/mxr/compiler/src/frontend/SyntaxTreePrinter.cpp:1:
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/tree/ParseTree.h:50:18: warning: virtual bool antlr4::tree::ParseTree::operator==(const antlr4::tree::ParseTree&) const was hidden [-Woverloaded-virtual=]
50 | virtual bool operator == (const ParseTree &other) const;
| ^~~~~~~~
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:135:10: note: by bool antlr4::RuleContext::operator==(const antlr4::RuleContext&)
135 | bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
| ^~~~~~~~
In file included from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/ParserRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/InterpreterRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/antlr4-runtime.h:30,
from /home/mxr/compiler/build/generated/antlr4/SysYLexer.h:7,
from /home/mxr/compiler/build/generated/antlr4/SysYLexer.cpp:5:
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/tree/ParseTree.h:50:18: warning: virtual bool antlr4::tree::ParseTree::operator==(const antlr4::tree::ParseTree&) const was hidden [-Woverloaded-virtual=]
50 | virtual bool operator == (const ParseTree &other) const;
| ^~~~~~~~
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:135:10: note: by bool antlr4::RuleContext::operator==(const antlr4::RuleContext&)
135 | bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
| ^~~~~~~~
In file included from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/ParserRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/InterpreterRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/antlr4-runtime.h:30,
from /home/mxr/compiler/build/generated/antlr4/SysYVisitor.h:7,
from /home/mxr/compiler/build/generated/antlr4/SysYVisitor.cpp:5:
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/tree/ParseTree.h:50:18: warning: virtual bool antlr4::tree::ParseTree::operator==(const antlr4::tree::ParseTree&) const was hidden [-Woverloaded-virtual=]
50 | virtual bool operator == (const ParseTree &other) const;
| ^~~~~~~~
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:135:10: note: by bool antlr4::RuleContext::operator==(const antlr4::RuleContext&)
135 | bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
| ^~~~~~~~
In file included from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/ParserRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/InterpreterRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/antlr4-runtime.h:30,
from /home/mxr/compiler/build/generated/antlr4/SysYParser.h:7,
from /home/mxr/compiler/include/sem/SymbolTable.h:9,
from /home/mxr/compiler/src/sem/SymbolTable.cpp:1:
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/tree/ParseTree.h:50:18: warning: virtual bool antlr4::tree::ParseTree::operator==(const antlr4::tree::ParseTree&) const was hidden [-Woverloaded-virtual=]
50 | virtual bool operator == (const ParseTree &other) const;
| ^~~~~~~~
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:135:10: note: by bool antlr4::RuleContext::operator==(const antlr4::RuleContext&)
135 | bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
| ^~~~~~~~
In file included from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/ParserRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/InterpreterRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/antlr4-runtime.h:30,
from /home/mxr/compiler/build/generated/antlr4/SysYBaseVisitor.h:7,
from /home/mxr/compiler/build/generated/antlr4/SysYBaseVisitor.cpp:5:
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/tree/ParseTree.h:50:18: warning: virtual bool antlr4::tree::ParseTree::operator==(const antlr4::tree::ParseTree&) const was hidden [-Woverloaded-virtual=]
50 | virtual bool operator == (const ParseTree &other) const;
| ^~~~~~~~
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:135:10: note: by bool antlr4::RuleContext::operator==(const antlr4::RuleContext&)
135 | bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
| ^~~~~~~~
/home/mxr/compiler/src/sem/SymbolTable.cpp: In function int evaluateConstExp(SysYParser::ConstExpContext*):
/home/mxr/compiler/src/sem/SymbolTable.cpp:113:58: warning: unused parameter ctx [-Wunused-parameter]
113 | static int evaluateConstExp(SysYParser::ConstExpContext* ctx) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/home/mxr/compiler/src/sem/Sema.cpp: In member function std::any {anonymous}::SemaVisitor::visitBreakStmtInternal(SysYParser::StmtContext*):
/home/mxr/compiler/src/sem/Sema.cpp:518:62: warning: unused parameter ctx [-Wunused-parameter]
518 | std::any visitBreakStmtInternal(SysYParser::StmtContext* ctx) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/home/mxr/compiler/src/sem/Sema.cpp: In member function std::any {anonymous}::SemaVisitor::visitContinueStmtInternal(SysYParser::StmtContext*):
/home/mxr/compiler/src/sem/Sema.cpp:526:65: warning: unused parameter ctx [-Wunused-parameter]
526 | std::any visitContinueStmtInternal(SysYParser::StmtContext* ctx) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/home/mxr/compiler/build/generated/antlr4/SysYParser.cpp: In member function bool SysYParser::mulExpSempred(MulExpContext*, size_t):
/home/mxr/compiler/build/generated/antlr4/SysYParser.cpp:3090:47: warning: unused parameter _localctx [-Wunused-parameter]
3090 | bool SysYParser::mulExpSempred(MulExpContext *_localctx, size_t predicateIndex) {
| ~~~~~~~~~~~~~~~^~~~~~~~~
/home/mxr/compiler/build/generated/antlr4/SysYParser.cpp: In member function bool SysYParser::addExpSempred(AddExpContext*, size_t):
/home/mxr/compiler/build/generated/antlr4/SysYParser.cpp:3100:47: warning: unused parameter _localctx [-Wunused-parameter]
3100 | bool SysYParser::addExpSempred(AddExpContext *_localctx, size_t predicateIndex) {
| ~~~~~~~~~~~~~~~^~~~~~~~~
/home/mxr/compiler/build/generated/antlr4/SysYParser.cpp: In member function bool SysYParser::relExpSempred(RelExpContext*, size_t):
/home/mxr/compiler/build/generated/antlr4/SysYParser.cpp:3110:47: warning: unused parameter _localctx [-Wunused-parameter]
3110 | bool SysYParser::relExpSempred(RelExpContext *_localctx, size_t predicateIndex) {
| ~~~~~~~~~~~~~~~^~~~~~~~~
/home/mxr/compiler/build/generated/antlr4/SysYParser.cpp: In member function bool SysYParser::eqExpSempred(EqExpContext*, size_t):
/home/mxr/compiler/build/generated/antlr4/SysYParser.cpp:3120:45: warning: unused parameter _localctx [-Wunused-parameter]
3120 | bool SysYParser::eqExpSempred(EqExpContext *_localctx, size_t predicateIndex) {
| ~~~~~~~~~~~~~~^~~~~~~~~
/home/mxr/compiler/build/generated/antlr4/SysYParser.cpp: In member function bool SysYParser::lAndExpSempred(LAndExpContext*, size_t):
/home/mxr/compiler/build/generated/antlr4/SysYParser.cpp:3130:49: warning: unused parameter _localctx [-Wunused-parameter]
3130 | bool SysYParser::lAndExpSempred(LAndExpContext *_localctx, size_t predicateIndex) {
| ~~~~~~~~~~~~~~~~^~~~~~~~~
/home/mxr/compiler/build/generated/antlr4/SysYParser.cpp: In member function bool SysYParser::lOrExpSempred(LOrExpContext*, size_t):
/home/mxr/compiler/build/generated/antlr4/SysYParser.cpp:3140:47: warning: unused parameter _localctx [-Wunused-parameter]
3140 | bool SysYParser::lOrExpSempred(LOrExpContext *_localctx, size_t predicateIndex) {
| ~~~~~~~~~~~~~~~^~~~~~~~~
/home/mxr/compiler/src/sem/Sema.cpp: In member function ExprInfo {anonymous}::SemaVisitor::CheckBinaryOp(const ExprInfo*, const ExprInfo*, const std::string&, antlr4::ParserRuleContext*):
/home/mxr/compiler/src/sem/Sema.cpp:1032:78: warning: unused parameter ctx [-Wunused-parameter]
1032 | const std::string& op, antlr4::ParserRuleContext* ctx) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/home/mxr/compiler/src/sem/Sema.cpp: At global scope:
/home/mxr/compiler/src/sem/Sema.cpp:15:13: warning: std::string {anonymous}::GetLValueName(SysYParser::LValContext&) defined but not used [-Wunused-function]
15 | std::string GetLValueName(SysYParser::LValContext& lval) {
| ^~~~~~~~~~~~~
[ 99%] Linking CXX static library libsem.a
[ 99%] Built target sem
[ 99%] Linking CXX static library libfrontend.a
[ 99%] Built target frontend
[100%] Building CXX object src/CMakeFiles/compiler.dir/main.cpp.o
In file included from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/ParserRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/InterpreterRuleContext.h:8,
from /home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/antlr4-runtime.h:30,
from /home/mxr/compiler/build/generated/antlr4/SysYLexer.h:7,
from /home/mxr/compiler/include/frontend/AntlrDriver.h:7,
from /home/mxr/compiler/src/main.cpp:5:
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/tree/ParseTree.h:50:18: warning: virtual bool antlr4::tree::ParseTree::operator==(const antlr4::tree::ParseTree&) const was hidden [-Woverloaded-virtual=]
50 | virtual bool operator == (const ParseTree &other) const;
| ^~~~~~~~
/home/mxr/compiler/third_party/antlr4-runtime-4.13.2/runtime/src/RuleContext.h:135:10: note: by bool antlr4::RuleContext::operator==(const antlr4::RuleContext&)
135 | bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
| ^~~~~~~~
/home/mxr/compiler/src/main.cpp: In function int main(int, char**):
/home/mxr/compiler/src/main.cpp:25:10: warning: variable need_blank_line set but not used [-Wunused-but-set-variable]
25 | bool need_blank_line = false;
| ^~~~~~~~~~~~~~~
[100%] Linking CXX executable ../bin/compiler
[100%] Built target compiler
gmake[1]: warning: Clock skew detected. Your build may be incomplete.

@ -56,6 +56,8 @@ class SymbolTable {
bool addSymbol(const Symbol& sym); // 添加符号到当前作用域
Symbol* lookup(const std::string& name); // 从当前作用域向外查找
Symbol* lookupCurrent(const std::string& name); // 仅在当前作用域查找
const Symbol* lookup(const std::string& name) const;
const Symbol* lookupCurrent(const std::string& name) const;
// ----- 与原接口兼容(保留原有功能)-----
void Add(const std::string& name, SysYParser::VarDefContext* decl);
@ -63,14 +65,40 @@ class SymbolTable {
SysYParser::VarDefContext* Lookup(const std::string& name) const;
// ----- 辅助函数:从语法树节点构造 Type -----
static std::shared_ptr<ir::Type> getTypeFromVarDef(SysYParser::VarDefContext* ctx);
static std::shared_ptr<ir::Type> getTypeFromFuncDef(SysYParser::FuncDefContext* ctx);
void registerBuiltinFunctions();
// 对常量表达式求值(返回整数值,用于数组维度等)
int EvaluateConstExp(SysYParser::ConstExpContext* ctx) const;
// 对常量表达式求值(返回浮点值,用于全局初始化)
float EvaluateConstExpFloat(SysYParser::ConstExpContext* ctx) const;
// 对常量初始化列表求值,返回一系列常量值(扁平化)
struct ConstValue {
enum Kind { INT, FLOAT };
Kind kind;
union {
int int_val;
float float_val;
};
};
std::vector<ConstValue> EvaluateConstInitVal(
SysYParser::ConstInitValContext* ctx,
const std::vector<int>& dims,
std::shared_ptr<ir::Type> base_type) const;
private:
// 作用域栈:每个元素是一个从名字到符号的映射
std::vector<std::unordered_map<std::string, Symbol>> scopes_;
static constexpr int GLOBAL_SCOPE = 0; // 全局作用域索引
ConstValue EvaluateAddExp(SysYParser::AddExpContext* ctx) const;
ConstValue EvaluateMulExp(SysYParser::MulExpContext* ctx) const;
ConstValue EvaluateUnaryExp(SysYParser::UnaryExpContext* ctx) const;
ConstValue EvaluatePrimaryExp(SysYParser::PrimaryExpContext* ctx) const;
std::shared_ptr<ir::Type> getTypeFromVarDef(SysYParser::VarDefContext* ctx) const;
};

@ -180,7 +180,7 @@ public:
if (is_array) {
// 处理数组维度
for (auto* dim_exp : ctx->constExp()) {
int dim = EvaluateConstExp(dim_exp);
int dim = table_.EvaluateConstExp(dim_exp);
if (dim <= 0) {
throw std::runtime_error(FormatError("sema", "数组维度必须为正整数"));
}
@ -265,7 +265,7 @@ public:
<< " dim_count: " << ctx->constExp().size() << std::endl;
if (is_array) {
for (auto* dim_exp : ctx->constExp()) {
int dim = EvaluateConstExp(dim_exp);
int dim = table_.EvaluateConstExp(dim_exp);
if (dim <= 0) {
throw std::runtime_error(FormatError("sema", "数组维度必须为正整数"));
}
@ -276,9 +276,9 @@ public:
std::cout << "[DEBUG] 创建数组类型完成IsArray: " << type->IsArray() << std::endl;
}
// 求值初始化器
std::vector<ConstValue> init_values;
std::vector<SymbolTable::ConstValue> init_values;
if (ctx->constInitVal()) {
init_values = EvaluateConstInitVal(ctx->constInitVal(), dims, base_type);
init_values = table_.EvaluateConstInitVal(ctx->constInitVal(), dims, base_type);
std::cout << "[DEBUG] 初始化值数量: " << init_values.size() << std::endl;
}
// 检查初始化值数量
@ -300,14 +300,12 @@ public:
sym.var_def_ctx = nullptr;
// 存储常量值(仅对非数组有效)
if (!is_array && !init_values.empty()) {
if (base_type->IsInt32() && init_values[0].is_int) {
if (base_type->IsInt32() && init_values[0].kind == SymbolTable::ConstValue::INT) {
sym.is_int_const = true;
sym.const_value.i32 = init_values[0].int_val;
std::cout << "[DEBUG] 存储整型常量值: " << init_values[0].int_val << std::endl;
} else if (base_type->IsFloat() && !init_values[0].is_int) {
} else if (base_type->IsFloat() && init_values[0].kind == SymbolTable::ConstValue::FLOAT) {
sym.is_int_const = false;
sym.const_value.f32 = init_values[0].float_val;
std::cout << "[DEBUG] 存储浮点常量值: " << init_values[0].float_val << std::endl;
}
} else if (is_array) {
std::cout << "[DEBUG] 数组常量,不存储单个常量值" << std::endl;

@ -1,5 +1,9 @@
#include "sem/SymbolTable.h"
#include <antlr4-runtime.h> // 用于访问父节点
#include <cctype>
#include <stdexcept>
#include <string>
#include <cmath>
// ---------- 构造函数 ----------
SymbolTable::SymbolTable() {
@ -30,9 +34,16 @@ bool SymbolTable::addSymbol(const Symbol& sym) {
}
Symbol* SymbolTable::lookup(const std::string& name) {
// 从当前作用域向外层查找
return const_cast<Symbol*>(static_cast<const SymbolTable*>(this)->lookup(name));
}
Symbol* SymbolTable::lookupCurrent(const std::string& name) {
return const_cast<Symbol*>(static_cast<const SymbolTable*>(this)->lookupCurrent(name));
}
const Symbol* SymbolTable::lookup(const std::string& name) const {
for (auto it = scopes_.rbegin(); it != scopes_.rend(); ++it) {
auto& scope = *it;
const auto& scope = *it;
auto found = scope.find(name);
if (found != scope.end()) {
return &found->second;
@ -41,8 +52,8 @@ Symbol* SymbolTable::lookup(const std::string& name) {
return nullptr;
}
Symbol* SymbolTable::lookupCurrent(const std::string& name) {
auto& current_scope = scopes_.back();
const Symbol* SymbolTable::lookupCurrent(const std::string& name) const {
const auto& current_scope = scopes_.back();
auto it = current_scope.find(name);
if (it != current_scope.end()) {
return &it->second;
@ -109,45 +120,34 @@ static SysYParser::ConstDeclContext* getOuterConstDecl(SysYParser::VarDefContext
return nullptr;
}
// 常量表达式求值(占位,需实现真正的常量折叠)
static int evaluateConstExp(SysYParser::ConstExpContext* ctx) {
// TODO: 实现常量折叠目前返回0
return 0;
}
// 从 VarDefContext 构造类型
std::shared_ptr<ir::Type> SymbolTable::getTypeFromVarDef(SysYParser::VarDefContext* ctx) {
// 1. 获取基本类型int/float
// 原静态函数改为成员函数,并调用成员 EvaluateConstExp
std::shared_ptr<ir::Type> SymbolTable::getTypeFromVarDef(SysYParser::VarDefContext* ctx) const {
// 获取基本类型(同原代码,但通过外层 Decl 确定)
std::shared_ptr<ir::Type> base_type = nullptr;
auto varDecl = getOuterVarDecl(ctx);
if (varDecl) {
auto bType = varDecl->bType();
if (bType->Int()) {
base_type = ir::Type::GetInt32Type();
} else if (bType->Float()) {
base_type = ir::Type::GetFloatType();
}
if (bType->Int()) base_type = ir::Type::GetInt32Type();
else if (bType->Float()) base_type = ir::Type::GetFloatType();
} else {
auto constDecl = getOuterConstDecl(ctx);
if (constDecl) {
auto bType = constDecl->bType();
if (bType->Int()) {
base_type = ir::Type::GetInt32Type();
} else if (bType->Float()) {
base_type = ir::Type::GetFloatType();
}
if (bType->Int()) base_type = ir::Type::GetInt32Type();
else if (bType->Float()) base_type = ir::Type::GetFloatType();
}
}
if (!base_type) base_type = ir::Type::GetInt32Type();
if (!base_type) {
base_type = ir::Type::GetInt32Type(); // 默认 int
}
// 2. 解析数组维度(从 varDef 的 constExp 列表获取)
// 解析维度
std::vector<int> dims;
for (auto constExp : ctx->constExp()) {
int dimVal = evaluateConstExp(constExp);
dims.push_back(dimVal);
for (auto* dimExp : ctx->constExp()) {
int dim = EvaluateConstExp(dimExp); // 调用成员函数
if (dim <= 0) {
throw std::runtime_error("数组维度必须为正整数");
}
dims.push_back(dim);
}
if (!dims.empty()) {
@ -155,7 +155,6 @@ std::shared_ptr<ir::Type> SymbolTable::getTypeFromVarDef(SysYParser::VarDefConte
}
return base_type;
}
// 从 FuncDefContext 构造函数类型
std::shared_ptr<ir::Type> SymbolTable::getTypeFromFuncDef(SysYParser::FuncDefContext* ctx) {
// 1. 返回类型
@ -310,7 +309,7 @@ void SymbolTable::registerBuiltinFunctions() {
stoptime.scope_level = 0;
stoptime.is_builtin = true;
addSymbol(stoptime);
// getfarray: int getfarray(float arr[])
std::vector<std::shared_ptr<ir::Type>> getfarray_params = { ir::Type::GetPtrFloatType() };
Symbol getfarray;
@ -335,4 +334,262 @@ void SymbolTable::registerBuiltinFunctions() {
putfarray.scope_level = 0;
putfarray.is_builtin = true;
addSymbol(putfarray);
}
// ==================== 常量表达式求值实现 ====================
static long long ParseIntegerLiteral(const std::string& text) {
// 处理前缀0x/0X 十六进制0 八进制,否则十进制
if (text.size() > 2 && (text[0] == '0' && (text[1] == 'x' || text[1] == 'X'))) {
return std::stoll(text.substr(2), nullptr, 16);
} else if (text.size() > 1 && text[0] == '0') {
return std::stoll(text, nullptr, 8);
} else {
return std::stoll(text, nullptr, 10);
}
}
static float ParseFloatLiteral(const std::string& text) {
return std::stof(text);
}
SymbolTable::ConstValue SymbolTable::EvaluatePrimaryExp(SysYParser::PrimaryExpContext* ctx) const {
if (!ctx) throw std::runtime_error("常量表达式求值:无效 PrimaryExp");
if (ctx->lVal()) {
auto lval = ctx->lVal();
if (!lval->Ident()) throw std::runtime_error("常量表达式求值:无效左值");
std::string name = lval->Ident()->getText();
const Symbol* sym = lookup(name);
if (!sym) throw std::runtime_error("常量表达式求值:未定义的标识符 " + name);
if (sym->kind != SymbolKind::Constant)
throw std::runtime_error("常量表达式求值:标识符 " + name + " 不是常量");
ConstValue val;
if (sym->is_int_const) {
val.kind = ConstValue::INT;
val.int_val = sym->const_value.i32;
} else {
val.kind = ConstValue::FLOAT;
val.float_val = sym->const_value.f32;
}
return val;
}
else if (ctx->HEX_FLOAT() || ctx->DEC_FLOAT()) {
std::string text;
if (ctx->HEX_FLOAT()) text = ctx->HEX_FLOAT()->getText();
else text = ctx->DEC_FLOAT()->getText();
ConstValue val;
val.kind = ConstValue::FLOAT;
val.float_val = ParseFloatLiteral(text);
return val;
}
else if (ctx->HEX_INT() || ctx->OCTAL_INT() || ctx->DECIMAL_INT() || ctx->ZERO()) {
std::string text;
if (ctx->HEX_INT()) text = ctx->HEX_INT()->getText();
else if (ctx->OCTAL_INT()) text = ctx->OCTAL_INT()->getText();
else if (ctx->DECIMAL_INT()) text = ctx->DECIMAL_INT()->getText();
else text = ctx->ZERO()->getText();
ConstValue val;
val.kind = ConstValue::INT;
val.int_val = static_cast<int>(ParseIntegerLiteral(text));
return val;
}
else if (ctx->exp()) {
return EvaluateAddExp(ctx->exp()->addExp());
}
else {
throw std::runtime_error("常量表达式求值:不支持的 PrimaryExp 类型");
}
}
SymbolTable::ConstValue SymbolTable::EvaluateUnaryExp(SysYParser::UnaryExpContext* ctx) const {
if (!ctx) throw std::runtime_error("常量表达式求值:无效 UnaryExp");
if (ctx->primaryExp()) {
return EvaluatePrimaryExp(ctx->primaryExp());
}
else if (ctx->unaryOp()) {
ConstValue operand = EvaluateUnaryExp(ctx->unaryExp());
std::string op = ctx->unaryOp()->getText();
if (op == "+") {
return operand;
}
else if (op == "-") {
if (operand.kind == ConstValue::INT) {
operand.int_val = -operand.int_val;
} else {
operand.float_val = -operand.float_val;
}
return operand;
}
else if (op == "!") {
if (operand.kind != ConstValue::INT) {
throw std::runtime_error("常量表达式求值:逻辑非操作数必须是整数");
}
ConstValue res;
res.kind = ConstValue::INT;
res.int_val = (operand.int_val == 0) ? 1 : 0;
return res;
}
else {
throw std::runtime_error("常量表达式求值:未知一元运算符 " + op);
}
}
else {
// 函数调用在常量表达式中不允许
throw std::runtime_error("常量表达式求值:不允许函数调用");
}
}
SymbolTable::ConstValue SymbolTable::EvaluateMulExp(SysYParser::MulExpContext* ctx) const {
if (!ctx) throw std::runtime_error("常量表达式求值:无效 MulExp");
if (ctx->mulExp()) {
ConstValue left = EvaluateMulExp(ctx->mulExp());
ConstValue right = EvaluateUnaryExp(ctx->unaryExp());
std::string op;
if (ctx->MulOp()) op = "*";
else if (ctx->DivOp()) op = "/";
else if (ctx->QuoOp()) op = "%";
else throw std::runtime_error("常量表达式求值:未知乘法运算符");
bool is_float = (left.kind == ConstValue::FLOAT || right.kind == ConstValue::FLOAT);
if (is_float) {
float l = (left.kind == ConstValue::INT) ? static_cast<float>(left.int_val) : left.float_val;
float r = (right.kind == ConstValue::INT) ? static_cast<float>(right.int_val) : right.float_val;
ConstValue res;
res.kind = ConstValue::FLOAT;
if (op == "*") res.float_val = l * r;
else if (op == "/") res.float_val = l / r;
else if (op == "%") throw std::runtime_error("常量表达式求值:浮点数不支持取模运算");
return res;
} else {
int l = left.int_val;
int r = right.int_val;
ConstValue res;
res.kind = ConstValue::INT;
if (op == "*") res.int_val = l * r;
else if (op == "/") {
if (r == 0) throw std::runtime_error("常量表达式求值:除零错误");
res.int_val = l / r;
}
else if (op == "%") {
if (r == 0) throw std::runtime_error("常量表达式求值:模零错误");
res.int_val = l % r;
}
return res;
}
}
else {
return EvaluateUnaryExp(ctx->unaryExp());
}
}
SymbolTable::ConstValue SymbolTable::EvaluateAddExp(SysYParser::AddExpContext* ctx) const {
if (!ctx) throw std::runtime_error("常量表达式求值:无效 AddExp");
if (ctx->addExp()) {
ConstValue left = EvaluateAddExp(ctx->addExp());
ConstValue right = EvaluateMulExp(ctx->mulExp());
std::string op;
if (ctx->AddOp()) op = "+";
else if (ctx->SubOp()) op = "-";
else throw std::runtime_error("常量表达式求值:未知加法运算符");
bool is_float = (left.kind == ConstValue::FLOAT || right.kind == ConstValue::FLOAT);
if (is_float) {
float l = (left.kind == ConstValue::INT) ? static_cast<float>(left.int_val) : left.float_val;
float r = (right.kind == ConstValue::INT) ? static_cast<float>(right.int_val) : right.float_val;
ConstValue res;
res.kind = ConstValue::FLOAT;
if (op == "+") res.float_val = l + r;
else res.float_val = l - r;
return res;
} else {
int l = left.int_val;
int r = right.int_val;
ConstValue res;
res.kind = ConstValue::INT;
if (op == "+") res.int_val = l + r;
else res.int_val = l - r;
return res;
}
}
else {
return EvaluateMulExp(ctx->mulExp());
}
}
int SymbolTable::EvaluateConstExp(SysYParser::ConstExpContext* ctx) const {
if (!ctx || !ctx->addExp())
throw std::runtime_error("常量表达式求值:无效 ConstExp");
ConstValue val = EvaluateAddExp(ctx->addExp());
if (val.kind == ConstValue::INT) {
return val.int_val;
} else {
float f = val.float_val;
int i = static_cast<int>(f);
if (std::abs(f - i) > 1e-6) {
throw std::runtime_error("常量表达式求值:浮点常量不能隐式转换为整数");
}
return i;
}
}
float SymbolTable::EvaluateConstExpFloat(SysYParser::ConstExpContext* ctx) const {
if (!ctx || !ctx->addExp())
throw std::runtime_error("常量表达式求值:无效 ConstExp");
ConstValue val = EvaluateAddExp(ctx->addExp());
if (val.kind == ConstValue::INT) {
return static_cast<float>(val.int_val);
} else {
return val.float_val;
}
}
std::vector<SymbolTable::ConstValue> SymbolTable::EvaluateConstInitVal(
SysYParser::ConstInitValContext* ctx,
const std::vector<int>& dims,
std::shared_ptr<ir::Type> base_type) const
{
std::vector<ConstValue> result;
if (!ctx) return result;
if (ctx->constExp()) {
ConstValue val = EvaluateAddExp(ctx->constExp()->addExp());
// 根据基础类型进行可能的隐式转换
if (base_type->IsInt32() && val.kind == ConstValue::FLOAT) {
int i = static_cast<int>(val.float_val);
if (std::abs(val.float_val - i) > 1e-6) {
throw std::runtime_error("常量初始化:浮点常量不能隐式转换为整数");
}
val.kind = ConstValue::INT;
val.int_val = i;
} else if (base_type->IsFloat() && val.kind == ConstValue::INT) {
val.kind = ConstValue::FLOAT;
val.float_val = static_cast<float>(val.int_val);
}
result.push_back(val);
} else {
// 嵌套初始化列表
if (dims.empty()) {
throw std::runtime_error("常量初始化:非数组使用初始化列表");
}
std::vector<int> sub_dims(dims.begin() + 1, dims.end());
int expected_count = 1;
for (int d : sub_dims) expected_count *= d;
for (auto* sub_init : ctx->constInitVal()) {
auto sub_vals = EvaluateConstInitVal(sub_init, sub_dims, base_type);
if (sub_vals.size() != static_cast<size_t>(expected_count)) {
throw std::runtime_error("常量初始化:子列表元素数量不匹配");
}
result.insert(result.end(), sub_vals.begin(), sub_vals.end());
}
}
return result;
}
Loading…
Cancel
Save