File 1231-Declare-the-type-of-function-entry-points.patch of Package erlang

From d6d52477cdd6efefd3d3d93f4433b2b1f4e52ce7 Mon Sep 17 00:00:00 2001
From: Kostis Sagonas <kostis@it.uu.se>
Date: Fri, 27 May 2016 11:55:12 +0200
Subject: [PATCH 2/2] Declare the type of function entry points

This shuts off compiler warnings and will allow to enable stronger
compiler checks files that include beam_disasm.hrl in the hipe
application.

While doing that, also modified a comment in the header file and
turned a case statement into effectively an assertion: there should
not really be any beam files where functions do not have a label as
entry point, right?
---
 lib/compiler/src/beam_disasm.erl | 5 +----
 lib/compiler/src/beam_disasm.hrl | 6 ++++--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/compiler/src/beam_disasm.erl b/lib/compiler/src/beam_disasm.erl
index 5badcce..c699672 100644
--- a/lib/compiler/src/beam_disasm.erl
+++ b/lib/compiler/src/beam_disasm.erl
@@ -314,10 +314,7 @@ get_funs({LsR0,[{func_info,[{atom,M}=AtomM,{atom,F}=AtomF,ArityArg]}|Code0]})
   when is_atom(M), is_atom(F) ->
     Arity = resolve_arg_unsigned(ArityArg),
     {LsR,Code,RestCode} = get_fun(Code0, []),
-    Entry = case Code of
-		[{label,[{u,E}]}|_] -> E;
-		_ -> undefined
-	    end,
+    [{label,[{u,Entry}]}|_] = Code,
     [#function{name=F,
 	       arity=Arity,
 	       entry=Entry,
diff --git a/lib/compiler/src/beam_disasm.hrl b/lib/compiler/src/beam_disasm.hrl
index e182146..d968cd9 100644
--- a/lib/compiler/src/beam_disasm.hrl
+++ b/lib/compiler/src/beam_disasm.hrl
@@ -22,7 +22,9 @@
 %%	    the system (e.g. in the translation from Beam to Icode).
 
 %%
-%% XXX: THE FOLLOWING TYPE DECLARATION DOES NOT BELONG HERE...
+%% XXX: THE FOLLOWING TYPE DECLARATION DOES NOT BELONG HERE.
+%%      IT SHOULD BE MOVED TO A FILE THAT DEFINES (AND EXPORTS)
+%%      PROPER TYPES FOR THE SET OF BEAM INSTRUCTIONS.
 %%
 -type beam_instr() :: 'bs_init_writable' | 'fclearerror' | 'if_end'
                     | 'remove_message' | 'return' | 'send' | 'timeout'
@@ -34,7 +36,7 @@
 
 -record(function, {name      :: atom(),
 		   arity     :: byte(),
-		   entry,    %% unused ??
+		   entry     :: beam_lib:label(),    %% unnecessary ?
 		   code = [] :: [beam_instr()]}).
 
 -record(beam_file, {module               :: module(),
-- 
2.1.4

openSUSE Build Service is sponsored by