]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Relax assertion in profiler
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 25 Oct 2022 10:20:33 +0000 (12:20 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Tue, 25 Oct 2022 10:25:19 +0000 (12:25 +0200)
This assertion in branch_prob:

  if (bb == ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb)
    {
      location_t loc = DECL_SOURCE_LOCATION (current_function_decl);
      gcc_checking_assert (!RESERVED_LOCATION_P (loc));

had been correct until the fix for PR debug/101598 was installed.

gcc/
* profile.cc (branch_prob): Be prepared for ignored functions with
DECL_SOURCE_LOCATION set to UNKNOWN_LOCATION.

gcc/testsuite:
* gnat.dg/specs/coverage1.ads: New test.
* gnat.dg/specs/variant_part.ads: Minor tweak.
* gnat.dg/specs/weak1.ads: Add dg directive.

gcc/profile.cc
gcc/testsuite/gnat.dg/specs/coverage1.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/specs/variant_part.ads
gcc/testsuite/gnat.dg/specs/weak1.ads

index a67cce5b19986a1759f4ab007376f740a5397742..40e105258faa03b773f0e75740e2a48c6467fe04 100644 (file)
@@ -1457,11 +1457,13 @@ branch_prob (bool thunk)
          if (bb == ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb)
            {
              location_t loc = DECL_SOURCE_LOCATION (current_function_decl);
-             gcc_checking_assert (!RESERVED_LOCATION_P (loc));
-             seen_locations.add (loc);
-             expanded_location curr_location = expand_location (loc);
-             output_location (&streamed_locations, curr_location.file,
-                              MAX (1, curr_location.line), &offset, bb);
+             if (!RESERVED_LOCATION_P (loc))
+               {
+                 seen_locations.add (loc);
+                 expanded_location curr_location = expand_location (loc);
+                 output_location (&streamed_locations, curr_location.file,
+                                  MAX (1, curr_location.line), &offset, bb);
+               }
            }
 
          for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
diff --git a/gcc/testsuite/gnat.dg/specs/coverage1.ads b/gcc/testsuite/gnat.dg/specs/coverage1.ads
new file mode 100644 (file)
index 0000000..af7b61c
--- /dev/null
@@ -0,0 +1,10 @@
+-- { dg-do compile }
+-- { dg-options "-ftest-coverage" }
+
+package Coverage1 is
+
+  type Rec is record
+    I : Integer := 0;
+  end record;
+
+end Coverage1;
index afc92cde5d700a3ab2a385e962496db7db659f70..72da4108588a5a1547d136857717a9399f8a2e2b 100644 (file)
@@ -1,4 +1,5 @@
 -- { dg-do compile }
+
 package Variant_Part is
    type T1(b: boolean) is record
      case (b) is    -- { dg-error "discriminant name may not be parenthesized" }
index 82cddc09ac27156233f7fc6e61465c55772a927d..ece05ea68a758e3202887ecad0f470bc71c04ea3 100644 (file)
@@ -1,3 +1,5 @@
+-- { dg-do compile }
+
 package Weak1 is
 
    Myconst : constant Integer := 1234;