├── .clang-format ├── .gitmodules ├── .travis.yml ├── 3rdparty ├── CMakeLists.txt ├── Qt │ ├── CMakeLists.txt │ ├── api │ │ ├── QApplication.loci │ │ ├── QMessageBox.loci │ │ ├── QString.loci │ │ └── QTextEdit.loci │ └── src │ │ ├── QApplication.cpp │ │ ├── QMessageBox.cpp │ │ ├── QString.cpp │ │ └── QTextEdit.cpp ├── README └── SFML │ ├── CMakeLists.txt │ └── api │ ├── CircleShape.loci │ ├── Clock.loci │ ├── Color.loci │ ├── Event.loci │ ├── Font.loci │ ├── Mouse.loci │ ├── Rect.loci │ ├── RectangleShape.loci │ ├── RenderWindow.loci │ ├── Text.loci │ ├── Vector.loci │ ├── VideoMode.loci │ └── View.loci ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake ├── ConcatFiles.cmake ├── LLVMABI.cmake ├── LociModule.cmake ├── MakeCString.cmake ├── PrecompiledHeader.cmake └── modules │ ├── FindCSFML.cmake │ ├── FindClang.cmake │ └── FindSphinx.cmake ├── docs ├── AlgebraicDatatypes.rst ├── AssertStatement.rst ├── CMakeLists.txt ├── CircularQueue.odg ├── CircularQueue.png ├── CircularQueue.svg ├── Classes.rst ├── CompatibilityWithC.rst ├── CompilerDesign.rst ├── Concurrency.rst ├── Const.rst ├── Containers.rst ├── ControlFlow.rst ├── DynamicDispatch.rst ├── Exceptions.rst ├── FunctionOverloading.rst ├── GarbageCollection.rst ├── GettingStarted.rst ├── Hashing.rst ├── HeapMemoryManagement.rst ├── ImplicitOperations.rst ├── LLVMIntro.rst ├── LanguageGoals.rst ├── LifetimeMethods.rst ├── LinkedList.odg ├── LinkedList.png ├── LinkedList.svg ├── Literals.rst ├── LociCompilationModel.odg ├── LociCompilationModel.png ├── LociCompilationModel.svg ├── LvaluesAndRvalues.rst ├── Map.odg ├── Map.png ├── Map.svg ├── Modules.rst ├── MoveVersusCopy.rst ├── MultiPassCompilation.rst ├── NameMangling.rst ├── ObjectMemoryStates.rst ├── OperatorOverloading.rst ├── Predicates.rst ├── PrimitiveObjects.rst ├── Ranges.rst ├── References.rst ├── Releases.rst ├── Set.odg ├── Set.png ├── Set.svg ├── Strings.rst ├── StructuralTyping.rst ├── TemplateGenerators.rst ├── Templates.rst ├── Tuples.rst ├── UnusedValues.rst ├── ValueGenerators.rst ├── Variants.rst ├── Varray.odg ├── Varray.png ├── Varray.svg ├── VtableGeneration.rst ├── _themes │ └── sphinx_rtd_theme │ │ ├── LICENSE │ │ ├── __init__.py │ │ ├── breadcrumbs.html │ │ ├── footer.html │ │ ├── layout.html │ │ ├── layout_old.html │ │ ├── search.html │ │ ├── searchbox.html │ │ ├── static │ │ ├── css │ │ │ ├── badge_only.css │ │ │ └── theme.css │ │ ├── fonts │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ └── fontawesome-webfont.woff │ │ └── js │ │ │ └── theme.js │ │ ├── theme.conf │ │ └── versions.html ├── conf.py ├── index.rst ├── proposals │ ├── AtomicOperations.rst │ ├── CastingRules.rst │ ├── ClassInheritance.rst │ ├── ExceptionSpecifications.rst │ ├── FutureStandardLibraryModules.rst │ ├── ImprovementsToAPIs.rst │ ├── InteractingWithC++.rst │ ├── LateMoveParameters.rst │ ├── MergeTemplateGeneratorsAndVtables.rst │ ├── NamedParameters.rst │ ├── ObjectProperties.rst │ ├── RTTI.rst │ ├── RemoveLifetimeMethods.rst │ ├── StyleRules.rst │ ├── VariadicTemplates.rst │ ├── VectorTypes.rst │ └── VirtualTemplateVariables.rst └── static │ └── README ├── examples ├── CMakeLists.txt ├── Calculator │ ├── CMakeLists.txt │ └── Calculator.loci ├── ChainReversi │ ├── ANN │ │ ├── Layer.loci │ │ ├── Net.loci │ │ └── Neuron.loci │ ├── CMakeLists.txt │ ├── CR │ │ ├── AIPlayer.loci │ │ ├── ANNPlayer.loci │ │ ├── Board.loci │ │ ├── BoardAnalysis.loci │ │ ├── HumanPlayer.loci │ │ ├── Player.loci │ │ ├── Position.loci │ │ └── Value.loci │ ├── Data │ │ └── font.ttf │ └── main.loci ├── CommandLine │ ├── CMakeLists.txt │ └── CommandLine.loci ├── Events │ ├── CMakeLists.txt │ ├── Events.loci │ ├── MessageQueue.loci │ ├── Threads.loci │ └── main.loci ├── GUI │ ├── CMakeLists.txt │ └── main.loci ├── Looper │ ├── CMakeLists.txt │ └── Looper.loci ├── Network │ ├── CMakeLists.txt │ ├── TCP.loci │ └── main.loci ├── Simulations │ ├── CMakeLists.txt │ ├── Checkpoint │ │ ├── Particle.loci │ │ ├── RandomSimulation.loci │ │ └── Target.loci │ ├── Data │ │ └── font.ttf │ ├── Flocking │ │ ├── Boid.loci │ │ ├── Field.loci │ │ ├── FollowingSimulation.loci │ │ ├── Obstacle.loci │ │ └── System.loci │ ├── Gravity │ │ ├── CentralOrbitSimulation.loci │ │ ├── Particle.loci │ │ └── System.loci │ ├── Random.loci │ ├── Simulation.loci │ ├── SimulationList.loci │ ├── Support.loci │ ├── Vector.loci │ └── main.loci └── SplitModule │ ├── A.loci │ ├── B.loci │ └── CMakeLists.txt ├── include └── locic │ ├── AST.hpp │ ├── AST │ ├── Alias.hpp │ ├── CatchClause.hpp │ ├── ConstSpecifier.hpp │ ├── Context.hpp │ ├── ExceptionInitializer.hpp │ ├── ExitStates.hpp │ ├── Function.hpp │ ├── FunctionType.hpp │ ├── GlobalStructure.hpp │ ├── IfClause.hpp │ ├── MethodSet.hpp │ ├── MethodSetElement.hpp │ ├── Module.hpp │ ├── ModuleScope.hpp │ ├── ModuleScopeDecl.hpp │ ├── Namespace.hpp │ ├── NamespaceDecl.hpp │ ├── Node.hpp │ ├── Predicate.hpp │ ├── PredicateDecl.hpp │ ├── RequireSpecifier.hpp │ ├── Scope.hpp │ ├── Statement.hpp │ ├── StatementDecl.hpp │ ├── StaticAssert.hpp │ ├── StringList.hpp │ ├── SwitchCase.hpp │ ├── Symbol.hpp │ ├── TemplateVar.hpp │ ├── TemplateVarArray.hpp │ ├── TemplateVarMap.hpp │ ├── TemplatedObject.hpp │ ├── Type.hpp │ ├── TypeArray.hpp │ ├── TypeDecl.hpp │ ├── TypeInstance.hpp │ ├── Value.hpp │ ├── ValueArray.hpp │ ├── ValueDecl.hpp │ ├── ValueDeclList.hpp │ └── Var.hpp │ ├── CodeGen │ ├── ASTCodeEmitter.hpp │ ├── ASTFunctionGenerator.hpp │ ├── ArgInfo.hpp │ ├── BuildOptions.hpp │ ├── CallEmitter.hpp │ ├── CodeGenerator.hpp │ ├── ConstantGenerator.hpp │ ├── Context.hpp │ ├── ControlFlow.hpp │ ├── Debug.hpp │ ├── DefaultMethodEmitter.hpp │ ├── Exception.hpp │ ├── Function.hpp │ ├── FunctionCallInfo.hpp │ ├── FunctionTranslationStub.hpp │ ├── GenABIType.hpp │ ├── GenDebugType.hpp │ ├── GenVTable.hpp │ ├── IREmitter.hpp │ ├── Interface.hpp │ ├── InternalContext.hpp │ ├── Interpreter.hpp │ ├── LLVMIncludes.hpp │ ├── Linker.hpp │ ├── LivenessEmitter.hpp │ ├── LivenessIndicator.hpp │ ├── LivenessInfo.hpp │ ├── Mangling.hpp │ ├── MethodInfo.hpp │ ├── Module.hpp │ ├── ModulePtr.hpp │ ├── Optimisations.hpp │ ├── PendingResult.hpp │ ├── Primitive.hpp │ ├── PrimitiveFunctionEmitter.hpp │ ├── PrimitiveMap.hpp │ ├── Primitives.hpp │ ├── Primitives │ │ ├── BoolPrimitive.hpp │ │ ├── CompareResultPrimitive.hpp │ │ ├── FloatPrimitive.hpp │ │ ├── FunctionPtrPrimitive.hpp │ │ ├── NullPrimitive.hpp │ │ ├── PtrPrimitive.hpp │ │ ├── RefPrimitive.hpp │ │ ├── SignedIntegerPrimitive.hpp │ │ ├── StaticArrayPrimitive.hpp │ │ ├── TypenamePrimitive.hpp │ │ ├── UnicharPrimitive.hpp │ │ ├── UnsignedIntegerPrimitive.hpp │ │ ├── ValueLvalPrimitive.hpp │ │ └── VoidPrimitive.hpp │ ├── Routines.hpp │ ├── ScopeEmitter.hpp │ ├── ScopeExitActions.hpp │ ├── SizeOf.hpp │ ├── StatementEmitter.hpp │ ├── Support.hpp │ ├── TargetOptions.hpp │ ├── Template.hpp │ ├── TemplateBuilder.hpp │ ├── TemplatedObject.hpp │ ├── TypeGenerator.hpp │ ├── TypeInfo.hpp │ ├── UnwindAction.hpp │ ├── UnwindState.hpp │ ├── VTable.hpp │ ├── ValueEmitter.hpp │ ├── VirtualCall │ │ ├── GenericVirtualCallABI.hpp │ │ └── NestVirtualCallABI.hpp │ ├── VirtualCallABI.hpp │ └── md5.h │ ├── Constant.hpp │ ├── Debug.hpp │ ├── Debug │ ├── CompilerInfo.hpp │ ├── FunctionInfo.hpp │ ├── Module.hpp │ ├── SourceLocation.hpp │ ├── SourcePosition.hpp │ ├── SourceRange.hpp │ ├── StatementInfo.hpp │ ├── TemplateVarInfo.hpp │ ├── TypeInstanceInfo.hpp │ ├── ValueInfo.hpp │ └── VarInfo.hpp │ ├── Exception.hpp │ ├── Frontend │ ├── DiagnosticArray.hpp │ ├── DiagnosticReceiver.hpp │ ├── DiagnosticRenderer.hpp │ ├── Diagnostics.hpp │ ├── OptionalDiag.hpp │ └── ResultOrDiag.hpp │ ├── Lex │ ├── Character.hpp │ ├── CharacterReader.hpp │ ├── CharacterSource.hpp │ ├── Diagnostics.hpp │ ├── FileCharacterSource.hpp │ ├── IdentifierLexer.hpp │ ├── Lexer.hpp │ ├── LexerAPI.hpp │ ├── NumericValue.hpp │ ├── StringLiteralLexer.hpp │ └── Token.hpp │ ├── Parser │ ├── AttributeBuilder.hpp │ ├── AttributeParser.hpp │ ├── DefaultParser.hpp │ ├── FunctionBuilder.hpp │ ├── FunctionParser.hpp │ ├── NamespaceBuilder.hpp │ ├── NamespaceParser.hpp │ ├── PredicateBuilder.hpp │ ├── PredicateParser.hpp │ ├── ScopeParser.hpp │ ├── StatementBuilder.hpp │ ├── StatementParser.hpp │ ├── SymbolBuilder.hpp │ ├── SymbolParser.hpp │ ├── TemplateBuilder.hpp │ ├── TemplateInfo.hpp │ ├── TemplateParser.hpp │ ├── Token.hpp │ ├── TokenReader.hpp │ ├── TypeBuilder.hpp │ ├── TypeInstanceBuilder.hpp │ ├── TypeInstanceParser.hpp │ ├── TypeParser.hpp │ ├── ValueBuilder.hpp │ ├── ValueParser.hpp │ ├── VarBuilder.hpp │ └── VarParser.hpp │ ├── SemanticAnalysis.hpp │ ├── SemanticAnalysis │ ├── AliasTypeResolver.hpp │ ├── Analysis.hpp │ ├── CallValue.hpp │ ├── Cast.hpp │ ├── CastGenerator.hpp │ ├── CastRules.hpp │ ├── CastSequence.hpp │ ├── Context.hpp │ ├── ConvertException.hpp │ ├── ConvertForLoop.hpp │ ├── ConvertFunctionDecl.hpp │ ├── ConvertFunctionDef.hpp │ ├── ConvertModuleScope.hpp │ ├── ConvertNamespace.hpp │ ├── ConvertPredicate.hpp │ ├── ConvertScope.hpp │ ├── ConvertStatement.hpp │ ├── ConvertTypeInstance.hpp │ ├── ConvertValue.hpp │ ├── ConvertVar.hpp │ ├── DefaultMethods.hpp │ ├── Exception.hpp │ ├── GetMethod.hpp │ ├── GetMethodSet.hpp │ ├── Literal.hpp │ ├── NameSearch.hpp │ ├── Passes.hpp │ ├── Ref.hpp │ ├── SatisfyChecker.hpp │ ├── ScopeElement.hpp │ ├── ScopeStack.hpp │ ├── SearchResult.hpp │ ├── Template.hpp │ ├── TemplateInst.hpp │ ├── TypeBuilder.hpp │ ├── TypeCapabilities.hpp │ ├── TypeResolver.hpp │ ├── Unifier.hpp │ └── VarArgCast.hpp │ └── Support │ ├── APInt.hpp │ ├── Array.hpp │ ├── Compiler.hpp │ ├── Copy.hpp │ ├── ErrorHandling.hpp │ ├── FastMap.hpp │ ├── Hash.hpp │ ├── Hasher.hpp │ ├── HeapArray.hpp │ ├── MakeArray.hpp │ ├── MakeString.hpp │ ├── Map.hpp │ ├── MethodID.hpp │ ├── MethodIDMap.hpp │ ├── Name.hpp │ ├── Optional.hpp │ ├── PrimitiveID.hpp │ ├── PrimitiveIDMap.hpp │ ├── SharedMaps.hpp │ ├── StableSet.hpp │ ├── String.hpp │ ├── StringBuilder.hpp │ ├── StringHost.hpp │ ├── Utils.hpp │ └── Version.hpp ├── lib ├── AST │ ├── Alias.cpp │ ├── CMakeLists.txt │ ├── CatchClause.cpp │ ├── ConstSpecifier.cpp │ ├── Context.cpp │ ├── ExceptionInitializer.cpp │ ├── Function.cpp │ ├── FunctionType.cpp │ ├── GlobalStructure.cpp │ ├── IfClause.cpp │ ├── MethodSet.cpp │ ├── MethodSetElement.cpp │ ├── Module.cpp │ ├── ModuleScope.cpp │ ├── ModuleScopeDecl.cpp │ ├── Namespace.cpp │ ├── NamespaceDecl.cpp │ ├── Predicate.cpp │ ├── PredicateDecl.cpp │ ├── RequireSpecifier.cpp │ ├── Scope.cpp │ ├── Statement.cpp │ ├── StatementDecl.cpp │ ├── StaticAssert.cpp │ ├── SwitchCase.cpp │ ├── Symbol.cpp │ ├── TemplateVar.cpp │ ├── TemplateVarMap.cpp │ ├── Type.cpp │ ├── TypeDecl.cpp │ ├── TypeInstance.cpp │ ├── Value.cpp │ ├── ValueDecl.cpp │ └── Var.cpp ├── CMakeLists.txt ├── CodeGen │ ├── ASTCodeEmitter.cpp │ ├── ASTFunctionGenerator.cpp │ ├── ArgInfo.cpp │ ├── CMakeLists.txt │ ├── CallEmitter.cpp │ ├── CodeGenerator.cpp │ ├── ConstantGenerator.cpp │ ├── Context.cpp │ ├── ControlFlow.cpp │ ├── Debug.cpp │ ├── DefaultMethodEmitter.cpp │ ├── Exception.cpp │ ├── Function.cpp │ ├── FunctionCallInfo.cpp │ ├── FunctionTranslationStub.cpp │ ├── GenABIType.cpp │ ├── GenDebugType.cpp │ ├── GenVTable.cpp │ ├── IREmitter.cpp │ ├── Interface.cpp │ ├── InternalContext.cpp │ ├── Interpreter.cpp │ ├── LLVMIncludes.hpp │ ├── Linker.cpp │ ├── LivenessEmitter.cpp │ ├── LivenessIndicator.cpp │ ├── LivenessInfo.cpp │ ├── Mangling.cpp │ ├── MethodInfo.cpp │ ├── Module.cpp │ ├── ModulePtr.cpp │ ├── PendingResult.cpp │ ├── PrimitiveFunctionEmitter.cpp │ ├── PrimitiveMap.cpp │ ├── Primitives │ │ ├── BoolPrimitive.cpp │ │ ├── CompareResultPrimitive.cpp │ │ ├── FloatPrimitive.cpp │ │ ├── FunctionPtrPrimitive.cpp │ │ ├── NullPrimitive.cpp │ │ ├── PrimitiveMethod.cpp │ │ ├── PrimitiveSizeOf.cpp │ │ ├── PrimitiveTypes.cpp │ │ ├── PtrPrimitive.cpp │ │ ├── RefPrimitive.cpp │ │ ├── SignedIntegerPrimitive.cpp │ │ ├── StaticArrayPrimitive.cpp │ │ ├── TypenamePrimitive.cpp │ │ ├── UnicharPrimitive.cpp │ │ ├── UnsignedIntegerPrimitive.cpp │ │ ├── ValueLvalPrimitive.cpp │ │ └── VoidPrimitive.cpp │ ├── Routines.cpp │ ├── ScopeEmitter.cpp │ ├── ScopeExitActions.cpp │ ├── SizeOf.cpp │ ├── StatementEmitter.cpp │ ├── Support.cpp │ ├── Template.cpp │ ├── TemplateBuilder.cpp │ ├── TemplatedObject.cpp │ ├── TypeGenerator.cpp │ ├── TypeInfo.cpp │ ├── UnwindAction.cpp │ ├── VTable.cpp │ ├── ValueEmitter.cpp │ ├── VirtualCall │ │ ├── GenericVirtualCallABI.cpp │ │ └── NestVirtualCallABI.cpp │ └── md5.cpp ├── Frontend │ ├── CMakeLists.txt │ ├── DiagnosticRenderer.cpp │ └── OptionalDiag.cpp ├── Lex │ ├── CMakeLists.txt │ ├── CharacterReader.cpp │ ├── FileCharacterSource.cpp │ ├── IdentifierLexer.cpp │ ├── Lexer.cpp │ └── StringLiteralLexer.cpp ├── Parser │ ├── AttributeBuilder.cpp │ ├── AttributeParser.cpp │ ├── CMakeLists.txt │ ├── DefaultParser.cpp │ ├── FunctionBuilder.cpp │ ├── FunctionParser.cpp │ ├── LexLexer.hpp │ ├── NamespaceBuilder.cpp │ ├── NamespaceParser.cpp │ ├── PredicateBuilder.cpp │ ├── PredicateParser.cpp │ ├── ScopeParser.cpp │ ├── StatementBuilder.cpp │ ├── StatementParser.cpp │ ├── SymbolBuilder.cpp │ ├── SymbolParser.cpp │ ├── TemplateBuilder.cpp │ ├── TemplateInfo.cpp │ ├── TemplateParser.cpp │ ├── TokenReader.cpp │ ├── TypeBuilder.cpp │ ├── TypeInstanceBuilder.cpp │ ├── TypeInstanceParser.cpp │ ├── TypeParser.cpp │ ├── ValueBuilder.cpp │ ├── ValueParser.cpp │ ├── VarBuilder.cpp │ └── VarParser.cpp ├── SemanticAnalysis │ ├── AliasTypeResolver.cpp │ ├── Analysis.cpp │ ├── CMakeLists.txt │ ├── CallValue.cpp │ ├── Cast.cpp │ ├── CastGenerator.cpp │ ├── CastSequence.cpp │ ├── Context.cpp │ ├── ConvertException.cpp │ ├── ConvertForLoop.cpp │ ├── ConvertFunctionDecl.cpp │ ├── ConvertFunctionDef.cpp │ ├── ConvertModuleScope.cpp │ ├── ConvertNamespace.cpp │ ├── ConvertPredicate.cpp │ ├── ConvertScope.cpp │ ├── ConvertStatement.cpp │ ├── ConvertTypeInstance.cpp │ ├── ConvertValue.cpp │ ├── ConvertVar.cpp │ ├── DefaultMethods.cpp │ ├── GetMethod.cpp │ ├── GetMethodSet.cpp │ ├── Literal.cpp │ ├── NameSearch.cpp │ ├── Passes │ │ ├── AddAliasValuesPass.cpp │ │ ├── AddFunctionDeclsPass.cpp │ │ ├── AddFunctionTypesPass.cpp │ │ ├── AddGlobalStructuresPass.cpp │ │ ├── AddTemplateVariableTypesPass.cpp │ │ ├── AddTypeMemberVariablesPass.cpp │ │ ├── CheckTemplateInstantiationsPass.cpp │ │ ├── CompleteFunctionTemplateVariableRequirementsPass.cpp │ │ ├── CompleteTypeTemplateVariableRequirementsPass.cpp │ │ ├── EvaluateStaticAssertsPass.cpp │ │ └── GenerateDefaultMethodsPass.cpp │ ├── Ref.cpp │ ├── SatisfyChecker.cpp │ ├── ScopeElement.cpp │ ├── ScopeStack.cpp │ ├── SearchResult.cpp │ ├── Template.cpp │ ├── TypeBuilder.cpp │ ├── TypeCapabilities.cpp │ ├── TypeResolver.cpp │ ├── Unifier.cpp │ └── VarArgCast.cpp └── Support │ ├── APInt.cpp │ ├── CMakeLists.txt │ ├── ErrorHandling.cpp │ ├── Hasher.cpp │ ├── MethodID.cpp │ ├── MethodIDMap.cpp │ ├── Name.cpp │ ├── PrimitiveID.cpp │ ├── PrimitiveIDMap.cpp │ ├── String.cpp │ ├── StringHost.cpp │ └── Version.cpp ├── runtime ├── CMakeLists.txt ├── assert.cpp ├── atomic_t.loci ├── bool_t.loci ├── byte_t.loci ├── callable.loci ├── castable.loci ├── comparable.loci ├── compare_result_t.loci ├── copyable.loci ├── decrementable.loci ├── default_constructible.loci ├── destructible.loci ├── dissolvable.loci ├── double_t.loci ├── exception.cpp ├── float_t.loci ├── function_ptr_t.loci ├── hashable.loci ├── incrementable.loci ├── int16_t.loci ├── int32_t.loci ├── int64_t.loci ├── int8_t.loci ├── int_t.loci ├── interfacemethod_t.loci ├── long_t.loci ├── longdouble_t.loci ├── longlong_t.loci ├── method_t.loci ├── methodfunction_ptr_t.loci ├── minmax.loci ├── movable.loci ├── null_t.loci ├── ptr_t.loci ├── ptrdiff_t.loci ├── range_t.loci ├── ref_t.loci ├── reverse_range_t.loci ├── short_t.loci ├── size_t.loci ├── sized_type.loci ├── ssize_t.loci ├── static_array_t.loci ├── staticinterfacemethod_t.loci ├── templatedfunction_ptr_t.loci ├── templatedmethod_t.loci ├── templatedmethodfunction_ptr_t.loci ├── typename_t.loci ├── ubyte_t.loci ├── uint16_t.loci ├── uint32_t.loci ├── uint64_t.loci ├── uint8_t.loci ├── uint_t.loci ├── ulong_t.loci ├── ulonglong_t.loci ├── unichar_t.loci ├── ushort_t.loci ├── value_lval_t.loci ├── varargfunction_ptr_t.loci ├── void_t.loci └── zero.loci ├── stdlib ├── CMakeLists.txt └── std │ ├── CMakeLists.txt │ ├── concurrency │ ├── CMakeLists.txt │ ├── api │ │ ├── condition_variable.loci │ │ ├── fiber.loci │ │ ├── message_queue.loci │ │ ├── mutex.loci │ │ ├── runnable.loci │ │ ├── thread.loci │ │ ├── thread_local.loci │ │ └── thread_specific_ptr.loci │ └── src │ │ └── unix │ │ ├── condition_variable.loci │ │ ├── fiber.loci │ │ ├── message_queue.loci │ │ ├── mutex.loci │ │ ├── pthread_cond_t.c │ │ ├── pthread_cond_t.loci │ │ ├── pthread_mutex_t.c │ │ ├── pthread_mutex_t.loci │ │ ├── pthread_t.c │ │ ├── pthread_t.loci │ │ ├── thread.loci │ │ └── thread_internal.loci │ ├── container │ ├── CMakeLists.txt │ ├── api │ │ ├── circular_queue.loci │ │ ├── hash.loci │ │ ├── list.loci │ │ ├── map.loci │ │ ├── range.loci │ │ ├── set.loci │ │ └── varray.loci │ └── src │ │ ├── circular_queue.loci │ │ ├── hash.loci │ │ ├── list.loci │ │ ├── map.loci │ │ ├── range.loci │ │ ├── set.loci │ │ └── varray.loci │ ├── event │ ├── CMakeLists.txt │ ├── api │ │ ├── generator.loci │ │ ├── source.loci │ │ └── wait_set.loci │ └── src │ │ └── unix │ │ ├── exception.loci │ │ ├── generator.loci │ │ ├── internal_generator.c │ │ ├── internal_wait.c │ │ ├── source.loci │ │ └── wait_set.loci │ ├── filesystem │ ├── CMakeLists.txt │ ├── api │ │ ├── file_stream.loci │ │ └── path.loci │ └── src │ │ ├── file_stream.loci │ │ ├── internal_path.c │ │ └── path.loci │ ├── future │ ├── CMakeLists.txt │ ├── api │ │ ├── future.loci │ │ └── promise.loci │ └── src │ │ ├── future.loci │ │ └── promise.loci │ ├── memory │ ├── CMakeLists.txt │ ├── api │ │ ├── alloc.loci │ │ ├── raw.loci │ │ ├── shared.loci │ │ └── unique.loci │ └── src │ │ ├── alloc.loci │ │ ├── raw.loci │ │ ├── shared.loci │ │ └── unique.loci │ ├── network │ ├── CMakeLists.txt │ ├── api │ │ ├── ip │ │ │ ├── address.loci │ │ │ └── address_v4.loci │ │ └── tcp │ │ │ ├── connector.loci │ │ │ ├── endpoint.loci │ │ │ ├── listener.loci │ │ │ ├── stream.loci │ │ │ └── sync_stream.loci │ └── src │ │ ├── ip │ │ ├── address.loci │ │ └── address_v4.loci │ │ └── tcp │ │ ├── connector.loci │ │ ├── endpoint.loci │ │ ├── internal_stream.c │ │ ├── listener.loci │ │ ├── stream.loci │ │ └── sync_stream.loci │ └── string │ ├── CMakeLists.txt │ ├── api │ ├── string.loci │ ├── string_builder.loci │ ├── string_iterator.loci │ ├── string_range.loci │ ├── utf8.loci │ ├── utf8_buffer.loci │ └── utf8_encoder.loci │ └── src │ ├── string.loci │ ├── string_builder.loci │ ├── string_iterator.loci │ ├── string_range.loci │ ├── utf8.loci │ ├── utf8_buffer.loci │ └── utf8_encoder.loci ├── test ├── CMakeLists.txt ├── CheckError │ ├── Cast │ │ ├── ConstRefLocalVarImplicitCopy.loci │ │ └── ConstRefMemberVarImplicitCopy.loci │ ├── Class │ │ ├── DuplicateClass.loci │ │ ├── DuplicateMemberVar.loci │ │ └── NoNullConstructor.loci │ ├── Conditional │ │ ├── IntCondition.loci │ │ ├── MismatchedTernaryValues.loci │ │ └── NonBoolCondition.loci │ ├── Const │ │ ├── CallNonConstMethodOnConstObject.loci │ │ ├── CallNonConstMethodOnConstPredicateObject.loci │ │ ├── CallNonConstMethodOnConstTemplateVar.loci │ │ ├── ConstPointerTransitivity.loci │ │ ├── ModifyConstLocalVariable.loci │ │ ├── ModifyConstParamVariable.loci │ │ └── ModifyConstValuePointer.loci │ ├── Datatype │ │ ├── CompareMultiLevelNonComparableDatatype.loci │ │ ├── CompareNonComparableDatatype.loci │ │ ├── ComparePartiallyNonComparableDatatype.loci │ │ ├── CopyMultiLevelNonCopyableDatatype.loci │ │ ├── CopyNonCopyableDatatype.loci │ │ └── CopyPartiallyNonCopyableDatatype.loci │ ├── Exception │ │ ├── CallMethodOnlySpecifiedInNoExceptPredicate.loci │ │ └── NoExceptPredicateReverseImplication.loci │ ├── Move │ │ └── MoveNonMovableTemplateType.loci │ ├── Primitives │ │ ├── InvalidConstantStaticArraySizeParameter.loci │ │ └── InvalidTemplateStaticArraySizeParameter.loci │ ├── SizeOf │ │ ├── AlignOfUnsizedTemplateType.loci │ │ └── SizeOfUnsizedTemplateType.loci │ ├── Struct │ │ ├── OpaqueStructAlignOf.loci │ │ ├── OpaqueStructMove.loci │ │ ├── OpaqueStructPointerArithmetic.loci │ │ └── OpaqueStructSizeOf.loci │ ├── Syntax │ │ ├── InvalidArithmeticOperatorCombinations.loci │ │ ├── InvalidBitShiftInTemplateArgument.loci │ │ ├── InvalidComparisonInTemplateArgument.loci │ │ ├── InvalidComparisonOperatorSequence.loci │ │ ├── InvalidLogicOperatorSequence.loci │ │ ├── InvalidLvalues.loci │ │ └── InvalidShiftOperatorSequence.loci │ └── Templates │ │ ├── IncorrectTemplateType.loci │ │ ├── InvalidAliasTemplateVarType.loci │ │ └── InvalidTypeInstanceTemplateVarType.loci ├── CheckOutput │ ├── Alias │ │ ├── BasicPredicateAlias.loci │ │ ├── BasicTypeAlias.loci │ │ ├── BasicValueAlias.loci │ │ ├── RecursivePredicateAlias.loci │ │ ├── RecursiveTemplatedPredicateAlias.loci │ │ ├── RecursiveTemplatedTypeAlias.loci │ │ ├── RecursiveTypeAlias.loci │ │ ├── RecursiveValueAlias.loci │ │ ├── TemplatedTypeAlias.loci │ │ └── TemplatedTypeAliasSpecType.loci │ ├── Assert │ │ └── BasicAssert.loci │ ├── Auto │ │ ├── AutoImplicitCopy.loci │ │ ├── AutoInt.loci │ │ ├── AutoMatchTemplate.loci │ │ └── AutoRefCast.loci │ ├── BindingRef │ │ ├── BasicConstRef.loci │ │ ├── BasicMutableRef.loci │ │ ├── ConstRefDestructor.loci │ │ └── MutableRefDestructor.loci │ ├── CTypes │ │ ├── Enum.loci │ │ ├── Union.loci │ │ └── UnionZeroInitialise.loci │ ├── Cast │ │ ├── ImplicitCopy.loci │ │ ├── IntImplicitCast.loci │ │ ├── NullConstructor.loci │ │ ├── RefImplicitDissolve.loci │ │ └── UserImplicitCast.loci │ ├── Class │ │ ├── BasicClass.loci │ │ ├── CanonicalizeConstructorName.loci │ │ ├── CanonicalizeMethodName.loci │ │ ├── Constructor.loci │ │ ├── EmptyClass.loci │ │ ├── ExtensionMethod.loci │ │ ├── ExtensionMethodMemberVariable.loci │ │ ├── ExtensionMethodPrimitive.loci │ │ ├── ImplicitCopy.loci │ │ ├── Self.loci │ │ └── This.loci │ ├── Conditional │ │ ├── BasicIf.loci │ │ ├── BasicTernary.loci │ │ ├── IfElse.loci │ │ ├── IfUnwind.loci │ │ ├── LogicalAndSideEffects.loci │ │ ├── LogicalOrSideEffects.loci │ │ ├── MultipleIf.loci │ │ ├── ShortCircuitLogicalAndSideEffects.loci │ │ ├── ShortCircuitLogicalOrSideEffects.loci │ │ └── TernarySideEffects.loci │ ├── Const │ │ ├── ConstLocalVariable.loci │ │ ├── ConstMethod.loci │ │ ├── ConstReferenceMember.loci │ │ └── ConstTemplatedMethod.loci │ ├── Datatype │ │ ├── BasicDatatype.loci │ │ ├── CompareDatatype.loci │ │ ├── CompareTemplatedDatatype.loci │ │ ├── CompareTemplatedUnionDatatype.loci │ │ ├── CompareUnionDatatype.loci │ │ ├── PatternMatch.loci │ │ ├── TemplatedDatatype.loci │ │ ├── TernaryUnionDatatype.loci │ │ └── UnionDatatype.loci │ ├── Defaults │ │ ├── DefaultCompare.loci │ │ ├── DefaultConstructor.loci │ │ ├── DefaultsMember.loci │ │ ├── RequestedDefaultExplicitCopy.loci │ │ └── RequestedDefaultImplicitCopy.loci │ ├── Destructor │ │ ├── BasicDestructor.loci │ │ ├── DestroyConstructedTemporary.loci │ │ ├── DestroyReturnValue.loci │ │ ├── DestroyReturnedValueAfterThrow.loci │ │ ├── DestroyUnusedArgument.loci │ │ ├── DestructorCallTemplateTypeMethod.loci │ │ ├── DirectlyCallDestructor.loci │ │ ├── RecursiveDestructor.loci │ │ ├── RecursiveDestructorMemberOrder.loci │ │ ├── RecursiveTemplatedDestructor.loci │ │ └── RecursiveTemplatedDestructorMemberOrder.loci │ ├── EvaluationOrder │ │ ├── AssignmentEvaluationOrder.loci │ │ └── MethodCallEvaluationOrder.loci │ ├── Exception │ │ ├── BasicException.loci │ │ ├── EmptyException.loci │ │ ├── HugeException.loci │ │ ├── InheritedException.loci │ │ ├── MultipleCatch.loci │ │ ├── NestedCatch.loci │ │ ├── PassThroughException.loci │ │ ├── RedundantCatch.loci │ │ ├── RethrowException.loci │ │ ├── ScopedCatch.loci │ │ └── TemplatedException.loci │ ├── Function │ │ ├── FunctionPtrCastCall.loci │ │ ├── FunctionRef.loci │ │ └── TemplatedFunctionRef.loci │ ├── Interface │ │ ├── BasicInterface.loci │ │ ├── CaseInsensitiveInterface.loci │ │ ├── CastBetweenInterfaces.loci │ │ ├── PrimitiveInterface.loci │ │ ├── TemplatedInterface.loci │ │ ├── VTableClash.loci │ │ ├── VirtualCallNonTemplateToTemplate.loci │ │ └── VirtualCallTemplateToNonTemplate.loci │ ├── Liveness │ │ ├── CustomLiveness.loci │ │ ├── DefaultConstructorSetLiveness.loci │ │ ├── DefaultExplicitCopySetLiveness.loci │ │ ├── DefaultImplicitCopySetLiveness.loci │ │ ├── GapByteLiveness.loci │ │ ├── InvalidMemberLiveness.loci │ │ ├── NonRecursiveSetDead.loci │ │ ├── RefMemberLiveness.loci │ │ └── SuffixByteLiveness.loci │ ├── Loop │ │ ├── ForBreak.loci │ │ ├── ForContinue.loci │ │ ├── ForLoop.loci │ │ ├── WhileBreak.loci │ │ ├── WhileContinue.loci │ │ └── WhileLoop.loci │ ├── Modules │ │ ├── ExportNamed.loci │ │ └── ImportNamed.loci │ ├── Move │ │ ├── Assign.loci │ │ ├── CountingMoveTo.loci │ │ ├── CustomMoveTo.loci │ │ ├── DefaultMoveTo.loci │ │ ├── MoveSetDestDead.loci │ │ ├── PtrLvalAssign.loci │ │ └── PtrLvalMove.loci │ ├── PolymorphicCast │ │ ├── PolyCastClassToInterface.loci │ │ ├── PolyCastTemplateVarToInterface.loci │ │ └── PolyCastTemplatedClassToInterface.loci │ ├── Primitives │ │ ├── Byte.loci │ │ ├── CallFunctionPointer.loci │ │ ├── Double.loci │ │ ├── Float.loci │ │ ├── Int.loci │ │ ├── Long.loci │ │ ├── LongLong.loci │ │ ├── NullFunctionPointer.loci │ │ ├── Range.loci │ │ ├── RangeBounds.loci │ │ ├── RangeClassValue.loci │ │ ├── Short.loci │ │ ├── StaticArray.loci │ │ ├── StaticArrayCopy.loci │ │ ├── StaticArrayDestructor.loci │ │ ├── StaticArrayImplicitCopy.loci │ │ ├── StaticArrayMove.loci │ │ ├── StaticArrayTemplateElementType.loci │ │ ├── UByte.loci │ │ ├── UInt.loci │ │ ├── ULong.loci │ │ ├── ULongLong.loci │ │ └── UShort.loci │ ├── Ref │ │ └── InterfaceRefInTemplate.loci │ ├── ScopeExit │ │ ├── NestedScopeExit.loci │ │ ├── ScopeException.loci │ │ ├── ScopeExit.loci │ │ ├── ScopeExitDuringBreak.loci │ │ ├── ScopeExitInternalLoop.loci │ │ ├── ScopeExitInternalLoopBreak.loci │ │ ├── ScopeExitInternalLoopContinue.loci │ │ ├── ScopeSuccessThrow.loci │ │ └── ScopeSuccessThrowFunction.loci │ ├── SizeOf │ │ ├── ClassGapByteAlignOf.loci │ │ ├── ClassGapByteSizeOf.loci │ │ ├── ClassSuffixByteAlignOf.loci │ │ ├── ClassSuffixByteSizeOf.loci │ │ ├── EmptyClassAlignOf.loci │ │ ├── EmptyClassSizeOf.loci │ │ ├── EmptyClassSuffixByteAlignOf.loci │ │ ├── EmptyClassSuffixByteSizeOf.loci │ │ ├── EmptyDatatypeAlignOf.loci │ │ ├── EmptyDatatypeSizeOf.loci │ │ ├── EmptyStructAlignOf.loci │ │ ├── EmptyStructSizeOf.loci │ │ ├── EmptyUnionAlignOf.loci │ │ ├── EmptyUnionDatatypeAlignOf.loci │ │ ├── EmptyUnionDatatypeSizeOf.loci │ │ ├── EmptyUnionSizeOf.loci │ │ ├── PrimitiveAlignOf.loci │ │ ├── PrimitiveSizeOf.loci │ │ ├── StructAlignOf.loci │ │ ├── StructSizeOf.loci │ │ ├── TemplatedTypeAlignOf.loci │ │ ├── TemplatedTypeSizeOf.loci │ │ ├── UnionAlignOf.loci │ │ └── UnionSizeOf.loci │ ├── Switch │ │ ├── DatatypeSwitch.loci │ │ └── SwitchDefaultCase.loci │ ├── Templates │ │ ├── BasicClassAndMethodTemplate.loci │ │ ├── BasicClassTemplate.loci │ │ ├── BasicFunctionTemplate.loci │ │ ├── BasicMethodTemplate.loci │ │ ├── ClassAndMethodTemplateSpecType.loci │ │ ├── ClassTemplateMethodRequire.loci │ │ ├── ExtensionMethodClassTemplate.loci │ │ ├── ExtensionMethodTemplate.loci │ │ ├── FunctionTemplateSpecType.loci │ │ ├── MemberTemplate.loci │ │ ├── MethodTemplateSpecType.loci │ │ ├── MultipleTemplate.loci │ │ ├── RecursiveTemplate.loci │ │ ├── TemplateCallConstructor.loci │ │ ├── TemplateCallStaticMethod.loci │ │ ├── TemplateInterfaceArgs.loci │ │ ├── TemplateRotateArgs.loci │ │ └── TemplatedSpecType.loci │ ├── Typename │ │ ├── BasicTypename.loci │ │ ├── CastTypename.loci │ │ ├── PassTypename.loci │ │ └── TransitiveCastTypename.loci │ └── ValueTemplates │ │ ├── IntAliasTemplate.loci │ │ ├── IntClassAndMethodTemplate.loci │ │ ├── IntClassTemplate.loci │ │ ├── IntExtensionMethodTemplate.loci │ │ ├── IntFunctionTemplate.loci │ │ ├── IntFunctionTemplateRotateArgs.loci │ │ ├── IntRecursiveFunctionTemplate.loci │ │ ├── IntSelfRecursiveFunctionTemplate.loci │ │ └── IntSelfRecursiveFunctionTemplateRotateArgs.loci ├── CodeGen │ ├── Assert │ │ └── Assert.loci │ ├── CABI │ │ ├── x86_32-arguments-darwin.loci │ │ └── x86_64-arguments.loci │ ├── DefaultMethods │ │ ├── ClassDefaultCompareMethod.loci │ │ ├── ClassDefaultCopyMethod.loci │ │ ├── ClassDefaultImplicitCopyMethod.loci │ │ └── ClassDefaultMoveMethod.loci │ ├── Destructor │ │ └── Destructor.loci │ ├── Linkage │ │ ├── ClassLinkage.loci │ │ └── FunctionLinkage.loci │ ├── MethodValue │ │ └── TemplatedMethodValue.loci │ ├── PolymorphicCasts │ │ ├── CastClassToIdenticalInterface.loci │ │ ├── CastClassToInterfaceUnderscoresVersusCamelCase.loci │ │ ├── CastClassToInterfaceWithFewerMethods.loci │ │ ├── CastInterfaceToIdenticalInterface.loci │ │ ├── CastInterfaceToInterfaceWithFewerMethods.loci │ │ └── CastPrimitiveIntToInterface.loci │ ├── PrimitiveFunctions │ │ ├── Max.loci │ │ ├── MaxInt.loci │ │ ├── Min.loci │ │ └── MinInt.loci │ ├── StaticArray │ │ ├── StaticArrayLiteral.loci │ │ └── StaticArrayLiteralUnknownElementSize.loci │ ├── TemplateGenerators │ │ ├── FunctionRootTemplateGenerator.loci │ │ ├── TemplatedClassIndirectSelfTemplate.loci │ │ ├── TemplatedClassSelfRecursive.loci │ │ ├── TemplatedFunctionCallOneFunctionSameTemplateArgs.loci │ │ ├── TemplatedFunctionCallOneFunctionSameTemplateArgsMutuallyRecursive.loci │ │ ├── TemplatedFunctionCallTwoFunctionsSameTemplateArgs.loci │ │ ├── TemplatedFunctionSelfRecursive.loci │ │ └── TemplatedMethodSelfRecursive.loci │ ├── Ternary │ │ ├── DestroyTernaryTemporary.loci │ │ └── VoidTernaryValue.loci │ └── VirtualCall │ │ ├── InterfaceMethodCall.loci │ │ ├── VTableOneMethod.loci │ │ └── VTableTwoMethodConflict.loci ├── Parser │ ├── Class │ │ ├── MethodDeclInClassDef.loci │ │ ├── MethodDefInClassDecl.loci │ │ ├── UnterminatedClassDeclMethodList.loci │ │ ├── UnterminatedClassDefMemberList.loci │ │ └── UnterminatedClassDefMethodList.loci │ ├── Conditional │ │ └── MultipleElse.loci │ ├── Enum │ │ └── UnterminatedEnumConstructorList.loci │ ├── Namespace │ │ └── RCurlyBracketTerminatingGlobalNamespace.loci │ ├── Scope │ │ └── UnterminatedScope.loci │ ├── Statement │ │ ├── PointerTypeVariableInitialiseSyntax.loci │ │ └── ReferenceTypeVariableInitialiseSyntax.loci │ ├── Struct │ │ └── UnterminatedStructMemberList.loci │ ├── Type │ │ ├── BitwiseShiftInTemplateSyntax.loci │ │ ├── DoubleRightTriangleBracketSyntax.loci │ │ ├── NestedTemplateArgumentsSyntax.loci │ │ └── TriangleBracketInTemplateSyntax.loci │ ├── Value │ │ ├── ArithmeticOperatorCombinations.loci │ │ ├── BooleanOperatorCombinations.loci │ │ ├── BracketedComparisonInFunctionArgument.loci │ │ ├── BracketedLvalues.loci │ │ ├── BuiltInTypeRefValueSyntax.loci │ │ ├── CompareTemplatedAlias.loci │ │ ├── ComparisonInFunctionArgument.loci │ │ ├── TemplateConstructInFunctionArgument.loci │ │ └── TypeRefValueSyntax.loci │ └── Var │ │ ├── InheritOnExceptionVariable.loci │ │ ├── InheritOnLocalVariable.loci │ │ ├── InheritOnParameterVariable.loci │ │ └── InheritOnStructVariable.loci ├── Primitives │ ├── Castable.loci │ ├── Comparable.loci │ ├── Copyable.loci │ ├── Decrementable.loci │ ├── Destructible.loci │ ├── ImplicitCastable.loci │ ├── ImplicitCopyable.loci │ ├── Incrementable.loci │ ├── Movable.loci │ ├── NoexceptComparable.loci │ ├── NoexceptCopyable.loci │ ├── NoexceptImplicitCopyable.loci │ └── StaticArrayShortSyntax.loci ├── SemanticAnalysis │ ├── Alias │ │ ├── AliasCircularDependency.loci │ │ ├── AliasStaticMethodAccess.loci │ │ ├── AliasTemplatedStaticMethodAccess.loci │ │ ├── AliasUsePredicateAsType.loci │ │ ├── PredicateAliasIndirectRequirement.loci │ │ ├── PredicateBasicAlias.loci │ │ ├── PredicateCapabilityAlias.loci │ │ ├── PredicateExpressionAlias.loci │ │ ├── PredicateExpressionRecursiveAlias.loci │ │ ├── PredicateLogicalOperatorAlias.loci │ │ ├── PredicateRecursiveAlias.loci │ │ ├── PredicateRecursiveTemplatedAlias.loci │ │ ├── PredicateTemplatedAlias.loci │ │ ├── TypeAliasReturnType.loci │ │ ├── TypeBasicAlias.loci │ │ ├── TypeRecursiveAlias.loci │ │ ├── TypeRecursiveTemplatedAlias.loci │ │ ├── TypeTemplatedAlias.loci │ │ ├── TypeTemplatedAliasSpecType.loci │ │ ├── ValueBasicAlias.loci │ │ └── ValueRecursiveAlias.loci │ ├── Assert │ │ ├── StaticAssertComparisonInvalid.loci │ │ ├── StaticAssertComparisonValid.loci │ │ ├── StaticAssertSatisfies.loci │ │ ├── StaticAssertTrivialBool.loci │ │ └── StaticAssertTrivialTrue.loci │ ├── Call │ │ ├── CallIncorrectArgCount.loci │ │ ├── CallVarArgInvalidType.loci │ │ └── CallVarArgTooFewArgs.loci │ ├── CapabilityTest │ │ ├── ContravariantInterfaceParameter.loci │ │ ├── CovariantInterfaceResult.loci │ │ ├── InferTemplateVarMethodSetIncorrectParamCount.loci │ │ ├── InferTemplateVarMethodSetIncorrectParamType.loci │ │ ├── InferTemplateVarMethodSetIncorrectReturnType.loci │ │ └── InferTemplateVarMethodSetMissingMethod.loci │ ├── Cast │ │ ├── FloatImplicitCast.loci │ │ ├── FloatLiteralBindRef.loci │ │ ├── FloatLiteralImplicitCast.loci │ │ ├── IntImplicitCast.loci │ │ ├── IntLiteralBindRef.loci │ │ ├── IntLiteralImplicitCast.loci │ │ ├── ReinterpretCastNonPointerType.loci │ │ ├── UnsignedIntImplicitCast.loci │ │ ├── UnsignedIntLiteralBindRef.loci │ │ └── UnsignedIntLiteralImplicitCast.loci │ ├── Class │ │ ├── DuplicateCanonicalMethod.loci │ │ ├── DuplicateMethod.loci │ │ ├── GetStaticMethodOfObject.loci │ │ ├── InternalConstructInNonMethod.loci │ │ ├── InternalConstructInNonStaticMethod.loci │ │ ├── InternalConstructInStaticMethod.loci │ │ ├── InternalConstructInvalidArgCount.loci │ │ ├── InternalConstructInvalidTemplateArgCount.loci │ │ ├── MemberVarInStaticMethod.loci │ │ ├── MultipleDestructors.loci │ │ ├── NonStaticMethodInvalidTemplateArgCount.loci │ │ ├── OverloadedMethod.loci │ │ ├── SelfInNonMethodFunction.loci │ │ ├── SelfInStaticMethod.loci │ │ ├── StaticMethodInvalidTemplateArgCount.loci │ │ ├── StaticMethodStaticRefInvalidTemplateArgCount.loci │ │ ├── StaticNonMethodFunction.loci │ │ ├── ThisInNonMethodFunction.loci │ │ └── ThisInStaticMethod.loci │ ├── Const │ │ ├── ConstClassMember.loci │ │ ├── ConstDatatypeIsCopyable.loci │ │ ├── ConstFunction.loci │ │ ├── ConstIntIsCopyable.loci │ │ ├── ConstPointerIsCopyable.loci │ │ ├── ConstStaticMethod.loci │ │ ├── ConstTemplatedDatatypeIsCopyable.loci │ │ ├── ConstValueLvalIsCopyable.loci │ │ ├── ModifyInsideConstMethod.loci │ │ ├── ModifyInsideOverrideConstMethod.loci │ │ ├── RefMemberConstMethod.loci │ │ ├── SelfConstConstObject.loci │ │ ├── SelfConstDynamicDispatch.loci │ │ ├── SelfConstInvalidContext.loci │ │ ├── SelfConstNonConstObject.loci │ │ ├── SelfConstObjectType.loci │ │ └── SelfConstTemplate.loci │ ├── Constants │ │ ├── DontTreatUnsignedConstantAsSigned.loci │ │ ├── EmptyArrayLiteral.loci │ │ ├── IntegerLiteralExceedsSpecifierMaximum.loci │ │ ├── IntegerLiteralTooLargeForFixedWidthType.loci │ │ ├── InvalidCharacterLiteralSpecifier.loci │ │ ├── InvalidFloatingPointLiteralSpecifier.loci │ │ ├── InvalidIntegerLiteralSpecifier.loci │ │ ├── InvalidStringLiteralSpecifier.loci │ │ ├── NonMatchingTypesInArrayLiteral.loci │ │ ├── TreatSignedConstantAsUnsigned.loci │ │ ├── TreatSignedConstantAsUnsignedBindRefCast.loci │ │ └── UnicharLiteral.loci │ ├── DeadCode │ │ ├── DeadCodeAfterBreak.loci │ │ ├── DeadCodeAfterContinue.loci │ │ ├── DeadCodeAfterIf.loci │ │ ├── DeadCodeAfterReturn.loci │ │ ├── DeadCodeAfterThrow.loci │ │ ├── DeadCodeAfterUnreachable.loci │ │ ├── EarlyThenReturn.loci │ │ ├── ScopeSuccessAlwaysThrowDeadCode.loci │ │ ├── ScopeSuccessBlockEarlierScopeSuccess.loci │ │ ├── UnreachableScopeExit.loci │ │ ├── UnreachableScopeFailure.loci │ │ ├── UnreachableScopeSuccess.loci │ │ └── WhileTrueDeadCode.loci │ ├── Defaults │ │ ├── DefaultMethodMustBeNonStatic.loci │ │ ├── DefaultMethodMustBeStatic.loci │ │ ├── RequestDefaultCompareWithNonComparableMembers.loci │ │ ├── RequestDefaultExplicitCopyWithNonCopyableMembers.loci │ │ └── RequestDefaultImplicitCopyWithNonCopyableMembers.loci │ ├── Exceptions │ │ ├── AssertNoExcept.loci │ │ ├── AssertNoExceptAroundNoExcept.loci │ │ ├── CircularInheritedException.loci │ │ ├── ExceptionParentTypeInvalidArgCount.loci │ │ ├── ExceptionParentTypeInvalidArgType.loci │ │ ├── ExceptionParentTypeNotException.loci │ │ ├── NoExceptPredicate.loci │ │ ├── NoExceptPredicateImplication.loci │ │ ├── NoExceptPredicateMultipleMethods.loci │ │ ├── RethrowInsideAssertNoExceptInsideScopeExit.loci │ │ ├── RethrowInsideScopeExit.loci │ │ ├── RethrowInsideScopeFailure.loci │ │ ├── RethrowInsideScopeSuccess.loci │ │ ├── RethrowInsideTry.loci │ │ ├── RethrowOutsideCatch.loci │ │ ├── SelfInheritedException.loci │ │ ├── ThrowInDestructor.loci │ │ ├── ThrowInNoExcept.loci │ │ ├── ThrowInNoExceptIndirectly.loci │ │ ├── ThrowInNoExceptViaOperator.loci │ │ ├── ThrowInsideAssertNoExceptInsideScopeExit.loci │ │ ├── ThrowInsideScopeExit.loci │ │ ├── ThrowInsideScopeFailure.loci │ │ ├── ThrowInsideScopeSuccess.loci │ │ ├── ThrowNonExceptionValue.loci │ │ ├── TryCatchNonExceptionType.loci │ │ ├── TryCatchPatternMatch.loci │ │ └── TryWrapsNonThrowingBlock.loci │ ├── ExtensionMethods │ │ ├── ParentOfExtensionMethodIsNotAType.loci │ │ └── UnknownParentTypeOfExtensionMethod.loci │ ├── Inherit │ │ ├── InheritOneMethod.loci │ │ ├── InheritTwoMethodsTwoClasses.loci │ │ └── OverrideOneMethod.loci │ ├── Interface │ │ └── InterfaceNameReference.loci │ ├── LifetimeMethods │ │ ├── InvalidArgumentCountAlignMask.loci │ │ ├── InvalidArgumentCountDestroy.loci │ │ ├── InvalidArgumentCountIsLive.loci │ │ ├── InvalidArgumentCountIsValid.loci │ │ ├── InvalidArgumentCountMove.loci │ │ ├── InvalidArgumentCountSetDead.loci │ │ ├── InvalidArgumentCountSetInvalid.loci │ │ ├── InvalidArgumentCountSizeOf.loci │ │ ├── InvalidConstnessDestroy.loci │ │ ├── InvalidConstnessIsLive.loci │ │ ├── InvalidConstnessIsValid.loci │ │ ├── InvalidConstnessMove.loci │ │ ├── InvalidConstnessSetDead.loci │ │ ├── InvalidConstnessSetInvalid.loci │ │ ├── InvalidDefaultLifetimeMethodName.loci │ │ ├── InvalidLifetimeMethodName.loci │ │ ├── InvalidReturnTypeAlignMask.loci │ │ ├── InvalidReturnTypeDestroy.loci │ │ ├── InvalidReturnTypeIsLive.loci │ │ ├── InvalidReturnTypeIsValid.loci │ │ ├── InvalidReturnTypeMove.loci │ │ ├── InvalidReturnTypeSetDead.loci │ │ ├── InvalidReturnTypeSetInvalid.loci │ │ ├── InvalidReturnTypeSizeOf.loci │ │ ├── InvalidStaticnessAlignMask.loci │ │ ├── InvalidStaticnessDestroy.loci │ │ ├── InvalidStaticnessIsLive.loci │ │ ├── InvalidStaticnessIsValid.loci │ │ ├── InvalidStaticnessMove.loci │ │ ├── InvalidStaticnessSetDead.loci │ │ ├── InvalidStaticnessSetInvalid.loci │ │ ├── InvalidStaticnessSizeOf.loci │ │ ├── ThrowingAlignMask.loci │ │ ├── ThrowingIsLive.loci │ │ ├── ThrowingIsValid.loci │ │ ├── ThrowingMove.loci │ │ ├── ThrowingSetDead.loci │ │ ├── ThrowingSetInvalid.loci │ │ └── ThrowingSizeOf.loci │ ├── Loop │ │ ├── BreakInScopeExitAction.loci │ │ ├── BreakOutOfFunction.loci │ │ ├── ContinueInScopeExitAction.loci │ │ └── ContinueOutOfFunction.loci │ ├── Module │ │ ├── ExportedClass.loci │ │ ├── ExportedFunction.loci │ │ ├── ExportedTemplateFunction.loci │ │ ├── ExportedTemplateFunctionWithRequire.loci │ │ ├── ImportedClass.loci │ │ ├── ImportedFunction.loci │ │ ├── ImportedOrExportedFunctionInModuleScope.loci │ │ ├── ImportedTemplateFunction.loci │ │ ├── ImportedTemplateFunctionWithRequire.loci │ │ ├── InternalClass.loci │ │ ├── InternalFunction.loci │ │ ├── NameExportedFunction.loci │ │ ├── NameExportedTemplateFunction.loci │ │ ├── NameExportedTemplateFunctionWithRequire.loci │ │ ├── NameImportedFunction.loci │ │ ├── NameImportedTemplateFunction.loci │ │ ├── NameImportedTemplateFunctionWithRequire.loci │ │ └── NestedModuleScope.loci │ ├── Names │ │ ├── DuplicateAlias.loci │ │ ├── DuplicateAliasTemplateVar.loci │ │ ├── DuplicateClass.loci │ │ ├── DuplicateEnumConstructor.loci │ │ ├── DuplicateExceptionMemberVar.loci │ │ ├── DuplicateFunction.loci │ │ ├── DuplicateLocalVar.loci │ │ ├── DuplicateParamVar.loci │ │ ├── ReferToNonStaticMethodDirectly.loci │ │ ├── ReferToSelfNonStaticMethodDirectly.loci │ │ ├── UnknownMemberVariable.loci │ │ ├── UnknownTypeName.loci │ │ └── UnknownValueName.loci │ ├── Namespace │ │ └── NamespaceTemplateArgs.loci │ ├── PatternMatch │ │ ├── PatternMatchIncorrectVarCount.loci │ │ ├── PatternMatchMemberVar.loci │ │ ├── PatternMatchNonDatatype.loci │ │ ├── PatternMatchParameter.loci │ │ └── PatternMatchSwitchAny.loci │ ├── PolymorphicCast │ │ ├── PolyCastClassToInterface.loci │ │ ├── PolyCastTemplateVarToInterface.loci │ │ └── PolyCastTemplatedClassToInterface.loci │ ├── Predicates │ │ ├── AliasNonBoolPredicateTypedTemplateVariable.loci │ │ ├── AliasPredicateTypedTemplateVariable.loci │ │ ├── FunctionNameInPredicate.loci │ │ ├── FunctionNonBoolPredicateTypedTemplateVariable.loci │ │ ├── FunctionPredicateTypedTemplateVariable.loci │ │ ├── NonBoolAliasInPredicate.loci │ │ ├── NonBoolTemplateVarInPredicate.loci │ │ ├── TransitiveRequireBoolVariable.loci │ │ ├── TypeInstanceNonBoolPredicateTypedTemplateVariable.loci │ │ ├── TypeInstancePredicateTypedTemplateVariable.loci │ │ └── UnknownNameInPredicate.loci │ ├── Return │ │ ├── MissingReturnStatement.loci │ │ ├── ReturnInScopeAction.loci │ │ ├── ReturnNonVoidInVoidFunction.loci │ │ ├── ReturnTypeIsUnsized.loci │ │ ├── ReturnVoidInNonVoidFunction.loci │ │ └── ReturnVoidValueInNonVoidFunction.loci │ ├── ScopeExit │ │ └── InvalidScopeExitState.loci │ ├── Shadowing │ │ ├── FunctionShadowFunction.loci │ │ ├── ParamVariableShadowFunction.loci │ │ ├── ParamVariableShadowType.loci │ │ ├── VariableShadowFunction.loci │ │ ├── VariableShadowType.loci │ │ └── VariableShadowVariable.loci │ ├── SizeOf │ │ ├── AlignMaskTemplateRequirement.loci │ │ ├── AlignOfMovableTemplateType.loci │ │ ├── AlignOfPrimitives.loci │ │ ├── SizeOfMovableTemplateType.loci │ │ ├── SizeOfPrimitives.loci │ │ └── SizeOfTemplateRequirement.loci │ ├── StaticArray │ │ ├── StaticArrayCopy.loci │ │ ├── StaticArrayImplicitCopy.loci │ │ ├── StaticArrayLiteralLvalueAndRvalue.loci │ │ └── StaticArrayShortSyntaxVersusIndexing.loci │ ├── Struct │ │ ├── OpaqueStructDerefPointer.loci │ │ ├── OpaqueStructFunctionReturnType.loci │ │ └── OpaqueStructPassPointer.loci │ ├── Switch │ │ ├── CannotPatternSwitchOnNonCopyableReference.loci │ │ ├── DuplicateSwitchCase.loci │ │ ├── SwitchInvalidCaseTypes.loci │ │ ├── SwitchTemplateType.loci │ │ ├── SwitchUnhandledCases.loci │ │ └── UnnecessaryDefaultCase.loci │ ├── TemplateArgumentDeduction │ │ └── SingleArgumentGlobalFunction.loci │ ├── Templates │ │ ├── ClassBoolTemplate.loci │ │ ├── ClassBoolTemplateConstPredicate.loci │ │ ├── ClassBoolTemplateRequirePredicate.loci │ │ ├── ClassBoolTemplateValue.loci │ │ ├── ClassDuplicateTemplate.loci │ │ ├── ClassTypenameTemplate.loci │ │ ├── ClassTypenameTemplateValue.loci │ │ ├── CyclicTemplateRequirement.loci │ │ ├── FunctionDuplicateTemplate.loci │ │ ├── FunctionTemplate.loci │ │ ├── FunctionTemplateNonPrimitiveType.loci │ │ ├── FunctionTemplateRequireAfter.loci │ │ ├── FunctionTemplateRequireBefore.loci │ │ ├── InterfaceMethodTemplate.loci │ │ ├── MethodDuplicateTemplate.loci │ │ └── TemplateVarInvalidType.loci │ ├── TypeOf │ │ ├── TypeOfDeclaredReferenceRvalue.loci │ │ ├── TypeOfInVariableType.loci │ │ ├── TypeOfLvalue.loci │ │ └── TypeOfRvalue.loci │ ├── Typename │ │ ├── InvalidTypenamePolyCast.loci │ │ ├── InvalidTypenameTargetTypeCast.loci │ │ └── InvalidTypenameTypeCast.loci │ ├── Types │ │ ├── ArrayAbstractElementType.loci │ │ ├── FunctionTypeVoidParameterType.loci │ │ └── VariableVoidType.loci │ ├── Unused │ │ ├── NonVoidNotExplicitlyIgnored.loci │ │ ├── UnusedLocalVariable.loci │ │ ├── UnusedParameter.loci │ │ ├── UnusedScopedLocalVariable.loci │ │ ├── UsedLocalVariableMarkedUnused.loci │ │ ├── UsedParameterMarkedUnused.loci │ │ ├── UsedScopedLocalVariableMarkedUnused.loci │ │ └── VoidExplicitlyIgnored.loci │ └── Variant │ │ ├── InvalidVariantCycle.loci │ │ ├── InvalidVariantRepeatedType.loci │ │ ├── TemplatedVariant.loci │ │ ├── VariantConditional.loci │ │ ├── VariantDatatypeShortSyntax.loci │ │ ├── VariantSharedMethod.loci │ │ ├── VariantSwitch.loci │ │ ├── VariantTernary.loci │ │ └── VariantTrivialDefinition.loci ├── StdLib │ ├── Concurrency │ │ ├── MessageQueue.loci │ │ └── Thread.loci │ ├── Container │ │ ├── CircularQueue.loci │ │ ├── Hash.loci │ │ ├── HugeVarray.loci │ │ ├── IndexVarray.loci │ │ ├── InterfaceReferenceVarray.loci │ │ ├── List.loci │ │ ├── Map.loci │ │ ├── Set.loci │ │ ├── VarrayCopy.loci │ │ └── VarrayDestroy.loci │ ├── Filesystem │ │ └── Path.loci │ ├── Memory │ │ ├── RawPtr.loci │ │ ├── SharedPtr.loci │ │ └── UniquePtr.loci │ └── String │ │ ├── StringBuilder.loci │ │ ├── StringConcat.loci │ │ ├── StringIterator.loci │ │ ├── StringJoin.loci │ │ ├── StringLength.loci │ │ └── StringSubstr.loci └── lit.cfg ├── tools ├── CMakeLists.txt ├── loci-vtable.cpp └── locic.cpp ├── unittests ├── CMakeLists.txt ├── Lex │ ├── CMakeLists.txt │ ├── CharacterLiteralLexTest.cpp │ ├── CommentLexTest.cpp │ ├── IdentifierLexTest.cpp │ ├── LexTest.hpp │ ├── MockCharacterSource.hpp │ ├── MockDiagnosticReceiver.hpp │ ├── NumericLexTest.cpp │ ├── StringLiteralLexTest.cpp │ ├── SymbolLexTest.cpp │ └── WhitespaceLexTest.cpp ├── Parser │ ├── CMakeLists.txt │ ├── MockTokenSource.hpp │ ├── NamespaceParseTest.cpp │ ├── StatementParseTest.cpp │ ├── TokenGenerator.hpp │ ├── TypeInstanceParseTest.cpp │ ├── TypeParseTest.cpp │ ├── ValueParseTest.cpp │ └── VarParseTest.cpp ├── Support │ ├── ArrayTest.cpp │ ├── CMakeLists.txt │ ├── OptionalTest.cpp │ └── StringTest.cpp └── TestMain.cpp └── utils ├── CMakeLists.txt ├── FileCheck ├── CMakeLists.txt ├── FileCheck.cpp └── README ├── artifact.py ├── googletest ├── CMakeLists.txt ├── LICENSE.TXT ├── include │ └── gtest │ │ ├── gtest-death-test.h │ │ ├── gtest-message.h │ │ ├── gtest-param-test.h │ │ ├── gtest-printers.h │ │ ├── gtest-spi.h │ │ ├── gtest-test-part.h │ │ ├── gtest-typed-test.h │ │ ├── gtest.h │ │ ├── gtest_pred_impl.h │ │ ├── gtest_prod.h │ │ └── internal │ │ ├── gtest-death-test-internal.h │ │ ├── gtest-filepath.h │ │ ├── gtest-internal.h │ │ ├── gtest-linked_ptr.h │ │ ├── gtest-param-util-generated.h │ │ ├── gtest-param-util.h │ │ ├── gtest-port.h │ │ ├── gtest-string.h │ │ ├── gtest-tuple.h │ │ └── gtest-type-util.h └── src │ ├── gtest-all.cc │ ├── gtest-death-test.cc │ ├── gtest-filepath.cc │ ├── gtest-internal-inl.h │ ├── gtest-port.cc │ ├── gtest-printers.cc │ ├── gtest-test-part.cc │ ├── gtest-typed-test.cc │ └── gtest.cc ├── upload_artifacts.py └── upload_docs.py /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "projects/llvm-abi"] 2 | path = projects/llvm-abi 3 | url = https://github.com/scrossuk/llvm-abi.git 4 | -------------------------------------------------------------------------------- /3rdparty/Qt/api/QApplication.loci: -------------------------------------------------------------------------------- 1 | 2 | import { 3 | 4 | class QApplication { 5 | static QApplication create(int& argc, ubyte** argv); 6 | 7 | int exec(); 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /3rdparty/Qt/api/QMessageBox.loci: -------------------------------------------------------------------------------- 1 | 2 | import { 3 | 4 | class QMessageBox { 5 | static QMessageBox create(); 6 | 7 | void show(); 8 | 9 | void setText(const QString& text) noexcept; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /3rdparty/Qt/api/QString.loci: -------------------------------------------------------------------------------- 1 | 2 | QString string_literal_Q(const ubyte* stringConstant) { 3 | return QString.createCString(stringConstant); 4 | } 5 | 6 | import { 7 | 8 | class QString { 9 | static QString createCString(const ubyte* cstring); 10 | 11 | QString implicitCopy() const; 12 | 13 | QString copy() const; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /3rdparty/Qt/api/QTextEdit.loci: -------------------------------------------------------------------------------- 1 | 2 | import { 3 | 4 | class QTextEdit { 5 | static QTextEdit create(); 6 | 7 | void show(); 8 | 9 | void setText(const QString& text) noexcept; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /3rdparty/README: -------------------------------------------------------------------------------- 1 | This directory contains Loci bindings for various third party libraries. -------------------------------------------------------------------------------- /3rdparty/SFML/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | function(loci_get_sfml_api_files SFML_API_FILES) 3 | set(${SFML_API_FILES} 4 | api/CircleShape.loci 5 | api/Clock.loci 6 | api/Color.loci 7 | api/Event.loci 8 | api/Font.loci 9 | api/Mouse.loci 10 | api/Rect.loci 11 | api/RectangleShape.loci 12 | api/RenderWindow.loci 13 | api/Text.loci 14 | api/Vector.loci 15 | api/VideoMode.loci 16 | api/View.loci 17 | PARENT_SCOPE 18 | ) 19 | endfunction() 20 | -------------------------------------------------------------------------------- /3rdparty/SFML/api/Color.loci: -------------------------------------------------------------------------------- 1 | // CSFML Color. 2 | struct sfColor { 3 | uint8_t r; 4 | uint8_t g; 5 | uint8_t b; 6 | uint8_t a; 7 | }; 8 | 9 | namespace sf { 10 | 11 | datatype Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a); 12 | 13 | static Color Color::Black() { 14 | return Color(0u, 0u, 0u, 255u); 15 | } 16 | 17 | static Color Color::Green() { 18 | return Color(0u, 255u, 0u, 255u); 19 | } 20 | 21 | static Color Color::White() { 22 | return Color(255u, 255u, 255u, 255u); 23 | } 24 | 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /3rdparty/SFML/api/Rect.loci: -------------------------------------------------------------------------------- 1 | // CSFML Rect. 2 | 3 | struct sfFloatRect { 4 | float left; 5 | float top; 6 | float width; 7 | float height; 8 | }; 9 | 10 | namespace sf { 11 | 12 | datatype FloatRect(Vector2f topLeft, Vector2f size); 13 | 14 | sfFloatRect rectToRaw(FloatRect rect) { 15 | return sfFloatRect(rect.topLeft.x, rect.topLeft.y, rect.size.x, rect.size.y); 16 | } 17 | 18 | } 19 | 20 | 21 | -------------------------------------------------------------------------------- /3rdparty/SFML/api/VideoMode.loci: -------------------------------------------------------------------------------- 1 | // CSFML Video Mode. 2 | struct sfVideoMode { 3 | unsigned int width; ///< Video mode width, in pixels 4 | unsigned int height; ///< Video mode height, in pixels 5 | unsigned int bitsPerPixel; ///< Video mode pixel depth, in bits per pixels 6 | }; 7 | 8 | namespace sf { 9 | 10 | datatype VideoMode(unsigned int width, unsigned int height, unsigned int bitsPerPixel); 11 | 12 | } 13 | 14 | 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Loci Compiler Tools 2 | =================== 3 | 4 | Website: http://loci-lang.org 5 | 6 | This directory contains the compiler (and related tools) for the programming language Loci. 7 | 8 | See [docs/GettingStarted.rst](docs/GettingStarted.rst) for an explanation of how to build/run the compiler. 9 | -------------------------------------------------------------------------------- /cmake/ConcatFiles.cmake: -------------------------------------------------------------------------------- 1 | separate_arguments(INPUT_FILES) 2 | 3 | set(ConcatString "") 4 | 5 | foreach(file_source_name ${INPUT_FILES}) 6 | file(READ "${file_source_name}" FileContents) 7 | set(ConcatString "${ConcatString}${FileContents}") 8 | endforeach(file_source_name) 9 | 10 | file(WRITE "${OUTPUT_FILE}" "${ConcatString}") 11 | -------------------------------------------------------------------------------- /cmake/MakeCString.cmake: -------------------------------------------------------------------------------- 1 | execute_process( 2 | COMMAND xxd -i "${INPUT_FILE}" "${OUTPUT_FILE}" 3 | WORKING_DIRECTORY "${WORKING_DIR}" 4 | ) 5 | -------------------------------------------------------------------------------- /docs/CircularQueue.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/CircularQueue.odg -------------------------------------------------------------------------------- /docs/CircularQueue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/CircularQueue.png -------------------------------------------------------------------------------- /docs/LinkedList.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/LinkedList.odg -------------------------------------------------------------------------------- /docs/LinkedList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/LinkedList.png -------------------------------------------------------------------------------- /docs/LociCompilationModel.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/LociCompilationModel.odg -------------------------------------------------------------------------------- /docs/LociCompilationModel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/LociCompilationModel.png -------------------------------------------------------------------------------- /docs/Map.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/Map.odg -------------------------------------------------------------------------------- /docs/Map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/Map.png -------------------------------------------------------------------------------- /docs/Set.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/Set.odg -------------------------------------------------------------------------------- /docs/Set.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/Set.png -------------------------------------------------------------------------------- /docs/Varray.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/Varray.odg -------------------------------------------------------------------------------- /docs/Varray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/Varray.png -------------------------------------------------------------------------------- /docs/_themes/sphinx_rtd_theme/__init__.py: -------------------------------------------------------------------------------- 1 | """Sphinx ReadTheDocs theme. 2 | 3 | From https://github.com/ryan-roemer/sphinx-bootstrap-theme. 4 | 5 | """ 6 | import os 7 | 8 | VERSION = (0, 1, 5) 9 | 10 | __version__ = ".".join(str(v) for v in VERSION) 11 | __version_full__ = __version__ 12 | 13 | 14 | def get_html_theme_path(): 15 | """Return list of HTML theme paths.""" 16 | cur_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) 17 | return cur_dir 18 | -------------------------------------------------------------------------------- /docs/_themes/sphinx_rtd_theme/searchbox.html: -------------------------------------------------------------------------------- 1 | {%- if builder != 'singlehtml' %} 2 |
3 |
4 | 5 | 6 | 7 |
8 |
9 | {%- endif %} 10 | -------------------------------------------------------------------------------- /docs/_themes/sphinx_rtd_theme/static/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/_themes/sphinx_rtd_theme/static/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /docs/_themes/sphinx_rtd_theme/static/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/_themes/sphinx_rtd_theme/static/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /docs/_themes/sphinx_rtd_theme/static/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/_themes/sphinx_rtd_theme/static/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /docs/_themes/sphinx_rtd_theme/static/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/docs/_themes/sphinx_rtd_theme/static/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/_themes/sphinx_rtd_theme/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = basic 3 | stylesheet = css/theme.css 4 | 5 | [options] 6 | typekit_id = hiw1hhg 7 | analytics_id = 8 | sticky_navigation = False 9 | -------------------------------------------------------------------------------- /docs/proposals/VariadicTemplates.rst: -------------------------------------------------------------------------------- 1 | Proposal: Variadic Templates 2 | ============================ 3 | 4 | .. Note:: 5 | Feature awaiting further design consideration. 6 | 7 | (No syntax yet described.) 8 | -------------------------------------------------------------------------------- /docs/static/README: -------------------------------------------------------------------------------- 1 | (Currently empty...) 2 | -------------------------------------------------------------------------------- /examples/Calculator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | loci_example(Calculator loci-calc "" Calculator.loci) 3 | 4 | -------------------------------------------------------------------------------- /examples/ChainReversi/CR/Player.loci: -------------------------------------------------------------------------------- 1 | // Chain Reversi Player API. 2 | 3 | namespace CR { 4 | 5 | datatype OptionalPosition = Some(Position position) | None(); 6 | 7 | interface Player { 8 | OptionalPosition performMove(const Board& board); 9 | 10 | void gameOver(bool win); 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /examples/ChainReversi/CR/Position.loci: -------------------------------------------------------------------------------- 1 | // Position on board. 2 | 3 | namespace CR { 4 | 5 | datatype Position(size_t x, size_t y); 6 | 7 | bool Position::isEdge() const { 8 | return @x == 0u || @y == 0u || @x == 7u || @y == 7u; 9 | } 10 | 11 | bool Position::isDiagonal() const { 12 | return @x == @y || (@x + @y) == 7u; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /examples/ChainReversi/CR/Value.loci: -------------------------------------------------------------------------------- 1 | // Chain Reversi Board Cell Value. 2 | 3 | namespace CR { 4 | 5 | datatype Value = 6 | Empty() 7 | | Red() 8 | | Blue(); 9 | 10 | Value Value::opposite() const noexcept { 11 | switch (self) { 12 | case Red() { 13 | return Blue(); 14 | } 15 | case Blue() { 16 | return Red(); 17 | } 18 | case Empty() { 19 | return Empty(); 20 | } 21 | } 22 | } 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /examples/ChainReversi/Data/font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/examples/ChainReversi/Data/font.ttf -------------------------------------------------------------------------------- /examples/CommandLine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | loci_module(CommandLine_Module commandLine.bc "" 2 | CommandLine.loci 3 | ${STD_CONTAINER_API_FILES} 4 | ${STD_STRING_API_FILES} 5 | ) 6 | 7 | loci_link(CommandLine commandLine "" 8 | commandLine.bc 9 | ${STD_CONTAINER_BINARY_FILES} 10 | ${STD_STRING_BINARY_FILES} 11 | ${STD_MEMORY_BINARY_FILES} 12 | ) 13 | 14 | add_dependencies(CommandLine std.container std.memory std.string) 15 | 16 | -------------------------------------------------------------------------------- /examples/Events/main.loci: -------------------------------------------------------------------------------- 1 | // Printf has an 'int' return type, but since 2 | // it's ignored just use 'void'. 3 | import void printf(const ubyte* str, ...) noexcept; 4 | 5 | export int main(unused int argc, unused ubyte** argv) { 6 | runEventsExample(); 7 | runMessageQueueExample(); 8 | runThreadsExample(); 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /examples/GUI/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Qt4) 2 | 3 | if(NOT QT4_FOUND) 4 | message(WARNING "Failed to find Qt so can't build GUI example.") 5 | return() 6 | endif() 7 | 8 | loci_get_3rdparty_api_files(QT_API_FILES Qt) 9 | 10 | loci_module(GUI_Module gui.bc "" 11 | main.loci 12 | ${QT_API_FILES} 13 | ) 14 | 15 | loci_link(GUI gui "-lQtCore -lQtGui -lstdc++" 16 | gui.bc 17 | "${PROJECT_BINARY_DIR}/3rdparty/Qt/qt.bc" 18 | ) 19 | 20 | add_dependencies(GUI 21 | loci-qt-binding 22 | ) 23 | -------------------------------------------------------------------------------- /examples/GUI/main.loci: -------------------------------------------------------------------------------- 1 | 2 | import void printf(const ubyte* format, ...) noexcept; 3 | 4 | export int main(int argc, ubyte ** argv) { 5 | auto app = QApplication(argc, argv); 6 | 7 | auto messageBox = QMessageBox(); 8 | messageBox.setText(Q"Example message box"); 9 | messageBox.show(); 10 | 11 | auto textEdit = QTextEdit(); 12 | textEdit.setText(Q"Example text box"); 13 | textEdit.show(); 14 | 15 | return app.exec(); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /examples/Looper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | loci_example(Looper looper "" Looper.loci) 3 | 4 | -------------------------------------------------------------------------------- /examples/Network/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | loci_module(Network_Module network.bc "" 2 | main.loci 3 | TCP.loci 4 | ${STD_NETWORK_API_FILES} 5 | ${STD_CONTAINER_API_FILES} 6 | ${STD_EVENT_API_FILES} 7 | ${STD_STRING_API_FILES} 8 | ) 9 | 10 | loci_link(Network network "" 11 | network.bc 12 | ${STD_NETWORK_BINARY_FILES} 13 | ${STD_EVENT_BINARY_FILES} 14 | ${STD_STRING_BINARY_FILES} 15 | ${STD_CONTAINER_BINARY_FILES} 16 | ${STD_MEMORY_BINARY_FILES} 17 | ) 18 | 19 | add_dependencies(Network std.network std.event std.string std.container) 20 | 21 | -------------------------------------------------------------------------------- /examples/Network/main.loci: -------------------------------------------------------------------------------- 1 | // Printf has an 'int' return type, but since 2 | // it's ignored just use 'void'. 3 | import void printf(const ubyte* str, ...) noexcept; 4 | 5 | export int main(unused int argc, unused ubyte** argv) { 6 | runTCPExample(); 7 | return 0; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /examples/Simulations/Checkpoint/Particle.loci: -------------------------------------------------------------------------------- 1 | 2 | namespace Simulations { 3 | 4 | namespace Checkpoint { 5 | 6 | datatype Particle(Vector position, Vector velocity); 7 | 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /examples/Simulations/Checkpoint/Target.loci: -------------------------------------------------------------------------------- 1 | namespace Simulations { 2 | 3 | namespace Checkpoint { 4 | 5 | datatype Target(Vector position, Vector velocity, double radius); 6 | 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /examples/Simulations/Data/font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrossuk/locic/a24bb380e17f8af69e7389acf8ce354c91a2abf3/examples/Simulations/Data/font.ttf -------------------------------------------------------------------------------- /examples/Simulations/Flocking/Boid.loci: -------------------------------------------------------------------------------- 1 | 2 | namespace Simulations { 3 | 4 | namespace Flocking { 5 | 6 | datatype Boid(Vector position, Vector velocity); 7 | 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /examples/Simulations/Flocking/Field.loci: -------------------------------------------------------------------------------- 1 | namespace Simulations { 2 | 3 | namespace Flocking { 4 | 5 | datatype Field(double strength, Vector position); 6 | 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /examples/Simulations/Flocking/Obstacle.loci: -------------------------------------------------------------------------------- 1 | 2 | namespace Simulations { 3 | 4 | namespace Flocking { 5 | 6 | datatype Obstacle(double radius, Vector position); 7 | 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /examples/Simulations/Gravity/Particle.loci: -------------------------------------------------------------------------------- 1 | 2 | namespace Simulations { 3 | 4 | namespace Gravity { 5 | 6 | datatype Particle(Vector position, Vector velocity, double mass); 7 | 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /examples/Simulations/Random.loci: -------------------------------------------------------------------------------- 1 | 2 | import int rand() noexcept; 3 | 4 | namespace Simulations { 5 | 6 | double RandomDouble(double low, double high) { 7 | assert low < high; 8 | const double randValue = (rand() % 1000).cast() / 1000.0f; 9 | return low + randValue * (high - low); 10 | } 11 | 12 | sf::Color RandomColor() { 13 | return sf::Color(RandomDouble(0.0, 255.0).cast(), RandomDouble(0.0, 255.0).cast(), RandomDouble(0.0, 255.0).cast(), 255u); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /examples/Simulations/Simulation.loci: -------------------------------------------------------------------------------- 1 | // Simulation abstraction. 2 | 3 | namespace Simulations { 4 | 5 | interface Simulation { 6 | std::string getName() const; 7 | 8 | bool handleEvent(const sf::Event& event); 9 | 10 | void update(sf::RenderWindow& renderWindow); 11 | 12 | void render(sf::RenderWindow& renderWindow); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /examples/SplitModule/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | loci_module(ModuleA A.bc "" A.loci) 3 | loci_module(ModuleB B.bc "" B.loci) 4 | loci_link(SplitModule splitModule "" A.bc B.bc) 5 | 6 | -------------------------------------------------------------------------------- /include/locic/AST/StringList.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_AST_STRINGLIST_HPP 2 | #define LOCIC_AST_STRINGLIST_HPP 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace locic { 9 | 10 | namespace AST { 11 | 12 | typedef std::vector StringList; 13 | 14 | } 15 | 16 | } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /include/locic/AST/TemplateVarArray.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_AST_TEMPLATEVARARRAY_HPP 2 | #define LOCIC_AST_TEMPLATEVARARRAY_HPP 3 | 4 | #include 5 | 6 | namespace locic { 7 | 8 | namespace AST { 9 | 10 | class TemplateVar; 11 | 12 | constexpr size_t TemplateVarArrayBaseSize = 8; 13 | using TemplateVarArray = Array; 14 | 15 | } 16 | 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/locic/AST/TypeArray.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_AST_TYPEARRAY_HPP 2 | #define LOCIC_AST_TYPEARRAY_HPP 3 | 4 | #include 5 | 6 | namespace locic { 7 | 8 | namespace AST { 9 | 10 | class Type; 11 | 12 | constexpr size_t TypeArrayBaseSize = 8; 13 | using TypeArray = Array; 14 | 15 | } 16 | 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/locic/AST/ValueArray.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_AST_VALUEARRAY_HPP 2 | #define LOCIC_AST_VALUEARRAY_HPP 3 | 4 | #include 5 | 6 | namespace locic { 7 | 8 | namespace AST { 9 | 10 | class Value; 11 | 12 | constexpr size_t ValueArrayBaseSize = 8; 13 | using ValueArray = Array; 14 | 15 | } 16 | 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/locic/AST/ValueDeclList.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_AST_VALUEDECLLIST_HPP 2 | #define LOCIC_AST_VALUEDECLLIST_HPP 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace locic { 9 | 10 | namespace AST { 11 | 12 | struct ValueDecl; 13 | 14 | typedef std::vector> ValueDeclList; 15 | 16 | } 17 | 18 | } 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /include/locic/CodeGen/BuildOptions.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_CODEGEN_BUILDOPTIONS_HPP 2 | #define LOCIC_CODEGEN_BUILDOPTIONS_HPP 3 | 4 | namespace locic{ 5 | 6 | namespace CodeGen { 7 | 8 | class BuildOptions { 9 | public: 10 | bool unsafe; 11 | bool zeroAllAllocas; 12 | 13 | BuildOptions() 14 | : unsafe(false), 15 | zeroAllAllocas(false) { } 16 | }; 17 | 18 | } 19 | 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/locic/CodeGen/GenABIType.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_CODEGEN_GENABITYPE_HPP 2 | #define LOCIC_CODEGEN_GENABITYPE_HPP 3 | 4 | #include 5 | #include 6 | 7 | 8 | 9 | #include 10 | 11 | namespace locic { 12 | 13 | namespace CodeGen { 14 | 15 | llvm_abi::Type genABIArgType(Module& module, const AST::Type* type); 16 | 17 | llvm_abi::Type genABIType(Module& module, const AST::Type* type); 18 | 19 | } 20 | 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /include/locic/CodeGen/GenDebugType.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_CODEGEN_GENDEBUGTYPE_HPP 2 | #define LOCIC_CODEGEN_GENDEBUGTYPE_HPP 3 | 4 | namespace locic { 5 | 6 | namespace AST { 7 | 8 | class FunctionType; 9 | class Type; 10 | 11 | } 12 | 13 | namespace CodeGen { 14 | 15 | class Module; 16 | 17 | DISubroutineType genDebugFunctionType(Module& module, AST::FunctionType type); 18 | 19 | DIType genDebugType(Module& module, const AST::Type* type); 20 | 21 | } 22 | 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /include/locic/CodeGen/GenVTable.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_CODEGEN_GENVTABLE_HPP 2 | #define LOCIC_CODEGEN_GENVTABLE_HPP 3 | 4 | 5 | #include 6 | 7 | namespace locic { 8 | 9 | namespace CodeGen { 10 | 11 | llvm::Value* genVTable(Module& module, const AST::TypeInstance* typeInstance); 12 | 13 | } 14 | 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /include/locic/CodeGen/LLVMIncludes.hpp: -------------------------------------------------------------------------------- 1 | // For compatibility; there used to be a header here 2 | // which is now a pre-compiled header. 3 | -------------------------------------------------------------------------------- /include/locic/CodeGen/ScopeEmitter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_CODEGEN_SCOPEEMITTER_HPP 2 | #define LOCIC_CODEGEN_SCOPEEMITTER_HPP 3 | 4 | namespace locic { 5 | 6 | namespace AST { 7 | 8 | class Scope; 9 | 10 | } 11 | 12 | namespace CodeGen { 13 | 14 | class IREmitter; 15 | 16 | class ScopeEmitter { 17 | public: 18 | ScopeEmitter(IREmitter& irEmitter); 19 | 20 | void emitScope(const AST::Scope& scope); 21 | 22 | private: 23 | IREmitter& irEmitter_; 24 | 25 | }; 26 | 27 | } 28 | 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /include/locic/CodeGen/TargetOptions.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_CODEGEN_TARGETOPTIONS_HPP 2 | #define LOCIC_CODEGEN_TARGETOPTIONS_HPP 3 | 4 | #include 5 | 6 | namespace locic { 7 | 8 | namespace CodeGen { 9 | 10 | struct TargetOptions { 11 | std::string triple; 12 | std::string arch; 13 | std::string cpu; 14 | std::string floatABI; 15 | std::string fpu; 16 | }; 17 | 18 | } 19 | 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/locic/CodeGen/UnwindState.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_CODEGEN_UNWINDSTATE_HPP 2 | #define LOCIC_CODEGEN_UNWINDSTATE_HPP 3 | 4 | namespace locic { 5 | 6 | namespace CodeGen { 7 | 8 | enum UnwindState { 9 | UnwindStateNormal = 0, 10 | UnwindStateReturn = 1, 11 | UnwindStateBreak = 2, 12 | UnwindStateContinue = 3, 13 | UnwindStateThrow = 4, 14 | UnwindStateRethrow = 5, 15 | UnwindState_MAX 16 | }; 17 | 18 | } 19 | 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/locic/Debug.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_DEBUG_HPP 2 | #define LOCIC_DEBUG_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /include/locic/Debug/CompilerInfo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_DEBUG_COMPILERINFO_HPP 2 | #define LOCIC_DEBUG_COMPILERINFO_HPP 3 | 4 | #include 5 | 6 | namespace locic { 7 | 8 | namespace Debug { 9 | 10 | struct CompilerInfo { 11 | std::string name; 12 | std::string flags; 13 | }; 14 | 15 | } 16 | 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/locic/Debug/Module.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_DEBUG_MODULE_HPP 2 | #define LOCIC_DEBUG_MODULE_HPP 3 | 4 | #include 5 | 6 | namespace locic { 7 | 8 | namespace Debug { 9 | 10 | class Module { 11 | public: 12 | CompilerInfo compiler; 13 | }; 14 | 15 | } 16 | 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/locic/Debug/StatementInfo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_DEBUG_STATEMENTINFO_HPP 2 | #define LOCIC_DEBUG_STATEMENTINFO_HPP 3 | 4 | #include 5 | 6 | namespace locic { 7 | 8 | namespace Debug { 9 | 10 | struct StatementInfo { 11 | SourceLocation location; 12 | 13 | inline StatementInfo() 14 | : location(SourceLocation::Null()) { } 15 | }; 16 | 17 | } 18 | 19 | } 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/locic/Debug/TypeInstanceInfo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_DEBUG_TYPEINSTANCEINFO_HPP 2 | #define LOCIC_DEBUG_TYPEINSTANCEINFO_HPP 3 | 4 | #include 5 | 6 | namespace locic { 7 | 8 | namespace Debug { 9 | 10 | struct TypeInstanceInfo { 11 | SourceLocation location; 12 | 13 | TypeInstanceInfo() 14 | : location(SourceLocation::Null()) { } 15 | 16 | TypeInstanceInfo(SourceLocation pLocation) 17 | : location(pLocation) { } 18 | }; 19 | 20 | } 21 | 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /include/locic/Debug/ValueInfo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_DEBUG_VALUEINFO_HPP 2 | #define LOCIC_DEBUG_VALUEINFO_HPP 3 | 4 | #include 5 | 6 | namespace locic { 7 | 8 | namespace Debug { 9 | 10 | class ValueInfo { 11 | public: 12 | SourceLocation location; 13 | 14 | ValueInfo() : location(SourceLocation::Null()) { } 15 | }; 16 | 17 | } 18 | 19 | } 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/locic/Exception.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_EXCEPTION_HPP 2 | #define LOCIC_EXCEPTION_HPP 3 | 4 | #include 5 | 6 | namespace locic{ 7 | 8 | class Exception { 9 | public: 10 | virtual std::string toString() const = 0; 11 | 12 | protected: 13 | Exception() = default; 14 | Exception(const Exception&) = default; 15 | Exception& operator=(const Exception&) = default; 16 | ~Exception() { } 17 | 18 | }; 19 | 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/locic/Lex/CharacterSource.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_LEX_CHARACTERSOURCE_HPP 2 | #define LOCIC_LEX_CHARACTERSOURCE_HPP 3 | 4 | namespace locic { 5 | 6 | class String; 7 | 8 | namespace Lex { 9 | 10 | class Character; 11 | 12 | class CharacterSource { 13 | protected: 14 | ~CharacterSource() { } 15 | 16 | public: 17 | virtual Character get() = 0; 18 | 19 | virtual size_t byteOffset() const = 0; 20 | 21 | virtual String fileName() const = 0; 22 | 23 | }; 24 | 25 | } 26 | 27 | } 28 | 29 | #endif -------------------------------------------------------------------------------- /include/locic/Lex/LexerAPI.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_LEX_LEXERAPI_HPP 2 | #define LOCIC_LEX_LEXERAPI_HPP 3 | 4 | namespace locic { 5 | 6 | class String; 7 | class StringHost; 8 | 9 | namespace Lex { 10 | 11 | class Token; 12 | 13 | class LexerAPI { 14 | protected: 15 | ~LexerAPI() { } 16 | 17 | public: 18 | virtual Token lexToken() = 0; 19 | 20 | virtual String fileName() const = 0; 21 | 22 | }; 23 | 24 | } 25 | 26 | } 27 | 28 | #endif -------------------------------------------------------------------------------- /include/locic/Parser/Token.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_PARSER_TOKEN_HPP 2 | #define LOCIC_PARSER_TOKEN_HPP 3 | 4 | #include 5 | 6 | namespace locic { 7 | 8 | namespace Parser { 9 | 10 | using Token = Lex::Token; 11 | 12 | } 13 | 14 | } 15 | 16 | #endif -------------------------------------------------------------------------------- /include/locic/SemanticAnalysis/ConvertFunctionDef.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_SEMANTICANALYSIS_CONVERTFUNCTIONDEF_HPP 2 | #define LOCIC_SEMANTICANALYSIS_CONVERTFUNCTIONDEF_HPP 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace locic { 9 | 10 | namespace SemanticAnalysis { 11 | 12 | void ConvertFunctionDef(Context& context, 13 | const AST::Node& astFunctionNode); 14 | 15 | } 16 | 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/locic/SemanticAnalysis/ConvertModuleScope.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_SEMANTICANALYSIS_CONVERTMODULESCOPE_HPP 2 | #define LOCIC_SEMANTICANALYSIS_CONVERTMODULESCOPE_HPP 3 | 4 | #include 5 | 6 | namespace locic { 7 | 8 | namespace SemanticAnalysis { 9 | 10 | AST::ModuleScope 11 | ConvertModuleScope(const AST::Node& astModuleScopeNode); 12 | 13 | } 14 | 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /include/locic/SemanticAnalysis/ConvertNamespace.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_SEMANTICANALYSIS_CONVERTNAMESPACE_HPP 2 | #define LOCIC_SEMANTICANALYSIS_CONVERTNAMESPACE_HPP 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace locic { 9 | 10 | namespace SemanticAnalysis { 11 | 12 | void ConvertNamespace(Context& context, const AST::NamespaceList& rootASTNamespaces); 13 | 14 | } 15 | 16 | } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /include/locic/SemanticAnalysis/ConvertScope.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_SEMANTICANALYSIS_CONVERTSCOPE_HPP 2 | #define LOCIC_SEMANTICANALYSIS_CONVERTSCOPE_HPP 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | namespace locic { 11 | 12 | namespace SemanticAnalysis { 13 | 14 | void ConvertScope(Context& context, AST::Node& astScopeNode); 15 | 16 | } 17 | 18 | } 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /include/locic/SemanticAnalysis/ConvertStatement.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_SEMANTICANALYSIS_CONVERTSTATEMENT_HPP 2 | #define LOCIC_SEMANTICANALYSIS_CONVERTSTATEMENT_HPP 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace locic { 9 | 10 | namespace SemanticAnalysis { 11 | 12 | AST::Statement ConvertStatement(Context& context, const AST::Node& statement); 13 | 14 | } 15 | 16 | } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /include/locic/SemanticAnalysis/ConvertTypeInstance.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_SEMANTICANALYSIS_CONVERTTYPEINSTANCE_HPP 2 | #define LOCIC_SEMANTICANALYSIS_CONVERTTYPEINSTANCE_HPP 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace locic { 9 | 10 | namespace SemanticAnalysis { 11 | 12 | void ConvertTypeInstance(Context& context, 13 | AST::Node& typeInstanceNode); 14 | 15 | } 16 | 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/locic/SemanticAnalysis/NameSearch.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_SEMANTICANALYSIS_NAMESEARCH_HPP 2 | #define LOCIC_SEMANTICANALYSIS_NAMESEARCH_HPP 3 | 4 | #include 5 | 6 | namespace locic { 7 | 8 | class Name; 9 | 10 | namespace SemanticAnalysis { 11 | 12 | class Context; 13 | class SearchResult; 14 | 15 | SearchResult performSearch(Context& context, const Name& name, size_t searchStartPosition = 0); 16 | 17 | } 18 | 19 | } 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/locic/SemanticAnalysis/VarArgCast.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_SEMANTICANALYSIS_VARARGCAST_HPP 2 | #define LOCIC_SEMANTICANALYSIS_VARARGCAST_HPP 3 | 4 | #include 5 | 6 | 7 | #include 8 | 9 | namespace locic { 10 | 11 | namespace SemanticAnalysis { 12 | 13 | bool isValidVarArgType(Context& context, const AST::Type* type); 14 | 15 | AST::Value VarArgCast(Context& context, AST::Value value, const Debug::SourceLocation& location); 16 | 17 | } 18 | 19 | } 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/locic/Support/Hasher.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_SUPPORT_HASHER_HPP 2 | #define LOCIC_SUPPORT_HASHER_HPP 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace locic{ 9 | 10 | class Hasher { 11 | public: 12 | Hasher(); 13 | 14 | void addValue(size_t value); 15 | 16 | template 17 | void add(const T& object) { 18 | addValue(hashObject(object)); 19 | } 20 | 21 | size_t get() const; 22 | 23 | private: 24 | size_t seed_; 25 | 26 | }; 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/locic/Support/HeapArray.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_SUPPORT_HEAPARRAY_HPP 2 | #define LOCIC_SUPPORT_HEAPARRAY_HPP 3 | 4 | #include 5 | 6 | namespace locic{ 7 | 8 | template 9 | using HeapArray = Array; 10 | 11 | } 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /include/locic/Support/Utils.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOCIC_SUPPORT_UTILS_HPP 2 | #define LOCIC_SUPPORT_UTILS_HPP 3 | 4 | namespace locic { 5 | 6 | inline bool checkImplies(const bool a, const bool b) { 7 | return !a || b; 8 | } 9 | 10 | inline bool isPowerOf2(const size_t value) { 11 | return value != 0 && (value & (value - 1)) == 0; 12 | } 13 | 14 | inline size_t roundUpToAlign(const size_t position, const size_t align) { 15 | assert(isPowerOf2(align)); 16 | return (position + (align - 1)) & (~(align - 1)); 17 | } 18 | 19 | } 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /lib/AST/TemplateVarMap.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace locic { 11 | 12 | namespace AST { 13 | 14 | std::string TemplateVarMap::toString() const { 15 | return makeMapString(*this); 16 | } 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LOCIC_BUILD_WARNINGS}") 2 | 3 | # Build abstract syntax tree structures. 4 | add_subdirectory(AST) 5 | 6 | # Build code generator. 7 | add_subdirectory(CodeGen) 8 | 9 | # Build frontend. 10 | add_subdirectory(Frontend) 11 | 12 | # Build lexer. 13 | add_subdirectory(Lex) 14 | 15 | # Build parser. 16 | add_subdirectory(Parser) 17 | 18 | # Build semantic analysis. 19 | add_subdirectory(SemanticAnalysis) 20 | 21 | # Build support library. 22 | add_subdirectory(Support) 23 | 24 | -------------------------------------------------------------------------------- /lib/Frontend/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_library(locic-frontend 3 | DiagnosticRenderer.cpp 4 | OptionalDiag.cpp 5 | ) 6 | 7 | -------------------------------------------------------------------------------- /lib/Lex/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(locic-lex 2 | CharacterReader.cpp 3 | FileCharacterSource.cpp 4 | IdentifierLexer.cpp 5 | Lexer.cpp 6 | StringLiteralLexer.cpp 7 | ) 8 | -------------------------------------------------------------------------------- /lib/Support/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_library(locic-support 3 | APInt.cpp 4 | ErrorHandling.cpp 5 | Hasher.cpp 6 | MethodID.cpp 7 | MethodIDMap.cpp 8 | Name.cpp 9 | PrimitiveID.cpp 10 | PrimitiveIDMap.cpp 11 | String.cpp 12 | StringHost.cpp 13 | Version.cpp 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /lib/Support/Hasher.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace locic{ 6 | 7 | Hasher::Hasher() 8 | : seed_(0) { } 9 | 10 | void Hasher::addValue(const size_t value) { 11 | seed_ ^= value + 0x9e3779b9 + (seed_ << 6) + (seed_ >> 2); 12 | } 13 | 14 | size_t Hasher::get() const { 15 | return seed_; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /runtime/assert.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern "C" void __loci_assert_failed(const char* name) { 5 | printf("Assertion failed: %s\n", name); 6 | abort(); 7 | } 8 | 9 | extern "C" void __loci_unreachable_failed() { 10 | printf("Unreachable failed!\n"); 11 | abort(); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /runtime/decrementable.loci: -------------------------------------------------------------------------------- 1 | interface decrementable_t { 2 | void decrement(); 3 | } 4 | 5 | template 6 | using decrementable = T : decrementable_t; 7 | 8 | interface noexcept_decrementable_t { 9 | void decrement() noexcept; 10 | } 11 | 12 | template 13 | using noexcept_decrementable = T : noexcept_decrementable_t; 14 | -------------------------------------------------------------------------------- /runtime/default_constructible.loci: -------------------------------------------------------------------------------- 1 | template 2 | interface default_constructible_t { 3 | static T create(); 4 | } 5 | 6 | template 7 | using default_constructible = sized_type and T : default_constructible_t; 8 | -------------------------------------------------------------------------------- /runtime/destructible.loci: -------------------------------------------------------------------------------- 1 | interface destructible_t { 2 | void __destroy() noexcept; 3 | } 4 | 5 | template 6 | using destructible = sized_type and T : destructible_t; 7 | -------------------------------------------------------------------------------- /runtime/dissolvable.loci: -------------------------------------------------------------------------------- 1 | template 2 | interface dissolvable_t { 3 | T& dissolve(); 4 | } 5 | 6 | template 7 | using dissolvable = T : dissolvable_t; 8 | 9 | template 10 | interface const_dissolvable_t { 11 | const T& dissolve() const; 12 | } 13 | 14 | template 15 | using const_dissolvable = T : const_dissolvable_t; 16 | -------------------------------------------------------------------------------- /runtime/incrementable.loci: -------------------------------------------------------------------------------- 1 | interface incrementable_t { 2 | void increment(); 3 | } 4 | 5 | template 6 | using incrementable = T : incrementable_t; 7 | 8 | interface noexcept_incrementable_t { 9 | void increment() noexcept; 10 | } 11 | 12 | template 13 | using noexcept_incrementable = T : noexcept_incrementable_t; 14 | -------------------------------------------------------------------------------- /runtime/minmax.loci: -------------------------------------------------------------------------------- 1 | template 2 | require(movable and lessthancomparable) 3 | __primitivefunction T min(T first, T second) noexcept(noexcept_lessthancomparable); 4 | 5 | template 6 | require(movable and lessthancomparable) 7 | __primitivefunction T max(T first, T second) noexcept(noexcept_lessthancomparable); 8 | -------------------------------------------------------------------------------- /runtime/movable.loci: -------------------------------------------------------------------------------- 1 | template 2 | interface movable_t { 3 | T __move() noexcept; 4 | } 5 | 6 | template 7 | using movable = sized_type and T : movable_t; 8 | -------------------------------------------------------------------------------- /runtime/ref_t.loci: -------------------------------------------------------------------------------- 1 | template 2 | __primitive ref_t { 3 | static size_t __alignmask() noexcept; 4 | static size_t __sizeof() noexcept; 5 | 6 | void __destroy() noexcept; 7 | 8 | ref_t implicit_copy() const noexcept; 9 | ref_t copy() const noexcept; 10 | 11 | void __setdead() noexcept; 12 | bool __islive() const noexcept; 13 | void __setinvalid() noexcept; 14 | bool __isvalid() const noexcept; 15 | 16 | ref_t __move() noexcept; 17 | 18 | selfconst(T)* address() const noexcept; 19 | } 20 | -------------------------------------------------------------------------------- /runtime/sized_type.loci: -------------------------------------------------------------------------------- 1 | interface sized_type_t { 2 | static size_t __alignmask() noexcept; 3 | static size_t __sizeof() noexcept; 4 | } 5 | 6 | template 7 | using sized_type = T : sized_type_t; 8 | -------------------------------------------------------------------------------- /runtime/ubyte_t.loci: -------------------------------------------------------------------------------- 1 | using ubyte_t = uint8_t; 2 | -------------------------------------------------------------------------------- /runtime/void_t.loci: -------------------------------------------------------------------------------- 1 | __primitive void_t { 2 | // FIXME: void_t should be an unsized type. 3 | static size_t __alignmask() noexcept; 4 | static size_t __sizeof() noexcept; 5 | 6 | void __destroy() noexcept; 7 | 8 | void_t __move() noexcept; 9 | } 10 | -------------------------------------------------------------------------------- /runtime/zero.loci: -------------------------------------------------------------------------------- 1 | template 2 | interface has_zero_t { 3 | static T zero(); 4 | } 5 | 6 | template 7 | using has_zero = T : has_zero_t; 8 | 9 | template 10 | interface has_noexcept_zero_t { 11 | static T zero() noexcept; 12 | } 13 | 14 | template 15 | using has_noexcept_zero = T : has_noexcept_zero_t; 16 | -------------------------------------------------------------------------------- /stdlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(LociModule) 2 | 3 | add_subdirectory(std) 4 | -------------------------------------------------------------------------------- /stdlib/std/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(concurrency) 2 | add_subdirectory(container) 3 | add_subdirectory(event) 4 | add_subdirectory(filesystem) 5 | add_subdirectory(memory) 6 | add_subdirectory(network) 7 | add_subdirectory(string) 8 | 9 | -------------------------------------------------------------------------------- /stdlib/std/concurrency/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | loci_module(std.concurrency std_concurrency.bc "" 2 | src/unix/condition_variable.loci 3 | src/unix/fiber.loci 4 | src/unix/message_queue.loci 5 | src/unix/mutex.loci 6 | src/unix/pthread_t.c 7 | src/unix/pthread_t.loci 8 | src/unix/pthread_cond_t.c 9 | src/unix/pthread_cond_t.loci 10 | src/unix/pthread_mutex_t.c 11 | src/unix/pthread_mutex_t.loci 12 | src/unix/thread.loci 13 | src/unix/thread_internal.loci 14 | ${STD_CONTAINER_API_FILES} 15 | ${STD_EVENT_API_FILES} 16 | ${STD_MEMORY_API_FILES} 17 | ) 18 | -------------------------------------------------------------------------------- /stdlib/std/concurrency/api/condition_variable.loci: -------------------------------------------------------------------------------- 1 | import std.concurrency 0.1.0 { 2 | 3 | namespace std { 4 | 5 | namespace concurrency { 6 | 7 | interface mutex_locker { 8 | mutex& internal_mutex() noexcept; 9 | } 10 | 11 | class condition_variable { 12 | static condition_variable create(); 13 | 14 | void notify_one() noexcept; 15 | 16 | void notify_all() noexcept; 17 | 18 | void wait(mutex_locker& locker); 19 | } 20 | 21 | } 22 | } 23 | 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /stdlib/std/concurrency/api/fiber.loci: -------------------------------------------------------------------------------- 1 | import std.concurrency 0.1.0 { 2 | 3 | namespace std { 4 | 5 | namespace concurrency { 6 | 7 | template 8 | require (T : runnable and movable) 9 | class fiber { 10 | static fiber create(T runnable_object); 11 | 12 | void cancel(); 13 | 14 | void join(); 15 | 16 | event::source event_source() const noexcept; 17 | } 18 | 19 | } 20 | } 21 | 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /stdlib/std/concurrency/api/mutex.loci: -------------------------------------------------------------------------------- 1 | import std.concurrency 0.1.0 { 2 | 3 | namespace std { 4 | 5 | namespace concurrency { 6 | 7 | class mutex { 8 | static mutex create(); 9 | 10 | void lock(); 11 | 12 | void unlock() noexcept; 13 | } 14 | 15 | class unique_lock { 16 | static unique_lock create(mutex& mutex_object); 17 | 18 | mutex& internal_mutex() noexcept; 19 | } 20 | 21 | } 22 | } 23 | 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /stdlib/std/concurrency/api/runnable.loci: -------------------------------------------------------------------------------- 1 | import std.concurrency 0.1.0 { 2 | 3 | namespace std { 4 | 5 | namespace concurrency { 6 | 7 | interface runnable { 8 | void run(); 9 | } 10 | 11 | } 12 | } 13 | 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /stdlib/std/concurrency/api/thread_local.loci: -------------------------------------------------------------------------------- 1 | import std.concurrency 0.1.0 { 2 | 3 | namespace std { 4 | 5 | namespace concurrency { 6 | 7 | template 8 | class thread_local { 9 | static thread_local create(); 10 | 11 | T* address() const; 12 | 13 | void assign(T value); 14 | 15 | T& dissolve() const; 16 | 17 | T move(); 18 | } 19 | 20 | } 21 | } 22 | 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /stdlib/std/concurrency/api/thread_specific_ptr.loci: -------------------------------------------------------------------------------- 1 | import std.concurrency 0.1.0 { 2 | 3 | namespace std { 4 | 5 | namespace concurrency { 6 | 7 | template 8 | class thread_specific_ptr { 9 | static thread_specific_ptr create(); 10 | 11 | void assign(T* ptr); 12 | 13 | T*& dissolve() const; 14 | 15 | T* move(); 16 | 17 | } 18 | 19 | } 20 | } 21 | 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /stdlib/std/container/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | loci_module(std.container std_container.bc "" 2 | src/circular_queue.loci 3 | src/hash.loci 4 | src/list.loci 5 | src/map.loci 6 | src/range.loci 7 | src/set.loci 8 | src/varray.loci 9 | ${STD_MEMORY_API_FILES} 10 | ) 11 | 12 | -------------------------------------------------------------------------------- /stdlib/std/event/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | loci_module(std.event std_event.bc "" 2 | src/unix/exception.loci 3 | src/unix/generator.loci 4 | src/unix/internal_generator.c 5 | src/unix/internal_wait.c 6 | src/unix/source.loci 7 | src/unix/wait_set.loci 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /stdlib/std/event/api/wait_set.loci: -------------------------------------------------------------------------------- 1 | import std.event 0.1.0 { 2 | 3 | namespace std { 4 | 5 | namespace event { 6 | 7 | class wait_set { 8 | static wait_set create(bool edgeTriggered); 9 | 10 | static wait_set edge_triggered(); 11 | 12 | static wait_set level_triggered(); 13 | 14 | void insert(source single_source); 15 | 16 | void wait(); 17 | 18 | bool poll(); 19 | 20 | source event_source() const noexcept; 21 | } 22 | 23 | } 24 | } 25 | 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /stdlib/std/event/src/unix/exception.loci: -------------------------------------------------------------------------------- 1 | export std.event 0.1.0 { 2 | 3 | namespace std { 4 | 5 | namespace event { 6 | 7 | exception generator_notify_failed(int error); 8 | exception generator_reset_failed(int error); 9 | exception pipe_failed(int error); 10 | exception wait_create_failed(int error); 11 | exception wait_insert_failed(int error); 12 | exception wait_failed(int error); 13 | 14 | } 15 | } 16 | 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /stdlib/std/filesystem/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | loci_module(std.filesystem std_filesystem.bc "" 2 | src/file_stream.loci 3 | src/internal_path.c 4 | src/path.loci 5 | ${STD_CONTAINER_API_FILES} 6 | ${STD_MEMORY_API_FILES} 7 | ${STD_STRING_API_FILES} 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /stdlib/std/filesystem/src/internal_path.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int std_filesystem_is_file(const char* path) { 6 | struct stat path_stat; 7 | if (stat(path, &path_stat) != 0) { 8 | return 0; 9 | } 10 | return S_ISREG(path_stat.st_mode); 11 | } 12 | 13 | int std_filesystem_is_directory(const char* path) { 14 | struct stat path_stat; 15 | if (stat(path, &path_stat) != 0) { 16 | return 0; 17 | } 18 | return S_ISDIR(path_stat.st_mode); 19 | } 20 | -------------------------------------------------------------------------------- /stdlib/std/future/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | loci_module(std.concurrency std_concurrency.bc "" 2 | src/unix/condition_variable.loci 3 | src/unix/fiber.loci 4 | src/unix/message_queue.loci 5 | src/unix/mutex.loci 6 | src/unix/thread.loci 7 | ${STD_CONTAINER_API_FILES} 8 | ${STD_EVENT_API_FILES} 9 | ${STD_MEMORY_API_FILES} 10 | ) 11 | 12 | -------------------------------------------------------------------------------- /stdlib/std/future/api/future.loci: -------------------------------------------------------------------------------- 1 | import std.future 0.1.0 { 2 | 3 | namespace std { 4 | 5 | template 6 | T future_get(future future); 7 | 8 | template 9 | class future { 10 | std::event_source event_source() const; 11 | } 12 | 13 | } 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /stdlib/std/future/api/promise.loci: -------------------------------------------------------------------------------- 1 | import std.future 0.1.0 { 2 | 3 | namespace std { 4 | 5 | template 6 | datatype promise_pair(future future, promise promise); 7 | 8 | template 9 | promise_pair make_promise(); 10 | 11 | template 12 | void complete_promise(promise promise, T value); 13 | 14 | template 15 | class promise { } 16 | 17 | } 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /stdlib/std/future/src/future.loci: -------------------------------------------------------------------------------- 1 | export std.future 0.1.0 { 2 | 3 | namespace std { 4 | 5 | // TODO 6 | 7 | } 8 | 9 | } 10 | 11 | -------------------------------------------------------------------------------- /stdlib/std/future/src/promise.loci: -------------------------------------------------------------------------------- 1 | export std.future 0.1.0 { 2 | 3 | namespace std { 4 | 5 | // TODO 6 | 7 | } 8 | 9 | } 10 | 11 | -------------------------------------------------------------------------------- /stdlib/std/memory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | loci_module(std.memory std_memory.bc "" 2 | src/alloc.loci 3 | src/raw.loci 4 | src/shared.loci 5 | src/unique.loci 6 | ) 7 | 8 | -------------------------------------------------------------------------------- /stdlib/std/memory/api/alloc.loci: -------------------------------------------------------------------------------- 1 | import std.memory 0.1.0 { 2 | 3 | namespace std { 4 | 5 | exception bad_alloc(); 6 | 7 | void* allocate(size_t size); 8 | 9 | void release(void* ptr) noexcept; 10 | 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /stdlib/std/memory/api/raw.loci: -------------------------------------------------------------------------------- 1 | import std.memory 0.1.0 { 2 | 3 | namespace std { 4 | 5 | template 6 | T* new_raw(T value); 7 | 8 | template 9 | void delete_raw(T* ptr) noexcept; 10 | 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /stdlib/std/memory/src/raw.loci: -------------------------------------------------------------------------------- 1 | export std.memory 0.1.0 { 2 | 3 | namespace std { 4 | 5 | template 6 | T* new_raw(T value) { 7 | void* ptr = allocate(sizeof(T)); 8 | T* castPtr = reinterpret_cast(ptr); 9 | new(castPtr) move value; 10 | return castPtr; 11 | } 12 | 13 | template 14 | void delete_raw(T* ptr) noexcept { 15 | ptr->__destroy(); 16 | release(reinterpret_cast(ptr)); 17 | } 18 | 19 | } 20 | 21 | } 22 | 23 | -------------------------------------------------------------------------------- /stdlib/std/network/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | loci_module(std.network std_network.bc "" 2 | src/ip/address.loci 3 | src/ip/address_v4.loci 4 | src/tcp/connector.loci 5 | src/tcp/endpoint.loci 6 | src/tcp/internal_stream.c 7 | src/tcp/listener.loci 8 | src/tcp/stream.loci 9 | src/tcp/sync_stream.loci 10 | ${STD_STRING_API_FILES} 11 | ${STD_CONTAINER_API_FILES} 12 | ${STD_EVENT_API_FILES} 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /stdlib/std/network/api/ip/address.loci: -------------------------------------------------------------------------------- 1 | import std.network 0.1.0 { 2 | 3 | namespace std { 4 | 5 | namespace ip { 6 | 7 | datatype address = 8 | address_v4(uint8_t[4] value) | 9 | address_v6(uint8_t[16] value); 10 | 11 | std::string address::to_string() const; 12 | 13 | } 14 | 15 | } 16 | 17 | } 18 | 19 | -------------------------------------------------------------------------------- /stdlib/std/network/api/ip/address_v4.loci: -------------------------------------------------------------------------------- 1 | import std.network 0.1.0 { 2 | 3 | namespace std { 4 | 5 | namespace ip { 6 | 7 | static address_v4 address_v4::localhost() noexcept; 8 | 9 | static address_v4 address_v4::any() noexcept; 10 | 11 | bool address_v4::is_localhost() const noexcept; 12 | 13 | bool address_v4::is_any() const noexcept; 14 | 15 | std::string address_v4::to_string() const; 16 | 17 | } 18 | 19 | } 20 | 21 | } 22 | 23 | -------------------------------------------------------------------------------- /stdlib/std/network/api/tcp/endpoint.loci: -------------------------------------------------------------------------------- 1 | import std.network 0.1.0 { 2 | 3 | namespace std { 4 | 5 | namespace tcp { 6 | 7 | using port_t = uint16_t; 8 | 9 | datatype endpoint(ip::address address, port_t port); 10 | 11 | std::string endpoint::to_string() const; 12 | 13 | } 14 | 15 | } 16 | 17 | } 18 | 19 | -------------------------------------------------------------------------------- /stdlib/std/network/api/tcp/listener.loci: -------------------------------------------------------------------------------- 1 | import std.network 0.1.0 { 2 | 3 | namespace std { 4 | 5 | namespace tcp { 6 | 7 | /** 8 | * \brief TCP Listener 9 | */ 10 | class listener { 11 | static listener create(port_t port); 12 | 13 | event::source event_source() const; 14 | 15 | bool check(); 16 | 17 | stream wait(); 18 | 19 | stream get(); 20 | } 21 | 22 | } 23 | 24 | } 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /stdlib/std/network/api/tcp/sync_stream.loci: -------------------------------------------------------------------------------- 1 | import std.network 0.1.0 { 2 | 3 | namespace std { 4 | 5 | namespace tcp { 6 | 7 | /** 8 | * \brief Synchronous stream. 9 | */ 10 | class sync_stream { 11 | static sync_stream create(stream& underlying_stream) noexcept; 12 | 13 | void sync_read(out_buffer& dest_buffer); 14 | 15 | void sync_write(const in_buffer& source_buffer); 16 | } 17 | 18 | } 19 | 20 | } 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /stdlib/std/network/src/tcp/endpoint.loci: -------------------------------------------------------------------------------- 1 | export std.network 0.1.0 { 2 | 3 | namespace std { 4 | 5 | namespace tcp { 6 | 7 | using port_t = uint16_t; 8 | 9 | datatype endpoint(ip::address address, uint16_t port); 10 | 11 | std::string endpoint::to_string() const { 12 | return "tcp::endpoint(address: " + @address.to_string() + ", port: " + serialize(@port) + ")"; 13 | } 14 | 15 | } 16 | 17 | } 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /stdlib/std/string/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | loci_module(std.string std_string.bc "" 2 | src/string.loci 3 | src/string_builder.loci 4 | src/string_iterator.loci 5 | src/string_range.loci 6 | src/utf8.loci 7 | src/utf8_buffer.loci 8 | ${STD_CONTAINER_API_FILES} 9 | ${STD_MEMORY_API_FILES} 10 | ) 11 | 12 | -------------------------------------------------------------------------------- /stdlib/std/string/api/utf8.loci: -------------------------------------------------------------------------------- 1 | import std.string 0.1.0 { 2 | 3 | namespace std { 4 | 5 | exception utf8_decode_error(const ubyte* error); 6 | 7 | void utf8_encode(input_range& source, output_range& dest); 8 | 9 | void utf8_decode(input_range& source, output_range& dest); 10 | 11 | void utf8_encode_character(unichar character, output_range& dest); 12 | 13 | unichar utf8_decode_character(input_range& source); 14 | 15 | } 16 | 17 | } 18 | 19 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Compiler tests. 2 | # Run 'make test' or 'ctest' to execute these. 3 | 4 | add_test(NAME "RunLitTests" 5 | COMMAND lit -v -j1 ${CMAKE_CURRENT_SOURCE_DIR}) 6 | -------------------------------------------------------------------------------- /test/CheckError/Class/DuplicateClass.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { } 5 | 6 | // CHECK: .loci:8:1: error: type 'TestClass' clashes with existing name 7 | // CHECK: .loci:4:1: note: because: previously defined here 8 | class TestClass() { } 9 | 10 | // CHECK: 1 error generated. 11 | -------------------------------------------------------------------------------- /test/CheckError/Class/DuplicateMemberVar.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:6:28: error: variable 'value' duplicates existing variable 5 | // CHECK: .loci:6:17: note: because: variable previously defined here 6 | class TestClass(int value, int value) { 7 | static create = default; 8 | } 9 | 10 | // CHECK: 1 error generated. 11 | -------------------------------------------------------------------------------- /test/CheckError/Class/NoNullConstructor.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass(int value) { 5 | static Create = default; 6 | } 7 | 8 | export int main(unused int argc, unused ubyte ** argv) { 9 | // CHECK: .loci:10:2: error: user cast failed from type 'null_t' to type 'TestClass' 10 | TestClass object = null; 11 | return 0; 12 | } 13 | 14 | // CHECK: 1 error generated. 15 | 16 | -------------------------------------------------------------------------------- /test/CheckError/Conditional/IntCondition.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // Integers can't be used as conditions in Loci 5 | // (no implicit cast to bool). 6 | 7 | export int main(unused int argc, unused ubyte ** argv) { 8 | // CHECK: .loci:9:2: error: user cast failed from type 'int8_t' to type 'bool_t' 9 | if (1) { 10 | // ... 11 | } 12 | return 0; 13 | } 14 | 15 | // CHECK: 1 error generated. 16 | -------------------------------------------------------------------------------- /test/CheckError/Conditional/MismatchedTernaryValues.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export int main(unused int argc, unused ubyte ** argv) { 5 | // CHECK: .loci:6:16: error: user cast failed from type 'double_t' to type 'int8_t' 6 | unused_result(true ? 1 : 1.0); 7 | return 0; 8 | } 9 | 10 | // CHECK: 1 error generated. 11 | -------------------------------------------------------------------------------- /test/CheckError/Conditional/NonBoolCondition.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass(int value) { 5 | static create = default; 6 | } 7 | 8 | export int main(unused int argc, unused ubyte ** argv) { 9 | // CHECK: .loci:10:2: error: Can't implicitly cast value of type 'TestClass' to type 'bool_t'. 10 | if (TestClass(10)) { 11 | // ... 12 | } 13 | return 0; 14 | } 15 | 16 | // CHECK: 1 error generated. 17 | -------------------------------------------------------------------------------- /test/CheckError/Const/CallNonConstMethodOnConstObject.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass(int value) { 5 | static create = default; 6 | 7 | void modify() { 8 | @value = 100; 9 | } 10 | } 11 | 12 | export void f() { 13 | const TestClass object = TestClass(10); 14 | // CHECK: .loci:15:2: error: cannot refer to mutator method 'modify' from const object of type 'const(TestClass)' 15 | object.modify(); 16 | } 17 | 18 | // CHECK: 1 error generated. 19 | -------------------------------------------------------------------------------- /test/CheckError/Const/CallNonConstMethodOnConstTemplateVar.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | interface Changeable { 5 | void modify(); 6 | } 7 | 8 | template 9 | void function(const T& object) require(T : Changeable) { 10 | // CHECK: .loci:11:2: error: cannot refer to mutator method 'modify' from const object of type 'const(T)' 11 | object.modify(); 12 | } 13 | 14 | // CHECK: 1 error generated. 15 | -------------------------------------------------------------------------------- /test/CheckError/Const/ConstPointerTransitivity.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | struct S { 5 | int* p; 6 | }; 7 | 8 | void f(const S* value) { 9 | // CHECK: .loci:10:2: error: cannot assign non-movable type 'const(int_t)' 10 | *(value->p) = 1; 11 | } 12 | 13 | void g(S* value) { 14 | *(value->p) = 1; 15 | } 16 | 17 | // CHECK: 1 error generated. 18 | -------------------------------------------------------------------------------- /test/CheckError/Const/ModifyConstLocalVariable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export void f() { 5 | const int value = 0; 6 | // CHECK: .loci:7:2: error: cannot assign non-movable type 'const(int_t)' 7 | value = 1; 8 | } 9 | 10 | export void g() { 11 | int value = 0; 12 | value = 1; 13 | } 14 | 15 | // CHECK: 1 error generated. 16 | 17 | -------------------------------------------------------------------------------- /test/CheckError/Const/ModifyConstParamVariable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | void f(const int value) { 5 | // CHECK: .loci:6:2: error: cannot assign non-movable type 'const(int_t)' 6 | value = 1; 7 | } 8 | 9 | void g(int value) { 10 | value = 1; 11 | } 12 | 13 | // CHECK: 1 error generated. 14 | -------------------------------------------------------------------------------- /test/CheckError/Const/ModifyConstValuePointer.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | void f(const int* value) { 5 | // CHECK: .loci:6:2: error: cannot assign non-movable type 'const(int_t)' 6 | *value = 1; 7 | } 8 | 9 | void g(int* value) { 10 | *value = 1; 11 | } 12 | 13 | // CHECK: 1 error generated. 14 | -------------------------------------------------------------------------------- /test/CheckError/Datatype/CopyNonCopyableDatatype.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // Not implicitly copyable. 6 | } 7 | 8 | datatype TestDatatype(TestClass object); 9 | 10 | TestDatatype doImplicitCopy(TestDatatype value) { 11 | // CHECK: .loci:12:2: error: unable to copy type 'TestDatatype' because it doesn't have a valid 'implicitcopy' method, in cast from type 'TestDatatype&' to type 'TestDatatype' 12 | return value; 13 | } 14 | 15 | // CHECK: 1 error generated. 16 | -------------------------------------------------------------------------------- /test/CheckError/Datatype/CopyPartiallyNonCopyableDatatype.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // Not implicitly copyable. 6 | } 7 | 8 | datatype TestDatatype(TestClass object); 9 | 10 | TestDatatype doImplicitCopy(TestDatatype value) { 11 | // CHECK: .loci:12:2: error: unable to copy type 'TestDatatype' because it doesn't have a valid 'implicitcopy' method, in cast from type 'TestDatatype&' to type 'TestDatatype' 12 | return value; 13 | } 14 | 15 | // CHECK: 1 error generated. 16 | -------------------------------------------------------------------------------- /test/CheckError/Move/MoveNonMovableTemplateType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | template 5 | void moveObject(T object) { 6 | // CHECK: .loci:7:16: error: cannot find method '__move' for type 'T' 7 | unused_result move object; 8 | } 9 | 10 | // CHECK: 2 errors generated. 11 | -------------------------------------------------------------------------------- /test/CheckError/Primitives/InvalidConstantStaticArraySizeParameter.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:8: error: static array size has type 'double_t', which doesn't match expected type 'size_t' 5 | import int[1.0] invalidDoubleSizeParameter(); 6 | 7 | // CHECK: 1 error generated. 8 | -------------------------------------------------------------------------------- /test/CheckError/Primitives/InvalidTemplateStaticArraySizeParameter.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | template 5 | // CHECK: .loci:6:8: error: static array size has type 'double_t', which doesn't match expected type 'size_t' 6 | import int[V] invalidDoubleSizeParameter(); 7 | 8 | // CHECK: 1 error generated. 9 | -------------------------------------------------------------------------------- /test/CheckError/SizeOf/AlignOfUnsizedTemplateType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | template 5 | size_t getTypeAlign() { 6 | // CHECK: .loci:7:9: error: cannot find static method '__alignmask' for type 'T' 7 | return alignof(T); 8 | } 9 | 10 | // CHECK: 4 errors generated. 11 | -------------------------------------------------------------------------------- /test/CheckError/SizeOf/SizeOfUnsizedTemplateType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | template 5 | size_t getTypeSize() { 6 | // CHECK: .loci:7:9: error: cannot find static method '__sizeof' for type 'T' 7 | return sizeof(T); 8 | } 9 | 10 | // CHECK: 2 errors generated. 11 | -------------------------------------------------------------------------------- /test/CheckError/Struct/OpaqueStructAlignOf.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | struct OpaqueStruct; 5 | 6 | size_t f() { 7 | // CHECK: .loci:8:9: error: cannot find static method '__alignmask' for type 'OpaqueStruct' 8 | return alignof(OpaqueStruct); 9 | } 10 | 11 | // CHECK: 4 errors generated. 12 | -------------------------------------------------------------------------------- /test/CheckError/Struct/OpaqueStructMove.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | struct OpaqueStruct; 5 | 6 | void f(OpaqueStruct* ptr) { 7 | // CHECK: .loci:8:16: error: cannot find method '__move' for type 'OpaqueStruct' 8 | unused_result move *ptr; 9 | } 10 | 11 | // CHECK: 2 errors generated. 12 | -------------------------------------------------------------------------------- /test/CheckError/Struct/OpaqueStructPointerArithmetic.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | struct OpaqueStruct; 5 | 6 | OpaqueStruct* plusOne(OpaqueStruct* ptr) { 7 | // .loci:12:9: error: template arguments do not satisfy require predicate 'OpaqueStruct : sized_type_t' of method 'add' 8 | // .loci:12:9: note: because: method '__alignmask' not found 9 | // .loci:12:15: error: User cast failed from type 'uint8_t' to type 'ptrdiff_t'. 10 | return ptr + 1u; 11 | } 12 | 13 | // CHECK: 2 errors generated. 14 | -------------------------------------------------------------------------------- /test/CheckError/Struct/OpaqueStructSizeOf.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | struct OpaqueStruct; 5 | 6 | size_t f() { 7 | // CHECK: .loci:8:9: error: cannot find static method '__sizeof' for type 'OpaqueStruct' 8 | return sizeof(OpaqueStruct); 9 | } 10 | 11 | // CHECK: 2 errors generated. 12 | -------------------------------------------------------------------------------- /test/CheckError/Templates/IncorrectTemplateType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | template 5 | void g() { } 6 | 7 | export void f() { 8 | // CHECK: .loci:9:2: error: template argument has type 'typename_t', which doesn't match type 'bool_t' of template variable 'T' 9 | g(); 10 | } 11 | 12 | // CHECK: 1 error generated. 13 | -------------------------------------------------------------------------------- /test/CheckError/Templates/InvalidAliasTemplateVarType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class SomeClass() { } 5 | 6 | // CHECK: .loci:7:11: error: template variable 'T' has non-primitive type 'SomeClass' 7 | template 8 | using TestAlias = int; 9 | 10 | // CHECK: 1 error generated. 11 | -------------------------------------------------------------------------------- /test/CheckError/Templates/InvalidTypeInstanceTemplateVarType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class SomeClass() { } 5 | 6 | // CHECK: .loci:7:11: error: template variable 'T' has non-primitive type 'SomeClass' 7 | template 8 | class TestClass() { } 9 | 10 | // CHECK: 1 error generated. 11 | -------------------------------------------------------------------------------- /test/CheckOutput/Alias/BasicPredicateAlias.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: TestClass.print() 5 | 6 | import void printf(const ubyte * str, ...); 7 | 8 | using SetConst = true; 9 | 10 | class TestClass() { 11 | static Create = default; 12 | 13 | void print() const(SetConst) { 14 | printf(C"TestClass.print()\n"); 15 | } 16 | } 17 | 18 | export int main(unused int argc, unused ubyte ** argv) { 19 | const TestClass object = TestClass(); 20 | object.print(); 21 | return 0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /test/CheckOutput/Alias/BasicTypeAlias.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: TestClass.print() 5 | 6 | import void printf(const ubyte * str, ...); 7 | 8 | class TestClass() { 9 | static Create = default; 10 | 11 | void print() { 12 | printf(C"TestClass.print()\n"); 13 | } 14 | } 15 | 16 | using TestClassAlias = TestClass; 17 | 18 | export int main(unused int argc, unused ubyte ** argv) { 19 | TestClassAlias object = TestClassAlias(); 20 | object.print(); 21 | return 0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /test/CheckOutput/Alias/BasicValueAlias.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: IntValue = 42 5 | 6 | import void printf(const ubyte * str, ...); 7 | 8 | using IntValue = 42; 9 | 10 | export int main(unused int argc, unused ubyte ** argv) { 11 | printf(C"IntValue = %d\n", IntValue); 12 | return 0; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /test/CheckOutput/Alias/RecursiveValueAlias.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: IntValue = 100 5 | 6 | import void printf(const ubyte * str, ...); 7 | 8 | using IntValue0 = 100; 9 | using IntValue1 = IntValue0; 10 | using IntValue2 = IntValue1; 11 | using IntValue3 = IntValue2; 12 | using IntValue = IntValue3; 13 | 14 | export int main(unused int argc, unused ubyte ** argv) { 15 | printf(C"IntValue = %d\n", IntValue); 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /test/CheckOutput/Class/EmptyClass.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: TestClass.Create 5 | // CHECK: TestClass.Create 6 | 7 | import void printf(const ubyte * str, ...); 8 | 9 | // Class definition. 10 | class TestClass() { 11 | static Create() { 12 | printf(C"TestClass.Create\n"); 13 | return @(); 14 | } 15 | 16 | } 17 | 18 | export int main(unused int argc, unused ubyte ** argv) { 19 | unused auto testInstance = TestClass(); 20 | unused_result TestClass(); 21 | return 0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /test/CheckOutput/Class/ExtensionMethodPrimitive.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: uint8_t.printSelf: self = 20 5 | // CHECK: uint8_t.printSelf: self = 30 6 | 7 | import void printf(const ubyte * str, ...); 8 | 9 | void int_t::printSelf() const { 10 | printf(C"uint8_t.printSelf: self = %d\n", self); 11 | } 12 | 13 | export int main(unused int argc, unused ubyte ** argv) { 14 | int i = 20; 15 | i.printSelf(); 16 | int j = 30; 17 | j.printSelf(); 18 | return 0; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /test/CheckOutput/Conditional/BasicIf.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: main: START 5 | // CHECK: main: i == 321 6 | // CHECK: main: END 7 | 8 | import void printf(const ubyte * str, ...); 9 | 10 | export int main(unused int argc, unused ubyte ** argv) { 11 | int i = 321; 12 | 13 | printf(C"main: START\n"); 14 | 15 | if (i == 321) { 16 | printf(C"main: i == 321\n"); 17 | } 18 | 19 | printf(C"main: END\n"); 20 | 21 | return 0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /test/CheckOutput/Exception/BasicException.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: Caught exception with value 1024! 5 | 6 | import void printf(const ubyte * str, ...); 7 | 8 | exception ExampleError(int value); 9 | 10 | export int main(unused int argc, unused ubyte ** argv) { 11 | try { 12 | throw ExampleError(1024); 13 | } catch (ExampleError error) { 14 | printf(C"Caught exception with value %d!\n", error.value); 15 | } 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /test/CheckOutput/Exception/EmptyException.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: Caught empty exception! 5 | 6 | import void printf(const ubyte * str, ...); 7 | 8 | exception ExampleEmptyError(); 9 | 10 | export int main(unused int argc, unused ubyte ** argv) { 11 | try { 12 | throw ExampleEmptyError(); 13 | } catch (ExampleEmptyError error) { 14 | printf(C"Caught empty exception!\n"); 15 | } 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /test/CheckOutput/Function/FunctionRef.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: i = 42 5 | 6 | import void printf(const ubyte * str, ...); 7 | 8 | void function(int i) { 9 | printf(C"i = %d\n", i); 10 | } 11 | 12 | (*)(void)(int) getFunctionPtr() { 13 | return function; 14 | } 15 | 16 | export int main(unused int argc, unused ubyte ** argv) { 17 | getFunctionPtr()(42); 18 | return 0; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /test/CheckOutput/Function/TemplatedFunctionRef.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: i = 44 5 | 6 | import void printf(const ubyte * str, ...); 7 | 8 | template 9 | void function(int i) { 10 | printf(C"i = %d\n", i); 11 | } 12 | 13 | export int main(unused int argc, unused ubyte ** argv) { 14 | auto f = function; 15 | f(44); 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /test/CheckOutput/Modules/ImportNamed.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | // XFAIL: * 4 | 5 | // CHECK: main: #5 6 | // CHECK: main: #4 7 | // CHECK: main: #3 8 | // CHECK: main: #2 9 | // CHECK: main: #1 10 | 11 | import void printf(const ubyte* str, ...) noexcept; 12 | 13 | import test.module 1.0.0 { 14 | int moduleAPI(); 15 | } 16 | 17 | export int main(unused int argc, unused ubyte** argv) { 18 | printf(C"main: moduleAPI() returned %d\n", moduleAPI()); 19 | 20 | return 0; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /test/CheckOutput/SizeOf/EmptyClassSizeOf.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: sizeof(EmptyClass) = 1 5 | // CHECK: EmptyClass.__sizeof() = 1 6 | 7 | import void printf(const ubyte * str, ...) noexcept; 8 | 9 | class EmptyClass() { } 10 | 11 | export int main(unused int argc, unused ubyte ** argv) { 12 | printf(C"sizeof(EmptyClass) = %llu\n", sizeof(EmptyClass).cast()); 13 | printf(C"EmptyClass.__sizeof() = %llu\n", EmptyClass.__sizeof().cast()); 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test/CheckOutput/SizeOf/EmptyDatatypeAlignOf.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: alignof(Empty) = 1 5 | // CHECK: Empty.__alignmask() = 0 6 | 7 | import void printf(const ubyte * str, ...) noexcept; 8 | 9 | datatype Empty(); 10 | 11 | export int main(unused int argc, unused ubyte ** argv) { 12 | printf(C"alignof(Empty) = %llu\n", alignof(Empty).cast()); 13 | printf(C"Empty.__alignmask() = %llu\n", Empty.__alignmask().cast()); 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test/CheckOutput/SizeOf/EmptyDatatypeSizeOf.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: sizeof(Empty) = 1 5 | // CHECK: Empty.__sizeof() = 1 6 | 7 | import void printf(const ubyte * str, ...) noexcept; 8 | 9 | datatype Empty(); 10 | 11 | export int main(unused int argc, unused ubyte ** argv) { 12 | printf(C"sizeof(Empty) = %llu\n", sizeof(Empty).cast()); 13 | printf(C"Empty.__sizeof() = %llu\n", Empty.__sizeof().cast()); 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test/CheckOutput/SizeOf/EmptyStructAlignOf.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: alignof(Empty) = 1 5 | // CHECK: Empty.__alignmask() = 0 6 | 7 | import void printf(const ubyte * str, ...); 8 | 9 | struct Empty { }; 10 | 11 | export int main(unused int argc, unused ubyte ** argv) { 12 | printf(C"alignof(Empty) = %llu\n", alignof(Empty).cast()); 13 | printf(C"Empty.__alignmask() = %llu\n", Empty.__alignmask().cast()); 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test/CheckOutput/SizeOf/EmptyUnionAlignOf.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: alignof(Empty) = 1 5 | // CHECK: Empty.__alignmask() = 0 6 | 7 | import void printf(const ubyte * str, ...); 8 | 9 | union Empty { }; 10 | 11 | export int main(unused int argc, unused ubyte ** argv) { 12 | printf(C"alignof(Empty) = %llu\n", alignof(Empty).cast()); 13 | printf(C"Empty.__alignmask() = %llu\n", Empty.__alignmask().cast()); 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test/CheckOutput/SizeOf/TemplatedTypeAlignOf.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: getTypeAlign() = 4 5 | 6 | import void printf(const ubyte * str, ...); 7 | 8 | template 9 | size_t getTypeAlign() { 10 | return alignof(T); 11 | } 12 | 13 | export int main(unused int argc, unused ubyte ** argv) { 14 | printf(C"getTypeAlign() = %llu\n", getTypeAlign().cast()); 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /test/CheckOutput/SizeOf/TemplatedTypeSizeOf.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: getTypeSize() = 4 5 | 6 | import void printf(const ubyte * str, ...); 7 | 8 | template 9 | size_t getTypeSize() { 10 | return sizeof(T); 11 | } 12 | 13 | export int main(unused int argc, unused ubyte ** argv) { 14 | printf(C"getTypeSize() = %llu\n", getTypeSize().cast()); 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /test/CheckOutput/Templates/BasicFunctionTemplate.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --interpret > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: i = 20 5 | // CHECK: f = 20.000000 6 | 7 | import void printf(const ubyte * str, ...); 8 | 9 | template 10 | T function(T arg) { 11 | return move arg; 12 | } 13 | 14 | export int main(unused int argc, unused ubyte ** argv) { 15 | int i = function(20); 16 | printf(C"i = %d\n", i); 17 | 18 | float f = function(20.0f); 19 | printf(C"f = %f\n", f); 20 | 21 | return 0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /test/CodeGen/Linkage/FunctionLinkage.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --target x86_64 --emit-llvm -o %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK-LABEL: declare i{{[0-9]+}} @importFunction() 5 | import int importFunction(); 6 | 7 | // CHECK-LABEL: define internal i{{[0-9]+}} @internalFunction() 8 | int internalFunction() { 9 | // CHECK: ret i{{[0-9]+}} 0 10 | return 0; 11 | } 12 | 13 | // CHECK-LABEL: define i{{[0-9]+}} @externalFunction() 14 | export int externalFunction() { 15 | // CHECK: ret i{{[0-9]+}} 0 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /test/CodeGen/VirtualCall/VTableOneMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --target x86_64 --emit-llvm -o %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // TODO 5 | // XFAIL: * 6 | 7 | interface Interface { 8 | void method(); 9 | } 10 | 11 | class Class() { 12 | void method() { } 13 | } 14 | 15 | // CHECK-LABEL: TODO 16 | export Interface& f(Class& c) { 17 | return c; 18 | } 19 | -------------------------------------------------------------------------------- /test/CodeGen/VirtualCall/VTableTwoMethodConflict.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --target x86_64 --emit-llvm -o %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // TODO 5 | // XFAIL: * 6 | 7 | interface Interface { 8 | // It turns out that 'method0' and 'method4' clash in slot index 4. 9 | void method0(); 10 | void method4(); 11 | } 12 | 13 | class Class() { 14 | void method0() { } 15 | void method4() { } 16 | } 17 | 18 | // CHECK-LABEL: TODO 19 | export Interface& f(Class& c) { 20 | return c; 21 | } 22 | -------------------------------------------------------------------------------- /test/Parser/Class/MethodDeclInClassDef.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: unexpected method declaration; was expecting method definition 6 | void method(); 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/Parser/Class/MethodDefInClassDecl.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass { 5 | // CHECK: .loci:6:2: error: unexpected method definition; was expecting method declaration 6 | void method() { } 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/Parser/Class/UnterminatedClassDeclMethodList.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:8:1: error: expected 'RCURLYBRACKET'; got 'END' 5 | class TestClass { 6 | 7 | // CHECK: 1 error generated. 8 | -------------------------------------------------------------------------------- /test/Parser/Class/UnterminatedClassDefMemberList.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:12:1: error: unexpected type token: END 5 | // CHECK: .loci:12:1: error: expected 'NAME'; got 'END' 6 | // CHECK: .loci:12:1: error: expected 'RROUNDBRACKET'; got 'END' 7 | // CHECK: .loci:12:1: error: expected 'LCURLYBRACKET'; got 'END' 8 | // CHECK: .loci:12:1: error: expected 'RCURLYBRACKET'; got 'END' 9 | class TestClass( 10 | 11 | // CHECK: 5 errors generated. 12 | -------------------------------------------------------------------------------- /test/Parser/Class/UnterminatedClassDefMethodList.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:8:1: error: expected 'RCURLYBRACKET'; got 'END' 5 | class TestClass() { 6 | 7 | // CHECK: 1 error generated. 8 | -------------------------------------------------------------------------------- /test/Parser/Conditional/MultipleElse.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // Entry point. 5 | export int testEntryPoint(unused int argc, unused ubyte ** argv) { 6 | if (true) { 7 | // ... 8 | } else { 9 | // ... 10 | // CHECK: .loci:11:4: error: 'else' without a previous 'if' 11 | } else { 12 | // ... 13 | } 14 | return 0; 15 | } 16 | 17 | // CHECK: 1 error generated. 18 | -------------------------------------------------------------------------------- /test/Parser/Enum/UnterminatedEnumConstructorList.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:9:1: error: expected 'NAME'; got 'END' 5 | // CHECK: .loci:9:1: error: expected 'RCURLYBRACKET'; got 'END' 6 | enum TestEnum { 7 | 8 | // CHECK: 2 errors generated. 9 | -------------------------------------------------------------------------------- /test/Parser/Namespace/RCurlyBracketTerminatingGlobalNamespace.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:1: error: expected 'END'; got 'RCURLYBRACKET' 5 | } 6 | 7 | // CHECK: 1 error generated. 8 | -------------------------------------------------------------------------------- /test/Parser/Scope/UnterminatedScope.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:8:1: error: expected 'RCURLYBRACKET'; got 'END' 5 | export void function() { 6 | 7 | // CHECK: 1 error generated. 8 | -------------------------------------------------------------------------------- /test/Parser/Statement/PointerTypeVariableInitialiseSyntax.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --parse-only 2 | 3 | class C() { } 4 | 5 | export C* f() { 6 | // Ensure this isn't confused with (C * c) = ..., which would be assigning 7 | // to the multiplication of 'C' and 'c'. 8 | C* c = null; 9 | return c; 10 | } 11 | -------------------------------------------------------------------------------- /test/Parser/Statement/ReferenceTypeVariableInitialiseSyntax.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --parse-only 2 | 3 | class C() { } 4 | 5 | export C& f(C& v) { 6 | // Ensure this isn't confused with (C & c) = ..., which would be assigning 7 | // to the bitwise-and of 'C' and 'c'. 8 | C& c = v; 9 | return c; 10 | } 11 | -------------------------------------------------------------------------------- /test/Parser/Struct/UnterminatedStructMemberList.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:8:1: error: expected 'RCURLYBRACKET'; got 'END' 5 | struct TestStruct { 6 | 7 | // CHECK: 1 error generated. 8 | -------------------------------------------------------------------------------- /test/Parser/Type/BitwiseShiftInTemplateSyntax.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --parse-only 2 | 3 | template 4 | class C () { } 5 | 6 | template 7 | import C<(A< testLeftShiftInTemplateArgument(); 8 | 9 | template 10 | import C<(A>>B)> testRightShiftInTemplateArgument(); 11 | 12 | template 13 | export void testLeftShiftInVariableTemplate(unused C<(A< value) { } 14 | 15 | template 16 | export void testRightShiftInVariableTemplate(unused C<(A>>B)> value) { } 17 | -------------------------------------------------------------------------------- /test/Parser/Type/DoubleRightTriangleBracketSyntax.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --parse-only 2 | 3 | template 4 | class C () { } 5 | 6 | import C> testTwoJointDoubleRightTriangleBrackets(); 7 | 8 | import C > testTwoSplitDoubleRightTriangleBrackets(); 9 | 10 | import C>> testThreeJointDoubleRightTriangleBrackets(); 11 | 12 | import C > > testThreeSplitDoubleRightTriangleBrackets(); 13 | -------------------------------------------------------------------------------- /test/Parser/Type/NestedTemplateArgumentsSyntax.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --parse-only 2 | 3 | template 4 | class C () { } 5 | 6 | import C< C, C > testTwoLevelNestedTemplateArguments(); 7 | 8 | import C< C< C, C >, C< C, C > > testThreeLevelNestedTemplateArguments(); 9 | -------------------------------------------------------------------------------- /test/Parser/Type/TriangleBracketInTemplateSyntax.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --parse-only 2 | 3 | template 4 | class C () { } 5 | 6 | template 7 | import C<(A testLeftTriangleBracketInTemplateArgument(); 8 | 9 | template 10 | import C<(A>B)> testRightTriangleBracketInTemplateArgument(); 11 | 12 | export void testLeftTriangleBracketInVariableTemplate(unused C<(A value) { } 13 | 14 | export void testRightTriangleBracketInVariableTemplate(unused C<(A>B)> value) { } 15 | -------------------------------------------------------------------------------- /test/Parser/Value/BracketedComparisonInFunctionArgument.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --parse-only 2 | 3 | import void f(bool arg); 4 | 5 | export void compareInFunctionCall() { 6 | int A = 1; 7 | int B = 2; 8 | 9 | f((AB)); 11 | } 12 | -------------------------------------------------------------------------------- /test/Parser/Value/TypeRefValueSyntax.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --parse-only 2 | 3 | class TestClass() { } 4 | 5 | export typename_t getType() { 6 | return TestClass; 7 | } 8 | 9 | export typename_t getConstType() { 10 | return const TestClass; 11 | } 12 | 13 | template 14 | export typename_t TestClass> getConstPredicateType() { 15 | return const TestClass; 16 | } 17 | -------------------------------------------------------------------------------- /test/Parser/Var/InheritOnExceptionVariable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:25: error: unexpected 'inherit' keyword 5 | exception TestException(inherit int i); 6 | 7 | // CHECK: 1 error generated. 8 | -------------------------------------------------------------------------------- /test/Parser/Var/InheritOnLocalVariable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export int function() { 5 | // CHECK: .loci:6:2: error: unexpected 'inherit' keyword 6 | inherit int i = 10; 7 | return i; 8 | } 9 | 10 | // CHECK: 1 error generated. 11 | -------------------------------------------------------------------------------- /test/Parser/Var/InheritOnParameterVariable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:21: error: unexpected 'inherit' keyword 5 | export int function(inherit int i) { 6 | return i; 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/Parser/Var/InheritOnStructVariable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | struct TestStruct { 5 | // CHECK: .loci:6:2: error: unexpected 'inherit' keyword 6 | inherit int i; 7 | }; 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Alias/AliasCircularDependency.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | using A = B; 5 | // CHECK: .loci:6:1: error: alias 'B' depends on itself via a cycle 6 | using B = A; 7 | 8 | // CHECK: 1 error generated. 9 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Alias/AliasStaticMethodAccess.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | static Create = default; 6 | } 7 | 8 | using TestClassAlias = TestClass; 9 | 10 | export void f() { 11 | // CHECK-NOT: .loci:12:16: error: use of undeclared identifier 'TestClass::Create' 12 | unused_result TestClass::Create; 13 | // CHECK: .loci:14:16: error: use of undeclared identifier 'TestClassAlias::Create' 14 | unused_result TestClassAlias::Create; 15 | } 16 | 17 | // CHECK: 1 error generated. 18 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Alias/PredicateBasicAlias.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | require(Value) 5 | class CheckIsTrue() { } 6 | 7 | using AliasValueTrue = true; 8 | 9 | import CheckIsTrue checkAliasValueIsTrue(); 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Alias/PredicateCapabilityAlias.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | interface DoThingable { 4 | void doThing(); 5 | } 6 | 7 | template 8 | using CanDoThing = T : DoThingable; 9 | 10 | class TypeWithCapability() { 11 | void doThing() { } 12 | } 13 | 14 | template 15 | require(CanDoThing) 16 | class CheckHasCapability() { } 17 | 18 | import CheckHasCapability checkTypeHasCapabilityViaPredicateAlias(); 19 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Alias/PredicateExpressionAlias.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | require(Value) 5 | class CheckIsTrue() { } 6 | 7 | template 8 | using AliasValue = A or B; 9 | 10 | import CheckIsTrue> checkAliasValueFalseOrTrue(); 11 | 12 | import CheckIsTrue> checkAliasValueTrueOrFalse(); 13 | 14 | import CheckIsTrue> checkAliasValueTrueOrTrue(); 15 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Alias/PredicateRecursiveAlias.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | require(Value) 5 | class CheckIsTrue() { } 6 | 7 | using True0 = true; 8 | using True1 = True0; 9 | using True2 = True1; 10 | using True3 = True2; 11 | using AliasValueTrue = True3; 12 | 13 | import CheckIsTrue checkAliasValueIsTrue(); 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Alias/PredicateTemplatedAlias.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | require(Value) 5 | class CheckIsTrue() { } 6 | 7 | template 8 | using AliasValue = IsTrue; 9 | 10 | import CheckIsTrue> checkAliasValueIsTrue(); 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Alias/TypeAliasReturnType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | class TestClass() { 4 | TestClassAlias& getSelf() { 5 | return self; 6 | } 7 | } 8 | 9 | using TestClassAlias = TestClass; 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Alias/ValueBasicAlias.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | using IntValue = 42; 4 | 5 | export int returnIntValue() { 6 | return IntValue; 7 | } 8 | 9 | using IntCallValue = returnIntValue(); 10 | 11 | export int returnIntCallValue() { 12 | return IntCallValue; 13 | } 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Assert/StaticAssertTrivialBool.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK-NOT: .loci:5:15: error: static assert predicate evaluates to false 5 | static assert true; 6 | 7 | // CHECK: .loci:9:15: error: static assert predicate evaluates to false 8 | // CHECK: .loci:9:15: note: because: predicate has literal 'false' 9 | static assert false; 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Assert/StaticAssertTrivialTrue.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | static assert true; 5 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Cast/FloatImplicitCast.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | // Entry point. 5 | export int main(unused int argc, unused ubyte ** argv) { 6 | float floatValue = 1.0f; 7 | double doubleValue = floatValue; 8 | unused long double longDoubleValue = doubleValue; 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Cast/FloatLiteralBindRef.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | // Entry point. 5 | export int main(unused int argc, unused ubyte ** argv) { 6 | unused const float& floatValue = 1.0f; 7 | unused const double& doubleValue = 1.0f; 8 | unused const long double& longDoubleValue = 1.0f; 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Cast/FloatLiteralImplicitCast.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | // Entry point. 5 | export int main(unused int argc, unused ubyte ** argv) { 6 | unused float floatValue = 1.0f; 7 | unused double doubleValue = 1.0f; 8 | unused long double longDoubleValue = 1.0f; 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Cast/IntImplicitCast.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | // Entry point. 5 | export int main(unused int argc, unused ubyte ** argv) { 6 | byte byteValue = 1; 7 | short shortValue = byteValue; 8 | int intValue = shortValue; 9 | long longValue = intValue; 10 | unused long long longLongValue = longValue; 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Cast/IntLiteralBindRef.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | // Entry point. 5 | export int main(unused int argc, unused ubyte ** argv) { 6 | unused const byte& byteValue = 1; 7 | unused const short& shortValue = 1; 8 | unused const int& intValue = 1; 9 | unused const long& longValue = 1; 10 | unused const long long& longLongValue = 1; 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Cast/IntLiteralImplicitCast.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | // Entry point. 5 | export int main(unused int argc, unused ubyte ** argv) { 6 | unused byte byteValue = 1; 7 | unused short shortValue = 1; 8 | unused int intValue = 1; 9 | unused long longValue = 1; 10 | unused long long longLongValue = 1; 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Cast/ReinterpretCastNonPointerType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export void f() { 5 | int value = 10; 6 | // CHECK-NOT: .loci:7:16: error: reinterpret_cast only supports pointers 7 | unused_result reinterpret_cast(&value); 8 | 9 | // CHECK: .loci:10:16: error: reinterpret_cast only supports pointers, in cast from type 'int_t' to type 'float_t' 10 | unused_result reinterpret_cast(10); 11 | } 12 | 13 | // CHECK: 1 error generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Cast/UnsignedIntImplicitCast.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | // Entry point. 5 | export int main(unused int argc, unused ubyte ** argv) { 6 | unsigned byte unsignedByteValue = 1u; 7 | unsigned short unsignedShortValue = unsignedByteValue; 8 | unsigned int unsignedIntValue = unsignedShortValue; 9 | unsigned long unsignedLongValue = unsignedIntValue; 10 | unused unsigned long long unsignedLongLongValue = unsignedLongValue; 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Cast/UnsignedIntLiteralBindRef.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | // Entry point. 5 | export int main(unused int argc, unused ubyte ** argv) { 6 | unused const unsigned byte& unsignedByteValue = 1u; 7 | unused const unsigned short& unsignedShortValue = 1u; 8 | unused const unsigned int& unsignedIntValue = 1u; 9 | unused const unsigned long& unsignedLongValue = 1u; 10 | unused const unsigned long long& unsignedLongLongValue = 1u; 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Cast/UnsignedIntLiteralImplicitCast.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | // Entry point. 5 | export int main(unused int argc, unused ubyte ** argv) { 6 | unused unsigned byte unsignedByteValue = 1u; 7 | unused unsigned short unsignedShortValue = 1u; 8 | unused unsigned int unsignedIntValue = 1u; 9 | unused unsigned long unsignedLongValue = 1u; 10 | unused unsigned long long unsignedLongLongValue = 1u; 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Class/DuplicateCanonicalMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | void doSomething() { } 6 | 7 | // CHECK: .loci:8:7: error: method 'do_SOME_thing' clashes with previous method 'doSomething' due to method canonicalization 8 | void do_SOME_thing() { } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Class/DuplicateMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | void doSomething() { } 6 | 7 | // CHECK: .loci:8:7: error: method 'doSomething' clashes with previous method of the same name 8 | void doSomething() { } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Class/GetStaticMethodOfObject.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | static create = default; 6 | 7 | static void method() { } 8 | } 9 | 10 | export void f() { 11 | // CHECK: .loci:12:2: error: cannot access static method 'method' for value of type 'TestClass' 12 | TestClass().method(); 13 | } 14 | 15 | // CHECK: 1 error generated. 16 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Class/InternalConstructInNonMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export int function() { 5 | // CHECK: .loci:6:9: error: cannot call internal constructor in non-method 6 | return @(); 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Class/InternalConstructInNonStaticMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | class TestClass() { 4 | TestClass method() { 5 | return @(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Class/InternalConstructInStaticMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | class TestClass() { 4 | static TestClass method() { 5 | return @(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Class/MemberVarInStaticMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass(int value) { 5 | static void method() { 6 | // CHECK: .loci:7:3: error: cannot access 'self' in static method 7 | @value = 100; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Class/MultipleDestructors.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass(int value) { 5 | static Create = default; 6 | 7 | ~ { } 8 | 9 | // CHECK: .loci:10:2: error: destructor method clashes with previous destructor method 10 | ~ { } 11 | } 12 | 13 | // CHECK: 1 error generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Class/OverloadedMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // Loci doesn't support method overloading, 5 | // so the two methods clash since they share 6 | // the same name. 7 | class TestClass() { 8 | void doSomething(unused int i) { } 9 | 10 | // CHECK: .loci:11:7: error: method 'doSomething' clashes with previous method of the same name 11 | void doSomething(unused float f) { } 12 | } 13 | 14 | // CHECK: 1 error generated. 15 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Class/SelfInNonMethodFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | void function() { 5 | // CHECK: .loci:6:16: error: cannot access 'self' in non-method function 6 | unused_result self; 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Class/SelfInStaticMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass(int value) { 5 | static void method() { 6 | // CHECK: .loci:7:3: error: cannot access 'self' in static method 7 | self.doSomething(); 8 | } 9 | 10 | void doSomething() { } 11 | } 12 | 13 | // CHECK: 1 error generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Class/StaticNonMethodFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:1: warning: non-method function 'f' cannot be static 5 | export static void f() { } 6 | 7 | // CHECK: 1 warning generated. 8 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Class/ThisInNonMethodFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | void function() { 5 | // CHECK: .loci:6:16: error: cannot access 'this' in non-method function 6 | unused_result this; 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Class/ThisInStaticMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass(int value) { 5 | static void method() { 6 | // CHECK: .loci:7:3: error: cannot access 'this' in static method 7 | this->doSomething(); 8 | } 9 | 10 | void doSomething() { } 11 | } 12 | 13 | // CHECK: 1 error generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Const/ConstClassMember.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass(int value) { } 5 | 6 | static assert movable; 7 | 8 | // Class members can't (or at least, shouldn't) 9 | // be const since this affects the movability 10 | // of the object. 11 | class ConstTestClass(const int value) { } 12 | 13 | // CHECK: .loci:14:15: error: static assert predicate evaluates to false 14 | static assert movable; 15 | 16 | // CHECK: 1 error generated. 17 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Const/ConstDatatypeIsCopyable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | require(implicit_copyable) 5 | class CheckIsCopyable() { } 6 | 7 | datatype Data(int value); 8 | 9 | import CheckIsCopyable checkMutableDataIsCopyable(); 10 | import CheckIsCopyable checkConstDataIsCopyable(); 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Const/ConstFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:17: warning: non-method function 'f' cannot have const specifier 5 | export void f() const { } 6 | 7 | // CHECK: 1 warning generated. 8 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Const/ConstIntIsCopyable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | require(implicit_copyable) 5 | class CheckIsCopyable() { } 6 | 7 | import CheckIsCopyable checkMutableIntIsCopyable(); 8 | import CheckIsCopyable checkConstIntIsCopyable(); 9 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Const/ConstPointerIsCopyable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | require(implicit_copyable) 5 | class CheckIsCopyable() { } 6 | 7 | import CheckIsCopyable checkMutablePointerIsCopyable(); 8 | import CheckIsCopyable checkConstPointerIsCopyable(); 9 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Const/ConstStaticMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:24: warning: static method cannot have const predicate 6 | static void doThing() const { } 7 | } 8 | 9 | // CHECK: 1 warning generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Const/ModifyInsideConstMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass(int value) { 5 | static create = default; 6 | 7 | void modifyNonConst() { 8 | @value = 100; 9 | } 10 | 11 | void modifyConst() const { 12 | // CHECK: .loci:13:3: error: cannot assign non-movable type 'const(int_t)' 13 | @value = 100; 14 | } 15 | } 16 | 17 | // CHECK: 1 error generated. 18 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Const/ModifyInsideOverrideConstMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | class TestClass(__override_const int value) { 4 | static create = default; 5 | 6 | void modify() const { 7 | @value = 100; 8 | } 9 | } 10 | 11 | // Entry point. 12 | export int main(unused int argc, unused ubyte ** argv) { 13 | const TestClass object = TestClass(10); 14 | object.modify(); 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Const/SelfConstConstObject.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass(int value) { 5 | static create = default; 6 | 7 | selfconst(int)& get() const { 8 | return @value; 9 | } 10 | } 11 | 12 | export int f(const TestClass object) { 13 | // CHECK: .loci:14:2: error: cannot assign non-movable type 'const(int_t)' 14 | object.get() = 20; 15 | return object.get(); 16 | } 17 | 18 | // CHECK: 1 error generated. 19 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Const/SelfConstDynamicDispatch.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | class ArrayType(int[10] value) { 4 | static create = default; 5 | 6 | selfconst(int)& index(size_t index) const noexcept { 7 | return @value[index]; 8 | } 9 | } 10 | 11 | interface ArrayAPI { 12 | selfconst(int)& index(size_t index) const; 13 | } 14 | 15 | export ArrayAPI& nonConstToNonConst(ArrayType& object) { 16 | return object; 17 | } 18 | 19 | export const ArrayAPI& constToConst(const ArrayType& object) { 20 | return object; 21 | } 22 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Const/SelfConstInvalidContext.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | bool f() { 5 | // CHECK: .loci:6:9: error: cannot use 'selfconst' in non-method function 6 | return selfconst; 7 | } 8 | 9 | class TestClass() { 10 | static bool get() { 11 | // CHECK: .loci:12:10: error: cannot use 'selfconst' in static method 12 | return selfconst; 13 | } 14 | } 15 | 16 | // CHECK: 2 errors generated. 17 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Const/SelfConstNonConstObject.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | class TestClass(int value) { 4 | static create = default; 5 | 6 | selfconst(int)& get() const { 7 | return @value; 8 | } 9 | } 10 | 11 | export int f(TestClass object) { 12 | object.get() = 20; 13 | return object.get(); 14 | } 15 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Constants/DontTreatUnsignedConstantAsSigned.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export void varFunction() { 5 | // CHECK: .loci:6:2: error: user cast failed from type 'uint8_t' to type 'int_t' 6 | unused int value = 42u; 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Constants/EmptyArrayLiteral.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export int[0] f() { 5 | // CHECK: .loci:6:9: error: empty array literals not currently supported 6 | return {}; 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Constants/IntegerLiteralExceedsSpecifierMaximum.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export void varFunction() { 5 | // CHECK: .loci:6:23: error: integer literal exceeds maximum of specifier 'u8' 6 | unused auto value0 = 1000u8; 7 | 8 | // CHECK: .loci:9:24: error: integer literal exceeds maximum of specifier 'i8' 9 | unused auto value1 = -1000i8; 10 | } 11 | 12 | // CHECK: 2 errors generated. 13 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Constants/InvalidCharacterLiteralSpecifier.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export void varFunction() { 5 | // CHECK: .loci:6:23: error: invalid character literal specifier 'abc' 6 | unused auto value0 = 'a' abc; 7 | 8 | // CHECK: .loci:9:23: error: invalid character literal specifier 'abc' 9 | unused auto value1 = abc 'a'; 10 | } 11 | 12 | // CHECK: 2 errors generated. 13 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Constants/InvalidFloatingPointLiteralSpecifier.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export void varFunction() { 5 | // CHECK: .loci:6:23: error: invalid floating point literal specifier 'abc' 6 | unused auto value0 = 1.0abc; 7 | 8 | // CHECK: .loci:9:23: error: invalid floating point literal specifier 'abc' 9 | unused auto value1 = abc 1.0; 10 | } 11 | 12 | // CHECK: 2 errors generated. 13 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Constants/InvalidIntegerLiteralSpecifier.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export void varFunction() { 5 | // CHECK: .loci:6:23: error: invalid literal specifier 'u13' 6 | unused auto value0 = 42u13; 7 | 8 | // CHECK: .loci:9:24: error: invalid literal specifier 'i13' 9 | unused auto value1 = -42i13; 10 | } 11 | 12 | // CHECK: 2 errors generated. 13 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Constants/InvalidStringLiteralSpecifier.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export void varFunction() { 5 | // CHECK: .loci:6:23: error: cannot find function 'string_literal_abc' for string literal specifier 'abc' 6 | unused auto value0 = "string"abc; 7 | 8 | // CHECK: .loci:9:23: error: cannot find function 'string_literal_abc' for string literal specifier 'abc' 9 | unused auto value1 = abc"string"; 10 | } 11 | 12 | // CHECK: 2 errors generated. 13 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Constants/NonMatchingTypesInArrayLiteral.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export int8_t[2] f() { 5 | // CHECK: .loci:6:9: error: array literal element types 'int8_t' and 'double_t' do not match 6 | return { 2, 2.0 }; 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Constants/TreatSignedConstantAsUnsigned.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | export void varFunction() { 4 | unused unsigned int value = 42; 5 | } 6 | 7 | export unsigned int returnFunction() { 8 | return 42; 9 | } 10 | 11 | import void callee(unsigned int value); 12 | 13 | export void callFunction() { 14 | callee(42); 15 | } 16 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Constants/TreatSignedConstantAsUnsignedBindRefCast.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | // XFAIL: * 3 | 4 | import void callee(const unsigned int& value); 5 | 6 | export void callFunction() { 7 | callee(42); 8 | } 9 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Constants/UnicharLiteral.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | export void f() { 4 | // Test that character literal has the correct type. 5 | unused unichar a = 'a'; 6 | } 7 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/DeadCode/DeadCodeAfterBreak.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | void function() { 5 | while (true) { 6 | break; 7 | // CHECK: .loci:8:3: warning: code will never be executed 8 | unused int i = 10; 9 | // CHECK: .loci:10:3: warning: code will never be executed 10 | unused int j = 10; 11 | } 12 | } 13 | 14 | // CHECK: 2 warnings generated. 15 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/DeadCode/DeadCodeAfterContinue.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | void function() { 5 | while (true) { 6 | continue; 7 | // CHECK: .loci:8:3: warning: code will never be executed 8 | unused int i = 10; 9 | // CHECK: .loci:10:3: warning: code will never be executed 10 | unused int j = 10; 11 | } 12 | } 13 | 14 | // CHECK: 2 warnings generated. 15 | 16 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/DeadCode/DeadCodeAfterReturn.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | int function() { 5 | return 10; 6 | // CHECK: .loci:7:2: warning: code will never be executed 7 | unused int i = 10; 8 | // CHECK: .loci:9:2: warning: code will never be executed 9 | unused int j = 10; 10 | } 11 | 12 | // CHECK: 2 warnings generated. 13 | 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/DeadCode/DeadCodeAfterThrow.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception TestError(); 5 | 6 | int function() { 7 | throw TestError(); 8 | // CHECK: .loci:9:2: warning: code will never be executed 9 | unused int i = 10; 10 | // CHECK: .loci:11:2: warning: code will never be executed 11 | unused int j = 10; 12 | } 13 | 14 | // CHECK: 2 warnings generated. 15 | 16 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/DeadCode/DeadCodeAfterUnreachable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | int function() { 5 | unreachable; 6 | // CHECK: .loci:7:2: warning: code will never be executed 7 | unused int i = 10; 8 | // CHECK: .loci:9:2: warning: code will never be executed 9 | unused int j = 10; 10 | } 11 | 12 | // CHECK: 2 warnings generated. 13 | 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/DeadCode/EarlyThenReturn.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // Entry point. 5 | export int testEntryPoint(unused int argc, unused ubyte ** argv) { 6 | if (true) { 7 | return 0; 8 | // CHECK: .loci:9:3: warning: code will never be executed 9 | if (true) { 10 | // ... 11 | } 12 | } 13 | return 0; 14 | } 15 | 16 | // CHECK: 1 warning generated. 17 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/DeadCode/ScopeSuccessAlwaysThrowDeadCode.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception TestError(); 5 | 6 | import void g(); 7 | 8 | void f() { 9 | { 10 | scope(success) { 11 | throw TestError(); 12 | } 13 | } 14 | // CHECK: .loci:15:2: warning: code will never be executed 15 | g(); 16 | } 17 | 18 | // CHECK: 1 warning generated. 19 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/DeadCode/ScopeSuccessBlockEarlierScopeSuccess.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception TestError(); 5 | 6 | void f() { 7 | // CHECK: .loci:8:2: warning: scope(success) will never be executed 8 | scope(success) { 9 | throw TestError(); 10 | } 11 | scope(success) { 12 | throw TestError(); 13 | } 14 | } 15 | 16 | // CHECK: 1 warning generated. 17 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/DeadCode/UnreachableScopeExit.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | void f() { 5 | // CHECK: .loci:6:2: warning: scope(exit) will never be executed 6 | scope(exit) { } 7 | unreachable; 8 | } 9 | 10 | // CHECK: 1 warning generated. 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/DeadCode/UnreachableScopeFailure.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | void f() { 5 | // CHECK: .loci:6:2: warning: scope(failure) will never be executed 6 | scope(failure) { } 7 | unreachable; 8 | } 9 | 10 | // CHECK: 1 warning generated. 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/DeadCode/UnreachableScopeSuccess.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | void f() { 5 | // CHECK: .loci:6:2: warning: scope(success) will never be executed 6 | scope(success) { } 7 | unreachable; 8 | } 9 | 10 | // CHECK: 1 warning generated. 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/DeadCode/WhileTrueDeadCode.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | // XFAIL: * 4 | 5 | int function() { 6 | while (true) { } 7 | 8 | // CHECK: .loci:9:2: warning: code will never be executed 9 | unused int i = 10; 10 | // CHECK: .loci:11:2: warning: code will never be executed 11 | unused int j = 10; 12 | } 13 | 14 | // CHECK: 2 warnings generated. 15 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Defaults/DefaultMethodMustBeStatic.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: default method 'TestClass::create' must be static 6 | create = default; 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Defaults/RequestDefaultCompareWithNonComparableMembers.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // Not comparable. 6 | } 7 | 8 | class ComparableClass(TestClass member) { 9 | // CHECK: .loci:10:2: error: cannot generate compare since members don't support it 10 | compare = default; 11 | } 12 | 13 | // CHECK: 1 error generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Defaults/RequestDefaultExplicitCopyWithNonCopyableMembers.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // Not copyable. 6 | } 7 | 8 | class CopyableClass(TestClass member) { 9 | // CHECK: .loci:10:2: error: cannot generate copy since members don't support it 10 | copy = default; 11 | } 12 | 13 | // CHECK: 1 error generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Defaults/RequestDefaultImplicitCopyWithNonCopyableMembers.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // Not copyable. 6 | } 7 | 8 | class CopyableClass(TestClass member) { 9 | // CHECK: .loci:10:2: error: cannot generate implicit copy since members don't support it 10 | implicitcopy = default; 11 | } 12 | 13 | // CHECK: 1 error generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/AssertNoExcept.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | import int externalFunctionThatCouldThrow(int valueThatIfZeroPreventsThrowing); 4 | 5 | export int functionThatWillNotThrow() noexcept { 6 | assert noexcept { 7 | return externalFunctionThatCouldThrow(0); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/AssertNoExceptAroundNoExcept.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | import void functionThatNeverThrows() noexcept; 5 | 6 | export void function() { 7 | // CHECK: .loci:8:2: warning: assert noexcept is around scope that is guaranteed to never throw anyway 8 | assert noexcept { 9 | functionThatNeverThrows(); 10 | } 11 | } 12 | 13 | // CHECK: 1 warning generated. 14 | 15 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/CircularInheritedException.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:1: error: exception type '::Exception1' inherits itself via a circular dependency 5 | exception Exception1(int value) : Exception2(value); 6 | // CHECK: .loci:7:1: error: exception type '::Exception2' inherits itself via a circular dependency 7 | exception Exception2(int value) : Exception1(value); 8 | 9 | // CHECK: 2 errors generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/ExceptionParentTypeNotException.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { static create = default; } 5 | 6 | // CHECK: .loci:7:25: error: 'Exception' cannot inherit from non-exception type 'TestClass' 7 | exception Exception() : TestClass(); 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/RethrowInsideScopeExit.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception ExampleError(int value); 5 | 6 | // Entry point. 7 | export int testEntryPoint(unused int argc, unused ubyte ** argv) { 8 | try { 9 | throw ExampleError(1024); 10 | } catch (ExampleError error1) { 11 | scope (exit) { 12 | // CHECK: .loci:13:4: error: cannot re-throw caught exception inside scope(exit) 13 | throw; 14 | } 15 | } 16 | return 0; 17 | } 18 | 19 | // CHECK: 1 error generated. 20 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/RethrowInsideScopeFailure.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception ExampleError(int value); 5 | 6 | // Entry point. 7 | export int testEntryPoint(unused int argc, unused ubyte ** argv) { 8 | try { 9 | throw ExampleError(1024); 10 | } catch (ExampleError error1) { 11 | scope (failure) { 12 | // CHECK: .loci:13:4: error: cannot re-throw caught exception inside scope(failure) 13 | throw; 14 | } 15 | throw; 16 | } 17 | } 18 | 19 | // CHECK: 1 error generated. 20 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/RethrowInsideScopeSuccess.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | exception ExampleError(int value); 4 | 5 | // Entry point. 6 | export int testEntryPoint(unused int argc, unused ubyte ** argv) { 7 | try { 8 | throw ExampleError(1024); 9 | } catch (ExampleError error1) { 10 | scope (success) { 11 | throw; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/RethrowOutsideCatch.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception ExampleError(int value); 5 | 6 | // Entry point. 7 | export int testEntryPoint(unused int argc, unused ubyte ** argv) { 8 | // CHECK: .loci:9:2: error: cannot re-throw exception outside of catch clause 9 | throw; 10 | } 11 | 12 | // CHECK: 1 error generated. 13 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/SelfInheritedException.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:1: error: exception type '::Exception' inherits itself via a circular dependency 5 | exception Exception(int value) : Exception(value); 6 | 7 | // Entry point. 8 | export int testEntryPoint(unused int argc, unused ubyte ** argv) { 9 | return 0; 10 | } 11 | 12 | // CHECK: 1 error generated. 13 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/ThrowInDestructor.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception TestError(); 5 | 6 | class TestClass() { 7 | // CHECK: .loci:8:2: error: function '::TestClass::__destroy' is declared as 'noexcept' but can throw 8 | ~ { 9 | throw TestError(); 10 | } 11 | } 12 | 13 | // CHECK: 1 error generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/ThrowInNoExcept.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception ExampleError(int value); 5 | 6 | // CHECK: .loci:7:17: error: function '::function' is declared as 'noexcept' but can throw 7 | void function() noexcept { 8 | throw ExampleError(1); 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/ThrowInNoExceptIndirectly.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception ExampleError(int value); 5 | 6 | void functionThatThrows() { 7 | throw ExampleError(1); 8 | } 9 | 10 | // CHECK: .loci:11:17: error: function '::function' is declared as 'noexcept' but can throw 11 | void function() noexcept { 12 | functionThatThrows(); 13 | } 14 | 15 | // CHECK: 1 error generated. 16 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/ThrowInNoExceptViaOperator.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception ExampleError(int value); 5 | 6 | class TestClass (int value) { 7 | static create = default; 8 | 9 | int add(unused int value) { 10 | throw ExampleError(1); 11 | } 12 | } 13 | 14 | // CHECK: .loci:15:17: error: function '::function' is declared as 'noexcept' but can throw 15 | void function() noexcept { 16 | unused_result(TestClass(1) + 1); 17 | } 18 | 19 | // CHECK: 1 error generated. 20 | 21 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/ThrowInsideAssertNoExceptInsideScopeExit.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception ExampleError(); 5 | 6 | // Entry point. 7 | export int testEntryPoint(unused int argc, unused ubyte ** argv) { 8 | scope (exit) { 9 | assert noexcept { 10 | // CHECK: .loci:11:4: warning: throw statement means assert noexcept is guaranteed to throw 11 | throw ExampleError(); 12 | } 13 | } 14 | return 0; 15 | } 16 | 17 | // CHECK: 1 warning generated. 18 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/ThrowInsideScopeExit.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception ExampleError(); 5 | 6 | // Entry point. 7 | export int testEntryPoint(unused int argc, unused ubyte ** argv) { 8 | // CHECK: .loci:9:2: error: scope(exit) can throw 9 | scope (exit) { 10 | // CHECK: .loci:11:3: error: cannot throw exception inside scope(exit) 11 | throw ExampleError(); 12 | } 13 | return 0; 14 | } 15 | 16 | // CHECK: 2 errors generated. 17 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/ThrowInsideScopeFailure.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception ExampleError(); 5 | 6 | // Entry point. 7 | export int testEntryPoint(unused int argc, unused ubyte ** argv) { 8 | // CHECK: .loci:9:2: error: scope(failure) can throw 9 | scope (failure) { 10 | // CHECK: .loci:11:3: error: cannot throw exception inside scope(failure) 11 | throw ExampleError(); 12 | } 13 | throw ExampleError(); 14 | } 15 | 16 | // CHECK: 2 errors generated. 17 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/ThrowInsideScopeSuccess.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | exception ExampleError(); 4 | 5 | // Entry point. 6 | export int testEntryPoint(unused int argc, unused ubyte ** argv) { 7 | scope (success) { 8 | throw ExampleError(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/ThrowNonExceptionValue.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | datatype TestDatatype(); 5 | 6 | export void f() { 7 | // CHECK: .loci:8:2: error: cannot throw non-exception value of type 'TestDatatype' 8 | throw TestDatatype(); 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Exceptions/TryWrapsNonThrowingBlock.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception ExampleError(); 5 | 6 | import void f() noexcept; 7 | 8 | export void g() { 9 | // CHECK: .loci:10:2: warning: try statement wraps scope that cannot throw 10 | try { 11 | f(); 12 | } catch(unused ExampleError error) { } 13 | } 14 | 15 | // CHECK: 1 warning generated. 16 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/ExtensionMethods/ParentOfExtensionMethodIsNotAType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | void TestClass() { } 5 | 6 | // CHECK: .loci:7:6: error: parent 'TestClass' of extension method 'method' is not a type 7 | void TestClass::method() { } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/ExtensionMethods/UnknownParentTypeOfExtensionMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:6: error: unknown parent type 'TestClass' of extension method 'method' 5 | void TestClass::method() { } 6 | 7 | // CHECK: 1 error generated. 8 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Inherit/InheritOneMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class Parent() { 5 | void method() { } 6 | } 7 | 8 | // CHECK: .loci:9:13: error: inheritance not currently implemented 9 | class Child(inherit Parent parent) { } 10 | 11 | void function(Child& child) { 12 | child.method(); 13 | } 14 | 15 | // CHECK: 1 error generated. 16 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Inherit/OverrideOneMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class Parent() { 5 | void method() { } 6 | } 7 | 8 | // CHECK: .loci:9:13: error: inheritance not currently implemented 9 | class Child(inherit Parent parent) { 10 | // CHECK: .loci:11:16: error: 'override' not currently implemented 11 | void method() override { } 12 | } 13 | 14 | void function(Child& child) { 15 | child.method(); 16 | } 17 | 18 | // CHECK: 2 errors generated. 19 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Interface/InterfaceNameReference.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | interface TestInterface { } 5 | 6 | export typename_t f() { 7 | // CHECK: .loci:8:2: error: Can't implicitly cast value of type 'abstracttypename_t' to type 'typename_t'. 8 | return TestInterface; 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidArgumentCountAlignMask.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__alignmask' has incorrect argument count 6 | static size_t __alignmask(unused int i) noexcept { 7 | return 1; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidArgumentCountDestroy.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__destroy' has incorrect argument count 6 | void __destroy(unused int i) noexcept { } 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidArgumentCountIsLive.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__islive' has incorrect argument count 6 | bool __islive(unused int i) const noexcept { 7 | return true; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidArgumentCountIsValid.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__isvalid' has incorrect argument count 6 | bool __isvalid(unused int i) const noexcept { 7 | return true; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidArgumentCountMove.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__move' has incorrect argument count 6 | TestClass __move(unused int i) noexcept { 7 | return @(); 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidArgumentCountSetDead.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__setdead' has incorrect argument count 6 | void __setdead(unused int i) noexcept { } 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidArgumentCountSetInvalid.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__setinvalid' has incorrect argument count 6 | void __setinvalid(unused int i) noexcept { } 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidArgumentCountSizeOf.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__sizeof' has incorrect argument count 6 | static size_t __sizeof(unused int i) noexcept { 7 | return 1; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidConstnessDestroy.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__destroy' has incorrect const predicate 6 | void __destroy() const noexcept { } 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidConstnessIsLive.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__islive' has incorrect const predicate 6 | bool __islive() noexcept { 7 | return true; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidConstnessIsValid.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__isvalid' has incorrect const predicate 6 | bool __isvalid() noexcept { 7 | return true; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidConstnessMove.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__move' has incorrect const predicate 6 | TestClass __move() const noexcept { 7 | return @(); 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidConstnessSetDead.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__setdead' has incorrect const predicate 6 | void __setdead() const noexcept { } 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidConstnessSetInvalid.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__setinvalid' has incorrect const predicate 6 | void __setinvalid() const noexcept { } 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidDefaultLifetimeMethodName.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: unknown default method '__someinvalidlifetimemethod' 6 | __someinvalidlifetimemethod = default; 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidLifetimeMethodName.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: unknown lifetime method '__someinvalidlifetimemethod' 6 | void __someinvalidlifetimemethod() noexcept { } 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidReturnTypeAlignMask.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__alignmask' has incorrect return type 6 | static void __alignmask() noexcept { } 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidReturnTypeDestroy.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__destroy' has incorrect return type 6 | int __destroy() noexcept { 7 | return 0; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidReturnTypeIsLive.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__islive' has incorrect return type 6 | void __islive() const noexcept { } 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidReturnTypeIsValid.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__isvalid' has incorrect return type 6 | void __isvalid() const noexcept { } 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidReturnTypeMove.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__move' has incorrect return type 6 | int __move() noexcept { 7 | return 0; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidReturnTypeSetDead.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__setdead' has incorrect return type 6 | int __setdead() noexcept { 7 | return 0; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidReturnTypeSetInvalid.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__setinvalid' has incorrect return type 6 | int __setinvalid() noexcept { 7 | return 0; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidReturnTypeSizeOf.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__sizeof' has incorrect return type 6 | static void __sizeof() noexcept { } 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidStaticnessAlignMask.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__alignmask' should be static 6 | size_t __alignmask() noexcept { 7 | return 1; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidStaticnessDestroy.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__destroy' should not be static 6 | static void __destroy() noexcept { } 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidStaticnessIsLive.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__islive' should not be static 6 | static bool __islive() noexcept { 7 | return true; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidStaticnessIsValid.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__isvalid' should not be static 6 | static bool __isvalid() noexcept { 7 | return true; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidStaticnessMove.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__move' should not be static 6 | static TestClass __move() noexcept { 7 | return @(); 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidStaticnessSetDead.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__setdead' should not be static 6 | static void __setdead() noexcept { } 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidStaticnessSetInvalid.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__setinvalid' should not be static 6 | static void __setinvalid() noexcept { } 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/InvalidStaticnessSizeOf.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | // CHECK: .loci:6:2: error: lifetime method '::TestClass::__sizeof' should be static 6 | size_t __sizeof() noexcept { 7 | return 1; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/ThrowingAlignMask.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception TestError(); 5 | 6 | class TestClass() { 7 | // CHECK: .loci:9:2: error: lifetime method '::TestClass::__alignmask' isn't marked 'noexcept' 8 | // CHECK: .loci:9:30: error: function '::TestClass::__alignmask' is declared as 'noexcept' but can throw 9 | static size_t __alignmask() { 10 | throw TestError(); 11 | } 12 | } 13 | 14 | // CHECK: 2 errors generated. 15 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/ThrowingIsLive.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception TestError(); 5 | 6 | class TestClass() { 7 | // CHECK: .loci:9:2: error: lifetime method '::TestClass::__islive' isn't marked 'noexcept' 8 | // CHECK: .loci:9:24: error: function '::TestClass::__islive' is declared as 'noexcept' but can throw 9 | bool __islive() const { 10 | throw TestError(); 11 | } 12 | } 13 | 14 | // CHECK: 2 errors generated. 15 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/ThrowingIsValid.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception TestError(); 5 | 6 | class TestClass() { 7 | // CHECK: .loci:9:2: error: lifetime method '::TestClass::__isvalid' isn't marked 'noexcept' 8 | // CHECK: .loci:9:25: error: function '::TestClass::__isvalid' is declared as 'noexcept' but can throw 9 | bool __isvalid() const { 10 | throw TestError(); 11 | } 12 | } 13 | 14 | // CHECK: 2 errors generated. 15 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/ThrowingMove.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception TestError(); 5 | 6 | class TestClass() { 7 | // CHECK: .loci:9:2: error: lifetime method '::TestClass::__move' isn't marked 'noexcept' 8 | // CHECK: .loci:9:21: error: function '::TestClass::__move' is declared as 'noexcept' but can throw 9 | TestClass __move() { 10 | throw TestError(); 11 | } 12 | } 13 | 14 | // CHECK: 2 errors generated. 15 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/ThrowingSetDead.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception TestError(); 5 | 6 | class TestClass() { 7 | // CHECK: .loci:9:2: error: lifetime method '::TestClass::__setdead' isn't marked 'noexcept' 8 | // CHECK: .loci:9:19: error: function '::TestClass::__setdead' is declared as 'noexcept' but can throw 9 | void __setdead() { 10 | throw TestError(); 11 | } 12 | } 13 | 14 | // CHECK: 2 errors generated. 15 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/ThrowingSetInvalid.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception TestError(); 5 | 6 | class TestClass() { 7 | // CHECK: .loci:9:2: error: lifetime method '::TestClass::__setinvalid' isn't marked 'noexcept' 8 | // CHECK: .loci:9:22: error: function '::TestClass::__setinvalid' is declared as 'noexcept' but can throw 9 | void __setinvalid() { 10 | throw TestError(); 11 | } 12 | } 13 | 14 | // CHECK: 2 errors generated. 15 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/LifetimeMethods/ThrowingSizeOf.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | exception TestError(); 5 | 6 | class TestClass() { 7 | // CHECK: .loci:9:2: error: lifetime method '::TestClass::__sizeof' isn't marked 'noexcept' 8 | // CHECK: .loci:9:27: error: function '::TestClass::__sizeof' is declared as 'noexcept' but can throw 9 | static size_t __sizeof() { 10 | throw TestError(); 11 | } 12 | } 13 | 14 | // CHECK: 2 errors generated. 15 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Loop/BreakOutOfFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | void function() { 5 | // CHECK: .loci:6:2: error: 'break' statement not in loop statement 6 | break; 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Loop/ContinueOutOfFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | void function() { 5 | // CHECK: .loci:6:2: error: 'continue' statement not in loop statement 6 | continue; 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/ExportedClass.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export a.b.c 1.2.3 { 5 | // CHECK: .loci:6:2: error: definition required for exported class 'Decl' 6 | class Decl { } 7 | 8 | class Def () { } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/ExportedFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export a.b.c 1.2.3 { 5 | // CHECK: .loci:6:2: error: definition required for exported function 'decl' 6 | void decl(); 7 | 8 | void def() { } 9 | } 10 | 11 | // CHECK: .loci:12:1: error: definition required for exported function 'exportedDecl' 12 | export void exportedDecl(); 13 | 14 | export void exportedDef() { } 15 | 16 | // CHECK: 2 errors generated. 17 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/ExportedTemplateFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | template 5 | export void f() { } 6 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/ExportedTemplateFunctionWithRequire.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | template 5 | require(movable) 6 | export void f() { } 7 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/ImportedClass.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | import a.b.c 1.2.3 { 5 | class Decl { } 6 | 7 | // CHECK: .loci:8:2: error: cannot define imported class 'Def' 8 | class Def() { } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/ImportedFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | import a.b.c 1.2.3 { 5 | void decl(); 6 | 7 | // CHECK: .loci:8:2: error: cannot define imported function 'def' 8 | void def() { } 9 | } 10 | 11 | import void importedDecl(); 12 | 13 | // CHECK: .loci:14:1: error: cannot define imported function 'importedDef' 14 | import void importedDef() { } 15 | 16 | // CHECK: 2 errors generated. 17 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/ImportedTemplateFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | template 5 | import void f(); 6 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/ImportedTemplateFunctionWithRequire.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | template 5 | require(movable) 6 | import void f(); 7 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/InternalClass.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:1: error: definition required for internal class 'Decl' 5 | class Decl { } 6 | 7 | class Def() { } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/InternalFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:1: error: definition required for internal function 'decl' 5 | void decl(); 6 | 7 | void def() { } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/NameExportedFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | export a.b.c 1.0.0 { 5 | 6 | void f() { } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/NameExportedTemplateFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | export a.b.c 1.0.0 { 5 | 6 | template 7 | void f() { } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/NameExportedTemplateFunctionWithRequire.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | export a.b.c 1.0.0 { 5 | 6 | template 7 | require(movable) 8 | void f() { } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/NameImportedFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | import a.b.c 1.0.0 { 5 | 6 | void f(); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/NameImportedTemplateFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | import a.b.c 1.0.0 { 5 | 6 | template 7 | void f(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Module/NameImportedTemplateFunctionWithRequire.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | import a.b.c 1.0.0 { 5 | 6 | template 7 | require(movable) 8 | void f(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Names/DuplicateAliasTemplateVar.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:23: error: template variable 'T' clashes with existing name 5 | template 6 | using TestAlias = T; 7 | 8 | // CHECK: 1 error generated. 9 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Names/DuplicateEnumConstructor.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | enum TestEnum { 5 | // CHECK: .loci:6:2: error: enum constructor 'TestEnum::VALUE' clashes with existing name 6 | VALUE, 7 | VALUE 8 | }; 9 | 10 | // CHECK: 1 error generated. 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Names/DuplicateFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | void function() { } 5 | 6 | // CHECK: .loci:7:6: error: function 'function' clashes with existing name 7 | void function() { } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Names/DuplicateLocalVar.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | int function() { 5 | int value = 1; 6 | 7 | // CHECK: .loci:9:2: error: variable 'value' duplicates existing variable 8 | // CHECK: .loci:5:2: note: because: variable previously defined here 9 | int value = 2; 10 | return value; 11 | } 12 | 13 | // CHECK: 1 error generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Names/DuplicateParamVar.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:6:25: error: variable 'value' duplicates existing variable 5 | // CHECK: .loci:6:14: note: because: variable previously defined here 6 | int function(int value, int value) { 7 | return value; 8 | } 9 | 10 | // CHECK: 1 error generated. 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Names/ReferToNonStaticMethodDirectly.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | void method() { } 6 | } 7 | 8 | export void f() { 9 | // CHECK: .loci:10:2: error: use of undeclared identifier 'TestClass::method' 10 | TestClass::method(); 11 | 12 | // CHECK: .loci:13:2: error: cannot call non-static method 'method' for type 'TestClass' 13 | TestClass.method(); 14 | } 15 | 16 | // CHECK: 3 errors generated. 17 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Names/UnknownMemberVariable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | int method() { 6 | // CHECK: .loci:7:10: error: cannot find member variable '@value' 7 | return @value; 8 | } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Names/UnknownTypeName.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:8: error: unknown type name 'Type' 5 | import Type f(); 6 | 7 | // CHECK: .loci:8:8: error: unknown type name 'Namespace::Type' 8 | import Namespace::Type g(); 9 | 10 | // CHECK: 2 errors generated. 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Names/UnknownValueName.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | int function() { 5 | // CHECK: .loci:6:9: error: use of undeclared identifier 'value' 6 | return value; 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Namespace/NamespaceTemplateArgs.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | namespace Namespace { 5 | void f() { } 6 | } 7 | 8 | export void f() { 9 | // CHECK: .loci:10:2: error: 1 template arguments provided for non-function and non-type node 'Namespace'; none should be provided 10 | Namespace::f(); 11 | } 12 | 13 | // CHECK: 1 error generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/PatternMatch/PatternMatchMemberVar.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | datatype UserType(int variable); 5 | 6 | // CHECK: .loci:10:17: error: pattern variables not supported for member variables 7 | 8 | // Use an invalid type name to check we're still converting the variable. 9 | // CHECK: .loci:10:26: error: unknown type name 'invalid_type' 10 | class TestClass(UserType(invalid_type v)) { } 11 | 12 | // CHECK: 2 errors generated. 13 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/PatternMatch/PatternMatchParameter.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | datatype UserType(); 5 | 6 | // CHECK: .loci:7:15: error: pattern matching not supported for parameter variables 7 | export void f(UserType()) { } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/PatternMatch/PatternMatchSwitchAny.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | datatype ParentType = ChildType0() | ChildType1(int value); 5 | 6 | import ParentType g(); 7 | 8 | export void f() { 9 | switch (g()) { 10 | case ChildType0() { } 11 | // CHECK: .loci:12:19: error: 'any' vars not implemented for uninitialised variables 12 | case ChildType1(_) { } 13 | } 14 | } 15 | 16 | // CHECK: 1 error generated. 17 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/PolymorphicCast/PolyCastClassToInterface.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | import { 4 | 5 | class TestClass { 6 | void method(); 7 | } 8 | 9 | } 10 | 11 | interface TestInterface { 12 | void method(); 13 | } 14 | 15 | export TestInterface& f(TestClass& value) { 16 | return value; 17 | } 18 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/PolymorphicCast/PolyCastTemplateVarToInterface.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | interface TestInterface { 4 | void method(); 5 | } 6 | 7 | template 8 | export TestInterface& f(T& value) { 9 | return value; 10 | } 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/PolymorphicCast/PolyCastTemplatedClassToInterface.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | import { 4 | 5 | template 6 | class TestClass { 7 | int method(); 8 | } 9 | 10 | } 11 | 12 | interface TestInterface { 13 | int method(); 14 | } 15 | 16 | export TestInterface& f(TestClass& value) { 17 | return value; 18 | } 19 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Predicates/AliasNonBoolPredicateTypedTemplateVariable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | interface TestInterface { 5 | void method(); 6 | } 7 | 8 | template 9 | using TestPredicate = T; 10 | 11 | // CHECK: .loci:12:11: error: alias 'TestPredicate' has non-boolean type 'typename_t' and therefore cannot be used in predicate 12 | template 13 | using Test = T; 14 | 15 | // CHECK: 1 error generated. 16 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Predicates/AliasPredicateTypedTemplateVariable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | interface TestInterface { 4 | void method(); 5 | } 6 | 7 | template 8 | using TestPredicate = T : TestInterface; 9 | 10 | template 11 | using Test = T; 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Predicates/FunctionNameInPredicate.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:18: error: symbol 'g' cannot be used in predicate 5 | void f() require(g) { } 6 | 7 | void g() { } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Predicates/FunctionPredicateTypedTemplateVariable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | interface TestInterface { 4 | void method(); 5 | } 6 | 7 | template 8 | using TestPredicate = T : TestInterface; 9 | 10 | template 11 | export void f(T& object) { 12 | object.method(); 13 | } 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Predicates/NonBoolAliasInPredicate.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | using Alias = 10; 5 | 6 | // CHECK: .loci:7:18: error: alias 'Alias' has non-boolean type 'int8_t' and therefore cannot be used in predicate 7 | void f() require(Alias) { } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Predicates/NonBoolTemplateVarInPredicate.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | template 5 | // CHECK: .loci:6:18: error: template variable 'T' has non-boolean type 'int_t' and therefore cannot be used in predicate 6 | void f() require(T) { } 7 | 8 | // CHECK: 1 error generated. 9 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Predicates/TypeInstancePredicateTypedTemplateVariable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | interface TestInterface { 4 | void method(); 5 | } 6 | 7 | template 8 | using TestPredicate = T : TestInterface; 9 | 10 | template 11 | class TestClass() { 12 | void method(T& object) { 13 | object.method(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Predicates/UnknownNameInPredicate.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:18: error: unknown symbol 'Unknown' cannot be used in predicate 5 | void f() require(Unknown) { } 6 | 7 | // CHECK: 1 error generated. 8 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Return/MissingReturnStatement.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:16: error: control reaches end of function 'f' with non-void return type; it needs a return statement 5 | export int f() { } 6 | 7 | // CHECK-NOT: .loci:8:17: error: control reaches end of function 'g' with non-void return type; it needs a return statement 8 | export void g() { } 9 | 10 | // CHECK: 1 error generated. 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Return/ReturnInScopeAction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | import void g(); 5 | 6 | export int f() { 7 | scope (exit) { 8 | // CHECK: .loci:9:3: error: cannot return in scope action 9 | return 1; 10 | } 11 | scope (success) { 12 | // CHECK: .loci:13:3: error: cannot return in scope action 13 | return 2; 14 | } 15 | scope (failure) { 16 | // CHECK: .loci:17:3: error: cannot return in scope action 17 | return 3; 18 | } 19 | g(); 20 | } 21 | 22 | // CHECK: 3 errors generated. 23 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Return/ReturnNonVoidInVoidFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export void f() { 5 | // CHECK: .loci:6:2: error: cannot return non-void value in function 'f' with void return type 6 | return 42; 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Return/ReturnVoidInNonVoidFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export int f() { 5 | // CHECK: .loci:6:2: error: cannot return void in function 'f' with non-void return type 6 | return; 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Return/ReturnVoidValueInNonVoidFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | import void g(); 5 | 6 | export int f() { 7 | // CHECK: .loci:8:2: error: cannot return void in function 'f' with non-void return type 8 | return g(); 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/ScopeExit/InvalidScopeExitState.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export void function() { 5 | // CHECK: .loci:6:2: error: invalid scope exit state 'nonexistent' 6 | scope (nonexistent) { 7 | // Verify the scope is still being converted. 8 | // CHECK: .loci:9:17: error: use of undeclared identifier 'varThatDoesNotExist' 9 | unused_result varThatDoesNotExist; 10 | } 11 | } 12 | 13 | // CHECK: 2 errors generated. 14 | 15 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Shadowing/FunctionShadowFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | void function() { } 4 | 5 | namespace Namespace { 6 | 7 | void function() { } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Shadowing/ParamVariableShadowFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | void testValue() { } 4 | 5 | void function(unused int testValue) { } 6 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Shadowing/ParamVariableShadowType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | class testValue() { } 4 | 5 | void function(unused int testValue) { } 6 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Shadowing/VariableShadowFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | void testValue() { } 4 | 5 | void function() { 6 | unused int testValue = 4; 7 | } 8 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Shadowing/VariableShadowType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | class testValue() { } 4 | 5 | void function() { 6 | unused int testValue = 4; 7 | } 8 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/SizeOf/AlignMaskTemplateRequirement.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | class TestClass() { } 4 | 5 | interface HasAlignMask { 6 | static size_t __alignmask() noexcept; 7 | } 8 | 9 | template 10 | size_t getAlignOf() { 11 | return alignof(T); 12 | } 13 | 14 | template 15 | size_t getAlignMask() { 16 | return T.__alignmask(); 17 | } 18 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/SizeOf/AlignOfMovableTemplateType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | size_t getTypeAlign() { 5 | return alignof(T); 6 | } 7 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/SizeOf/SizeOfMovableTemplateType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | size_t getTypeSize() { 5 | return sizeof(T); 6 | } 7 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/StaticArray/StaticArrayCopy.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | export int[4] copyValueFunction(int[4]& value) { 4 | return value.copy(); 5 | } 6 | 7 | export int[4] copyRefFunction(const(int[4])& value) { 8 | return value.copy(); 9 | } 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/StaticArray/StaticArrayImplicitCopy.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | export int[4] implicitCopyValueFunction(int[4] value) { 4 | return value; 5 | } 6 | 7 | export int[4] implicitCopyRefFunction(const(int[4])& value) { 8 | return value; 9 | } 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/StaticArray/StaticArrayLiteralLvalueAndRvalue.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | // XFAIL: * 3 | 4 | int[4] function(int value) { 5 | return { 0, value, 1, 2 }; 6 | } 7 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Struct/OpaqueStructDerefPointer.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | struct OpaqueStruct; 4 | 5 | OpaqueStruct& derefPointer(OpaqueStruct* value) { 6 | return *value; 7 | } 8 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Struct/OpaqueStructPassPointer.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | struct OpaqueStruct; 4 | 5 | OpaqueStruct* pass(OpaqueStruct* value) { 6 | return value; 7 | } 8 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Switch/DuplicateSwitchCase.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | datatype Data = A() | B(); 5 | 6 | void doSwitch(Data data) { 7 | switch (move data) { 8 | case A() { } 9 | // CHECK: .loci:10:3: error: duplicate case for type 'A' 10 | case A() { } 11 | case B() { } 12 | } 13 | } 14 | 15 | // CHECK: 1 error generated. 16 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Switch/SwitchTemplateType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | template 5 | require(movable) 6 | void doSwitch(T data) { 7 | // CHECK: .loci:8:10: error: switch type 'T' is not an object 8 | switch (move data) { } 9 | } 10 | 11 | // CHECK: 1 error generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Switch/UnnecessaryDefaultCase.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | datatype Data = A() | B(); 5 | 6 | void doSwitch(Data data) { 7 | switch (move data) { 8 | case A() { } 9 | case B() { } 10 | // CHECK: .loci:11:3: warning: default case in switch which covers all possible cases 11 | default { } 12 | } 13 | } 14 | 15 | // CHECK: 1 warning generated. 16 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/TemplateArgumentDeduction/SingleArgumentGlobalFunction.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | // XFAIL: * 4 | 5 | template 6 | import T function(T value); 7 | 8 | class TestClass { 9 | static TestClass create(); 10 | } 11 | 12 | static assert typeof(function(TestClass())) == TestClass; 13 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Templates/ClassBoolTemplate.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | class C () { } 5 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Templates/ClassBoolTemplateConstPredicate.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | class C () { 5 | static create = default; 6 | 7 | bool get() const(V) { 8 | return true; 9 | } 10 | } 11 | 12 | bool f() { 13 | const auto value = C(); 14 | return value.get(); 15 | } 16 | 17 | bool g() { 18 | auto value = C(); 19 | return value.get(); 20 | } 21 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Templates/ClassBoolTemplateRequirePredicate.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | class C () { 5 | static create = default; 6 | 7 | bool get() const require(V) { 8 | return true; 9 | } 10 | } 11 | 12 | bool f() { 13 | const auto value = C(); 14 | return value.get(); 15 | } 16 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Templates/ClassBoolTemplateValue.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | class C () { } 5 | 6 | import C f(); 7 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Templates/ClassDuplicateTemplate.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | template 5 | // CHECK: .loci:4:23: error: declaration of 'T' shadows template parameter 6 | class TestClass() { } 7 | 8 | // CHECK: 1 error generated. 9 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Templates/ClassTypenameTemplate.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | class C () { } 5 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Templates/ClassTypenameTemplateValue.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | class C () { } 5 | 6 | import C f(); 7 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Templates/FunctionDuplicateTemplate.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | template 5 | // CHECK: .loci:4:23: error: declaration of 'T' shadows template parameter 6 | void function() { } 7 | 8 | // CHECK: 1 error generated. 9 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Templates/FunctionTemplate.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | template 5 | void f() { } 6 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Templates/FunctionTemplateNonPrimitiveType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class UserType() { } 5 | 6 | // CHECK: .loci:7:11: error: template variable 'T' has non-primitive type 'UserType' in function 'f' 7 | template 8 | void f() { } 9 | 10 | // CHECK: 1 error generated. 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Templates/FunctionTemplateRequireAfter.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | interface CanDoThing { 5 | void doThing(); 6 | } 7 | 8 | template 9 | void f(T& object) require(T : CanDoThing) { 10 | object.doThing(); 11 | } 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Templates/FunctionTemplateRequireBefore.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | 4 | interface CanDoThing { 5 | void doThing(); 6 | } 7 | 8 | template 9 | require(T : CanDoThing) 10 | void f(T& object) { 11 | object.doThing(); 12 | } 13 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Templates/InterfaceMethodTemplate.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // Loci doesn't allow interface methods to be templated 5 | // since that would be a second instantiation (and would 6 | // therefore not work with CodeGen's template generators). 7 | interface SomeInterface { 8 | // CHECK: .loci:9:2: error: interface method 'doSomething' cannot be templated 9 | template 10 | void doSomething(); 11 | } 12 | 13 | // CHECK: 1 error generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Templates/MethodDuplicateTemplate.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { 5 | template 6 | // CHECK: .loci:5:24: error: declaration of 'T' shadows template parameter 7 | void function() { } 8 | } 9 | 10 | // CHECK: 1 error generated. 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Templates/TemplateVarInvalidType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:11: error: unknown type name 'someunknowntypethatmustnotexist' 5 | template 6 | import T function(); 7 | 8 | // CHECK: 1 error generated. 9 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/TypeOf/TypeOfDeclaredReferenceRvalue.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | // XFAIL: * 4 | 5 | import int& function(); 6 | 7 | static assert typeof(function()) == int&; 8 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/TypeOf/TypeOfInVariableType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | // XFAIL: * 4 | 5 | export void function(int x) { 6 | typeof(x) y = x; 7 | static assert typeof(y) == int; 8 | } 9 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/TypeOf/TypeOfLvalue.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | // XFAIL: * 4 | 5 | export void function(int x) { 6 | static assert typeof(x) == int; 7 | } 8 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/TypeOf/TypeOfRvalue.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | // XFAIL: * 4 | 5 | import int function(); 6 | 7 | static assert typeof(function()) == int; 8 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Typename/InvalidTypenamePolyCast.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { } 5 | 6 | interface Interface { 7 | static void method(); 8 | } 9 | 10 | void function0(typename_t typeValue) { 11 | // CHECK: .loci:12:12: error: Can't implicitly cast value of type 'typename_t&' to type 'typename_t'. 12 | function1(typeValue); 13 | } 14 | 15 | void function1(unused typename_t typeValue) { } 16 | 17 | // CHECK: 1 error generated. 18 | 19 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Typename/InvalidTypenameTargetTypeCast.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { } 5 | 6 | class TestClass2() { } 7 | 8 | void function0(typename_t typeValue) { 9 | // CHECK: .loci:10:12: error: Can't implicitly cast value of type 'typename_t&' to type 'typename_t'. 10 | function1(typeValue); 11 | } 12 | 13 | void function1(unused typename_t typeValue) { } 14 | 15 | // CHECK: 1 error generated. 16 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Typename/InvalidTypenameTypeCast.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | class TestClass() { } 5 | 6 | void function0(typename_t typeValue) { 7 | // CHECK: .loci:8:12: error: Can't implicitly cast value of type 'typename_t&' to type 'int_t'. 8 | function1(typeValue); 9 | } 10 | 11 | void function1(unused int typeValue) { } 12 | 13 | // CHECK: 1 error generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Types/FunctionTypeVoidParameterType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:29: error: parameter type in function pointer type cannot be void 5 | using Type = (*)(void)(int, void); 6 | 7 | // CHECK: 1 error generated. 8 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Types/VariableVoidType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export void f() { 5 | // CHECK: .loci:6:9: error: variable 'value' cannot have void type 6 | unused void value = f(); 7 | } 8 | 9 | // CHECK: 1 error generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Unused/NonVoidNotExplicitlyIgnored.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | import int g(); 5 | 6 | export void f() { 7 | // CHECK: .loci:8:2: warning: non-void value result ignored in expression 8 | g(); 9 | // CHECK-NOT: .loci:10:2: warning: non-void value result ignored in expression 10 | unused_result g(); 11 | } 12 | 13 | // CHECK: 1 warning generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Unused/UnusedLocalVariable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export void function() { 5 | // CHECK: .loci:6:2: warning: unused variable 'localVariable' (which is not marked as 'unused') 6 | int localVariable = 0; 7 | 8 | unused int unusedLocalVariable = 0; 9 | } 10 | 11 | // CHECK: 1 warning generated. 12 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Unused/UnusedParameter.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:22: warning: unused parameter 'parameterVariable' (which is not marked as 'unused') 5 | export void function(int parameterVariable, unused int unusedParameterVariable) { } 6 | 7 | // CHECK: 1 warning generated. 8 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Unused/UnusedScopedLocalVariable.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export void function() { 5 | { 6 | // CHECK: .loci:7:3: warning: unused variable 'scopedLocalVariable' (which is not marked as 'unused') 7 | int scopedLocalVariable = 0; 8 | 9 | unused int unusedScopedLocalVariable = 0; 10 | } 11 | } 12 | 13 | // CHECK: 1 warning generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Unused/UsedLocalVariableMarkedUnused.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export int function() { 5 | // CHECK: .loci:6:9: warning: variable 'localVariable' is marked 'unused' but is used 6 | unused int localVariable = 0; 7 | return localVariable; 8 | } 9 | 10 | // CHECK: 1 warning generated. 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Unused/UsedParameterMarkedUnused.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // CHECK: .loci:5:28: warning: parameter 'parameterVariable' is marked 'unused' but is used 5 | export int function(unused int parameterVariable) { 6 | return parameterVariable; 7 | } 8 | 9 | // CHECK: 1 warning generated. 10 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Unused/UsedScopedLocalVariableMarkedUnused.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | export int function() { 5 | { 6 | // CHECK: .loci:7:10: warning: variable 'scopedLocalVariable' is marked 'unused' but is used 7 | unused int scopedLocalVariable = 0; 8 | return scopedLocalVariable; 9 | } 10 | } 11 | 12 | // CHECK: 1 warning generated. 13 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Unused/VoidExplicitlyIgnored.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | import void g(); 5 | 6 | export void f() { 7 | // CHECK-NOT: .loci:8:2: warning: void explicitly ignored in expression 8 | g(); 9 | // CHECK: .loci:10:2: warning: void explicitly ignored in expression 10 | unused_result g(); 11 | } 12 | 13 | // CHECK: 1 warning generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Variant/InvalidVariantCycle.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // Not yet implemented. 5 | // XFAIL: * 6 | 7 | datatype A(); 8 | 9 | // CHECK: .loci:8:17: type 'B' appears within itself via a cycle 10 | variant B = A | B; 11 | 12 | datatype C(D value); 13 | 14 | // CHECK: .loci:8:17: type 'D' appears within itself via a cycle 15 | variant D = A | C; 16 | 17 | // CHECK: 2 errors generated. 18 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Variant/InvalidVariantRepeatedType.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --verify > %t 2 | // RUN: FileCheck < %t %s 3 | 4 | // Not yet implemented. 5 | // XFAIL: * 6 | 7 | datatype A(); 8 | datatype B(); 9 | 10 | // CHECK: .loci:8:21: type 'A' appears multiple times in variant 'C' 11 | variant C = A | B | A; 12 | 13 | // CHECK: 1 error generated. 14 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Variant/TemplatedVariant.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | template 4 | variant C = A | B; 5 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Variant/VariantConditional.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | // Not yet implemented. 4 | // XFAIL: * 5 | 6 | datatype A(); 7 | datatype B(); 8 | variant C = A | B; 9 | 10 | export bool f(C value) { 11 | if (A a = value) { 12 | return true; 13 | } else { 14 | return false; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Variant/VariantDatatypeShortSyntax.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | datatype C = A() | B(); 4 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Variant/VariantSharedMethod.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | // Not yet implemented. 4 | // XFAIL: * 5 | 6 | class A() { 7 | void method() const { } 8 | } 9 | 10 | class B() { 11 | void method() const { } 12 | } 13 | 14 | variant C = A | B; 15 | 16 | export void f(const C& value) { 17 | value.method(); 18 | } 19 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Variant/VariantSwitch.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | datatype A(); 4 | datatype B(); 5 | variant C = A | B; 6 | 7 | export bool f(C value) { 8 | switch (value) { 9 | case A() { return true; } 10 | case B() { return false; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Variant/VariantTernary.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | datatype A(); 4 | datatype B(); 5 | variant C = A | B; 6 | 7 | export C f(bool cond) { 8 | auto value = cond ? A() : B(); 9 | return value; 10 | } 11 | -------------------------------------------------------------------------------- /test/SemanticAnalysis/Variant/VariantTrivialDefinition.loci: -------------------------------------------------------------------------------- 1 | // RUN: %locic %s --emit-llvm -o %t 2 | 3 | datatype A(); 4 | datatype B(); 5 | variant C = A | B; 6 | -------------------------------------------------------------------------------- /unittests/Lex/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Unit tests for 'Lex' library. 2 | 3 | add_unit_test(Lex 4 | CharacterLiteralLexTest.cpp 5 | CommentLexTest.cpp 6 | IdentifierLexTest.cpp 7 | NumericLexTest.cpp 8 | StringLiteralLexTest.cpp 9 | SymbolLexTest.cpp 10 | WhitespaceLexTest.cpp 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /unittests/Parser/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Unit tests for 'Parser' library. 2 | 3 | add_unit_test(Parser 4 | NamespaceParseTest.cpp 5 | StatementParseTest.cpp 6 | TypeInstanceParseTest.cpp 7 | TypeParseTest.cpp 8 | ValueParseTest.cpp 9 | VarParseTest.cpp 10 | ) 11 | 12 | -------------------------------------------------------------------------------- /unittests/Support/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Unit tests for 'Support' library. 2 | 3 | add_unit_test(Support 4 | ArrayTest.cpp 5 | OptionalTest.cpp 6 | StringTest.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /unittests/TestMain.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | int main(int argc, char **argv) { 4 | testing::InitGoogleTest(&argc, argv); 5 | return RUN_ALL_TESTS(); 6 | } 7 | -------------------------------------------------------------------------------- /utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_subdirectory(googletest) 3 | add_subdirectory(FileCheck) 4 | 5 | -------------------------------------------------------------------------------- /utils/FileCheck/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Threads REQUIRED) 2 | 3 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") 4 | 5 | add_executable(FileCheck FileCheck.cpp) 6 | 7 | target_link_libraries(FileCheck 8 | ${LLVM_LIBRARIES} 9 | tinfo 10 | ${CMAKE_DL_LIBS} 11 | ${CMAKE_THREAD_LIBS_INIT} 12 | ) 13 | -------------------------------------------------------------------------------- /utils/FileCheck/README: -------------------------------------------------------------------------------- 1 | FileCheck is a tool from LLVM (see top level 'LICENSE' file for the LLVM License) for checking test output. 2 | 3 | This will be periodically updated with upstream changes from LLVM. 4 | -------------------------------------------------------------------------------- /utils/googletest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories( 3 | "${CMAKE_CURRENT_SOURCE_DIR}/include" 4 | "${CMAKE_CURRENT_SOURCE_DIR}" 5 | ) 6 | 7 | add_library(locic-util-gtest STATIC 8 | src/gtest-all.cc 9 | ) 10 | 11 | --------------------------------------------------------------------------------