add [[noreturn]] for *Error functions to disable warning. (#247)

* add noreturn for *Error to disable warning.

* fix.
This commit is contained in:
ykiko 2024-05-29 21:23:39 +08:00 committed by GitHub
parent 249aac934b
commit 5d73dfc55d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 24 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@ __pycache__/
.DS_Store .DS_Store
.coverage .coverage
.idea .idea
.cache/clangd/
gmon.out gmon.out
gprof.txt gprof.txt

View File

@ -375,26 +375,26 @@ public:
#endif #endif
#if PK_REGION("Error Reporting Methods") #if PK_REGION("Error Reporting Methods")
void _error(PyVar); [[noreturn]] void _error(PyVar);
void StackOverflowError() { __builtin_error("StackOverflowError"); } [[noreturn]] void StackOverflowError() { __builtin_error("StackOverflowError"); }
void IOError(const Str& msg) { __builtin_error("IOError", msg); } [[noreturn]] void IOError(const Str& msg) { __builtin_error("IOError", msg); }
void NotImplementedError(){ __builtin_error("NotImplementedError"); } [[noreturn]] void NotImplementedError(){ __builtin_error("NotImplementedError"); }
void TypeError(const Str& msg){ __builtin_error("TypeError", msg); } [[noreturn]] void TypeError(const Str& msg){ __builtin_error("TypeError", msg); }
void TypeError(Type expected, Type actual) { TypeError("expected " + _type_name(vm, expected).escape() + ", got " + _type_name(vm, actual).escape()); } [[noreturn]] void TypeError(Type expected, Type actual) { TypeError("expected " + _type_name(vm, expected).escape() + ", got " + _type_name(vm, actual).escape()); }
void IndexError(const Str& msg){ __builtin_error("IndexError", msg); } [[noreturn]] void IndexError(const Str& msg){ __builtin_error("IndexError", msg); }
void ValueError(const Str& msg){ __builtin_error("ValueError", msg); } [[noreturn]] void ValueError(const Str& msg){ __builtin_error("ValueError", msg); }
void RuntimeError(const Str& msg){ __builtin_error("RuntimeError", msg); } [[noreturn]] void RuntimeError(const Str& msg){ __builtin_error("RuntimeError", msg); }
void ZeroDivisionError(const Str& msg){ __builtin_error("ZeroDivisionError", msg); } [[noreturn]] void ZeroDivisionError(const Str& msg){ __builtin_error("ZeroDivisionError", msg); }
void ZeroDivisionError(){ __builtin_error("ZeroDivisionError", "division by zero"); } [[noreturn]] void ZeroDivisionError(){ __builtin_error("ZeroDivisionError", "division by zero"); }
void NameError(StrName name){ __builtin_error("NameError", _S("name ", name.escape() + " is not defined")); } [[noreturn]] void NameError(StrName name){ __builtin_error("NameError", _S("name ", name.escape() + " is not defined")); }
void UnboundLocalError(StrName name){ __builtin_error("UnboundLocalError", _S("local variable ", name.escape() + " referenced before assignment")); } [[noreturn]] void UnboundLocalError(StrName name){ __builtin_error("UnboundLocalError", _S("local variable ", name.escape() + " referenced before assignment")); }
void KeyError(PyVar obj){ __builtin_error("KeyError", obj); } [[noreturn]] void KeyError(PyVar obj){ __builtin_error("KeyError", obj); }
void ImportError(const Str& msg){ __builtin_error("ImportError", msg); } [[noreturn]] void ImportError(const Str& msg){ __builtin_error("ImportError", msg); }
void AssertionError(const Str& msg){ __builtin_error("AssertionError", msg); } [[noreturn]] void AssertionError(const Str& msg){ __builtin_error("AssertionError", msg); }
void AssertionError(){ __builtin_error("AssertionError"); } [[noreturn]] void AssertionError(){ __builtin_error("AssertionError"); }
void BinaryOptError(const char* op, PyVar _0, PyVar _1); [[noreturn]] void BinaryOptError(const char* op, PyVar _0, PyVar _1);
void AttributeError(PyVar obj, StrName name); [[noreturn]] void AttributeError(PyVar obj, StrName name);
void AttributeError(const Str& msg){ __builtin_error("AttributeError", msg); } [[noreturn]] void AttributeError(const Str& msg){ __builtin_error("AttributeError", msg); }
#endif #endif
#if PK_REGION("Type Checking Methods") #if PK_REGION("Type Checking Methods")
@ -484,12 +484,12 @@ public:
void __prepare_py_call(PyVar*, ArgsView, ArgsView, const FuncDecl_&); void __prepare_py_call(PyVar*, ArgsView, ArgsView, const FuncDecl_&);
void __unpack_as_list(ArgsView args, List& list); void __unpack_as_list(ArgsView args, List& list);
void __unpack_as_dict(ArgsView args, Dict& dict); void __unpack_as_dict(ArgsView args, Dict& dict);
void __raise_exc(bool re_raise=false); [[noreturn]] void __raise_exc(bool re_raise=false);
void __init_builtin_types(); void __init_builtin_types();
void __post_init_builtin_types(); void __post_init_builtin_types();
void __builtin_error(StrName type); [[noreturn]] void __builtin_error(StrName type);
void __builtin_error(StrName type, PyVar arg); [[noreturn]] void __builtin_error(StrName type, PyVar arg);
void __builtin_error(StrName type, const Str& msg); [[noreturn]] void __builtin_error(StrName type, const Str& msg);
void __push_varargs(){} void __push_varargs(){}
void __push_varargs(PyVar _0){ PUSH(_0); } void __push_varargs(PyVar _0){ PUSH(_0); }
void __push_varargs(PyVar _0, PyVar _1){ PUSH(_0); PUSH(_1); } void __push_varargs(PyVar _0, PyVar _1){ PUSH(_0); PUSH(_1); }