Patchwork [Ada] Do not generate SCO for use clause or rep clause

login
register
mail settings
Submitter Arnaud Charlet
Date Aug. 5, 2011, 3:08 p.m.
Message ID <20110805150823.GA8686@adacore.com>
Download mbox | patch
Permalink /patch/108686/
State New
Headers show

Comments

Arnaud Charlet - Aug. 5, 2011, 3:08 p.m.
This change removes SCO generation for USE clauses and representation clauses,
which should not be subjected to coverage analysis.

The following compilation must produce a single statement SCO corresponding
to the declaration of type T:

$ gcc -c -gnateS no_sco.ads
$ grep "^CS" no_sco.ali
CS t3:4-3:25

with Ada;
package No_SCO is
   type T is range 0 .. 1;
   for T'Size use 1;
   use Ada;
end No_SCO;

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-05  Thomas Quinot  <quinot@adacore.com>

	* par_sco.adb (Traverse_Declarations_Or_Statements): Do not generate a
	statement SCO for a USE clause or a representation clause.

Patch

Index: par_sco.adb
===================================================================
--- par_sco.adb	(revision 177448)
+++ par_sco.adb	(working copy)
@@ -1483,7 +1483,8 @@ 
 
                when others =>
 
-                  --  Determine required type character code
+                  --  Determine required type character code, or ASCII.NUL if
+                  --  no SCO should be generated for this node.
 
                   declare
                      Typ : Character;
@@ -1505,11 +1506,19 @@ 
                         when N_Generic_Instantiation         =>
                            Typ := 'i';
 
+                        when
+                          N_Representation_Clause            |
+                          N_Use_Package_Clause               |
+                          N_Use_Type_Clause                  =>
+                           Typ := ASCII.NUL;
+
                         when others                          =>
                            Typ := ' ';
                      end case;
 
-                     Extend_Statement_Sequence (N, Typ);
+                     if Typ /= ASCII.NUL then
+                        Extend_Statement_Sequence (N, Typ);
+                     end if;
                   end;
 
                   --  Process any embedded decisions