aboutsummaryrefslogtreecommitdiff
path: root/gcc/m2/gm2-gcc
diff options
context:
space:
mode:
authorGaius Mulley <gaiusmod2@gmail.com>2023-01-26 21:43:22 +0000
committerGaius Mulley <gaiusmod2@gmail.com>2023-01-26 21:43:22 +0000
commit94673a121cfc7f9d51c9d05e31795477f4dc8dc7 (patch)
tree4c9f12b0bfba33a7fd1c51afe648ba9a927b3fbe /gcc/m2/gm2-gcc
parent67bcd1c5ed4d966a91b49b8a7da7c1ca3289c2ce (diff)
downloadgcc-94673a121cfc7f9d51c9d05e31795477f4dc8dc7.zip
gcc-94673a121cfc7f9d51c9d05e31795477f4dc8dc7.tar.gz
gcc-94673a121cfc7f9d51c9d05e31795477f4dc8dc7.tar.bz2
PR-108551 gcc/m2/gm2-libs-pim/Termbase.mod:128:1 error end of non-void
cc1gm2 generates an error: control reaches end of non-void function when compiling Termbase.mod if -Werror=return-type is present. ../gcc/m2/gm2-libs-pim/Termbase.mod: In function 'Termbase_KeyPressed': ../gcc/m2/gm2-libs-pim/Termbase.mod:128:1: error: control reaches end of non-void function [-Werror=return-type] 128 | END KeyPressed ; | ^~~ This occurs as cc1gm2 does skips over the <* noreturn *> attribute. This patch records the <* noreturn *> attribute in the m2 symbol table and later on sets TREE_THIS_VOLATILE when creating the function decl. The patch also contains a fix for the main scaffold which also omitted a return 0 after the exception handler code. gcc/m2/ChangeLog: * gm2-compiler/M2GCCDeclare.mod: Import IsProcedureNoReturn. (DeclareProcedureToGccWholeProgram): New variable declared and set returnType. Pass returnType to BuildEndFunctionDeclaration. Extra parameter IsProcedureNoReturn passed to BuildEndFunctionDeclaration. * gm2-compiler/M2Quads.mod (BuildM2MainFunction): Correct scaffold comment and add extra return 0. * gm2-compiler/P2Build.bnf: Import BuildNoReturnAttribute. (ProcedureHeading): Process EndBuildFormalParameters before parsing AttributeNoReturn. (DefProcedureHeading): Process EndBuildFormalParameters before parsing AttributeNoReturn. (AttributeNoReturn): Call BuildNoReturnAttribute. * gm2-compiler/P2SymBuild.def (BuildNoReturnAttribute): New procedure. * gm2-compiler/P2SymBuild.mod (BuildNoReturnAttribute): New procedure. * gm2-compiler/SymbolTable.def (PutProcedureInline): Corrected comment. (PutProcedureNoReturn): New procedure. (IsProcedureNoReturn): New procedure function. * gm2-compiler/SymbolTable.mod (SymProcedure): IsNoReturn new field. (MakeProcedure): Initialize IsNoReturn to FALSE. (PutProcedureNoReturn): New procedure. (IsProcedureNoReturn): New procedure function. * gm2-gcc/m2decl.cc (m2decl_BuildEndFunctionDeclaration): Add extra parameter isnoreturn. Set TREE_THIS_VOLATILE to isnoreturn. * gm2-gcc/m2decl.def (BuildEndFunctionDeclaration): Add extra parameter isnoreturn. * gm2-gcc/m2decl.h (m2decl_BuildEndFunctionDeclaration): Add extra parameter isnoreturn. * gm2-gcc/m2except.cc (m2except_InitExceptions): Change all function decl to pass an extra parameter isnoreturn. gcc/testsuite/ChangeLog: * gm2/warnings/returntype/fail/badreturn.mod: New test. * gm2/warnings/returntype/fail/warnings-returntype-fail.exp: New test. * gm2/warnings/returntype/pass/Termbase.mod: New test. * gm2/warnings/returntype/pass/goodreturn.mod: New test. * gm2/warnings/returntype/pass/keypressedsimple.mod: New test. * gm2/warnings/returntype/pass/warnings-returntype-pass.exp: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diffstat (limited to 'gcc/m2/gm2-gcc')
-rw-r--r--gcc/m2/gm2-gcc/m2decl.cc3
-rw-r--r--gcc/m2/gm2-gcc/m2decl.def3
-rw-r--r--gcc/m2/gm2-gcc/m2decl.h3
-rw-r--r--gcc/m2/gm2-gcc/m2except.cc17
4 files changed, 16 insertions, 10 deletions
diff --git a/gcc/m2/gm2-gcc/m2decl.cc b/gcc/m2/gm2-gcc/m2decl.cc
index fb4d7dc..ab40937 100644
--- a/gcc/m2/gm2-gcc/m2decl.cc
+++ b/gcc/m2/gm2-gcc/m2decl.cc
@@ -211,7 +211,7 @@ tree
m2decl_BuildEndFunctionDeclaration (location_t location_begin,
location_t location_end, const char *name,
tree returntype, int isexternal,
- int isnested, int ispublic)
+ int isnested, int ispublic, int isnoreturn)
{
tree fntype;
tree fndecl;
@@ -244,6 +244,7 @@ m2decl_BuildEndFunctionDeclaration (location_t location_begin,
= build_decl (location_end, RESULT_DECL, NULL_TREE, returntype);
DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
TREE_TYPE (fndecl) = fntype;
+ TREE_THIS_VOLATILE (fndecl) = isnoreturn;
DECL_SOURCE_LOCATION (fndecl) = location_begin;
diff --git a/gcc/m2/gm2-gcc/m2decl.def b/gcc/m2/gm2-gcc/m2decl.def
index 036f903c..6a19693 100644
--- a/gcc/m2/gm2-gcc/m2decl.def
+++ b/gcc/m2/gm2-gcc/m2decl.def
@@ -149,7 +149,8 @@ PROCEDURE BuildStartFunctionDeclaration (uses_varargs: BOOLEAN) ;
PROCEDURE BuildEndFunctionDeclaration (location_begin, location_end: location_t;
name: ADDRESS; returntype: Tree;
- isexternal, isnested, ispublic: BOOLEAN) : Tree ;
+ isexternal, isnested, ispublic,
+ isnoreturn: BOOLEAN) : Tree ;
(*
diff --git a/gcc/m2/gm2-gcc/m2decl.h b/gcc/m2/gm2-gcc/m2decl.h
index 13ecaaf..19dbb7b 100644
--- a/gcc/m2/gm2-gcc/m2decl.h
+++ b/gcc/m2/gm2-gcc/m2decl.h
@@ -58,7 +58,8 @@ EXTERN void m2decl_RememberVariables (tree l);
EXTERN tree m2decl_BuildEndFunctionDeclaration (
location_t location_begin, location_t location_end, const char *name,
- tree returntype, int isexternal, int isnested, int ispublic);
+ tree returntype, int isexternal, int isnested, int ispublic,
+ int isnoreturn);
EXTERN void m2decl_BuildStartFunctionDeclaration (int uses_varargs);
EXTERN tree m2decl_BuildParameterDeclaration (location_t location, char *name,
tree type, int isreference);
diff --git a/gcc/m2/gm2-gcc/m2except.cc b/gcc/m2/gm2-gcc/m2except.cc
index 2f43b68..ab7df80 100644
--- a/gcc/m2/gm2-gcc/m2except.cc
+++ b/gcc/m2/gm2-gcc/m2except.cc
@@ -103,18 +103,19 @@ m2except_InitExceptions (location_t location)
m2decl_BuildStartFunctionDeclaration (FALSE);
fn_rethrow_tree = m2decl_BuildEndFunctionDeclaration (
- location, location, "__cxa_rethrow", void_type_node, TRUE, FALSE, TRUE);
+ location, location, "__cxa_rethrow", void_type_node, TRUE, FALSE,
+ TRUE, FALSE);
TREE_NOTHROW (fn_rethrow_tree) = 0;
m2decl_BuildStartFunctionDeclaration (FALSE);
m2decl_BuildParameterDeclaration (location, NULL, ptr_type_node, FALSE);
fn_begin_catch_tree = m2decl_BuildEndFunctionDeclaration (
location, location, "__cxa_begin_catch", ptr_type_node, TRUE, FALSE,
- TRUE);
+ TRUE, FALSE);
m2decl_BuildStartFunctionDeclaration (FALSE);
fn_end_catch_tree = m2decl_BuildEndFunctionDeclaration (
location, location, "__cxa_end_catch", void_type_node, TRUE, FALSE,
- TRUE);
+ TRUE, FALSE);
/* This can throw if the destructor for the exception throws. */
TREE_NOTHROW (fn_end_catch_tree) = 0;
@@ -130,26 +131,28 @@ m2except_InitExceptions (location_t location)
m2decl_BuildParameterDeclaration (location, NULL, ptr_type_node, FALSE);
m2decl_BuildParameterDeclaration (location, NULL, ptr_type_node, FALSE);
fn_throw_tree = m2decl_BuildEndFunctionDeclaration (
- location, location, "__cxa_throw", void_type_node, TRUE, FALSE, TRUE);
+ location, location, "__cxa_throw", void_type_node, TRUE, FALSE, TRUE,
+ FALSE);
/* Declare void __cxa_rethrow (void). */
m2decl_BuildStartFunctionDeclaration (FALSE);
fn_rethrow_tree = m2decl_BuildEndFunctionDeclaration (
- location, location, "__cxa_rethrow", void_type_node, TRUE, FALSE, TRUE);
+ location, location, "__cxa_rethrow", void_type_node, TRUE, FALSE, TRUE,
+ FALSE);
/* Declare void *__cxa_allocate_exception (size_t). */
m2decl_BuildStartFunctionDeclaration (FALSE);
m2decl_BuildParameterDeclaration (location, NULL, size_type_node, FALSE);
fn_allocate_exception_tree = m2decl_BuildEndFunctionDeclaration (
location, location, "__cxa_allocate_exception", ptr_type_node, TRUE,
- FALSE, TRUE);
+ FALSE, TRUE, FALSE);
/* Declare void *__cxa_free_exception (void *). */
m2decl_BuildStartFunctionDeclaration (FALSE);
m2decl_BuildParameterDeclaration (location, NULL, ptr_type_node, FALSE);
fn_free_exception_tree = m2decl_BuildEndFunctionDeclaration (
location, location, "__cxa_free_exception", ptr_type_node, TRUE, FALSE,
- TRUE);
+ TRUE, FALSE);
/* Define integer type exception type which will match C++ int type
in the C++ runtime library. */