{"id":810562,"url":"http://patchwork.ozlabs.org/api/patches/810562/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20170906121655.GA59280@adacore.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170906121655.GA59280@adacore.com>","list_archive_url":null,"date":"2017-09-06T12:16:55","name":"[Ada] Issue error message on invalid representation clause for extension","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e296ce02df3d861d907c24687b0f68f571c8952e","submitter":{"id":4418,"url":"http://patchwork.ozlabs.org/api/people/4418/?format=json","name":"Arnaud Charlet","email":"charlet@adacore.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20170906121655.GA59280@adacore.com/mbox/","series":[{"id":1786,"url":"http://patchwork.ozlabs.org/api/series/1786/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=1786","date":"2017-09-06T12:16:55","name":"[Ada] Issue error message on invalid representation clause for extension","version":1,"mbox":"http://patchwork.ozlabs.org/series/1786/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/810562/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/810562/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-461595-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-461595-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"ZLe5VPsj\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xnMyw0Jl7z9sBZ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed,  6 Sep 2017 22:17:11 +1000 (AEST)","(qmail 99225 invoked by alias); 6 Sep 2017 12:16:59 -0000","(qmail 99001 invoked by uid 89); 6 Sep 2017 12:16:58 -0000","from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tWed, 06 Sep 2017 12:16:57 +0000","from localhost (localhost.localdomain [127.0.0.1])\tby\n\tfiltered-rock.gnat.com (Postfix) with ESMTP id A23105641C;\n\tWed,  6 Sep 2017 08:16:55 -0400 (EDT)","from rock.gnat.com ([127.0.0.1])\tby localhost (rock.gnat.com\n\t[127.0.0.1]) (amavisd-new, port 10024)\twith LMTP id\n\tK48UX4B-rs1M; Wed,  6 Sep 2017 08:16:55 -0400 (EDT)","from tron.gnat.com (tron.gnat.com [205.232.38.10])\tby\n\trock.gnat.com (Postfix) with ESMTP id 46F125614C;\n\tWed,  6 Sep 2017 08:16:55 -0400 (EDT)","by tron.gnat.com (Postfix, from userid 4192)\tid 45FB54AC;\n\tWed,  6 Sep 2017 08:16:55 -0400 (EDT)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:mime-version:content-type; q=dns;\n\ts=default; b=HrR13Ms+kBkdqZ4C1Gnh9Z7K7Iw9h+S66ATs8Pc85P0DyApcCi\n\tsl7DIse4vrLJ83BinwnyXI5cJGIf/PC2hUMmWirLTDA5qHLOazWoa4JEQKbFsoOH\n\tx8t6FuVnPdoygJEPai4TYTEGNqWxfsLOFStOi44kZnShk/arQzZOK918o=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:mime-version:content-type; s=\n\tdefault; bh=Rj6lmkBd+FCjMPWAWb9FBOIYfM0=; b=ZLe5VPsjtKHFLHTEqBPI\n\tIy3DaT9sM6ia1BAksjVuTrYdjMIsYNexKuxiWF4Jw6vC8XlDkfk7nB9icG5UZrgo\n\tZGM+LNxlWukaYH4F0rjNDOI2OjXVE5SmvPQo/uVVNpQ9heT8I6SIHJNCSTcZh1v+\n\tagK2zT5t7p/RRtug/5wH3Fk=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-11.2 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=Comp, comp","X-HELO":"rock.gnat.com","Date":"Wed, 6 Sep 2017 08:16:55 -0400","From":"Arnaud Charlet <charlet@adacore.com>","To":"gcc-patches@gcc.gnu.org","Cc":"Eric Botcazou <botcazou@adacore.com>","Subject":"[Ada] Issue error message on invalid representation clause for\n\textension","Message-ID":"<20170906121655.GA59280@adacore.com>","MIME-Version":"1.0","Content-Type":"multipart/mixed; boundary=\"mYCpIKhGyMATD0i+\"","Content-Disposition":"inline","User-Agent":"Mutt/1.5.23 (2014-03-12)"},"content":"This makes the compiler generate an error message also in the case where one\nof the specified components overlaps the parent field because its size has\nbeen explicitly set by a size clause.\n\nThe compiler must issue an error on 32-bit platforms for the package:\n\n     1. package P is\n     2.\n     3.   type Byte is mod 2**8;\n     4.   for Byte'Size use 8;\n     5.\n     6.   type Root is tagged record\n     7.     Status : Byte;\n     8.   end record;\n     9.   for Root use record\n    10.     Status at 4 range 0 .. 7;\n    11.   end record;\n    12.   for Root'Size use 64;\n    13.\n    14.   type Ext is new Root with record\n    15.     Thread_Status : Byte;\n    16.   end record;\n    17.   for Ext use record\n    18.     Thread_Status at 5 range 0 .. 7;\n            |\n        >>> component overlaps parent field of \"Ext\"\n\n    19.   end record;\n    20.\n    21. end P;\n\n 21 lines: 1 error\n\nTested on x86_64-pc-linux-gnu, committed on trunk\n\n2017-09-06  Eric Botcazou  <ebotcazou@adacore.com>\n\n\t* sem_ch13.adb (Check_Record_Representation_Clause): Give an\n\terror as soon as one of the specified components overlaps the\n\tparent field.","diff":"Index: sem_ch13.adb\n===================================================================\n--- sem_ch13.adb\t(revision 251784)\n+++ sem_ch13.adb\t(working copy)\n@@ -9806,12 +9806,12 @@\n       --  checking for overlap, since no overlap is possible.\n \n       Tagged_Parent : Entity_Id := Empty;\n-      --  This is set in the case of a derived tagged type for which we have\n-      --  Is_Fully_Repped_Tagged_Type True (indicating that all components are\n-      --  positioned by record representation clauses). In this case we must\n-      --  check for overlap between components of this tagged type, and the\n-      --  components of its parent. Tagged_Parent will point to this parent\n-      --  type. For all other cases Tagged_Parent is left set to Empty.\n+      --  This is set in the case of an extension for which we have either a\n+      --  size clause or Is_Fully_Repped_Tagged_Type True (indicating that all\n+      --  components are positioned by record representation clauses) on the\n+      --  parent type. In this case we check for overlap between components of\n+      --  this tagged type and the parent component. Tagged_Parent will point\n+      --  to this parent type. For all other cases, Tagged_Parent is Empty.\n \n       Parent_Last_Bit : Uint;\n       --  Relevant only if Tagged_Parent is set, Parent_Last_Bit indicates the\n@@ -9959,19 +9959,23 @@\n \n       if Rectype = Any_Type then\n          return;\n-      else\n-         Rectype := Underlying_Type (Rectype);\n       end if;\n \n+      Rectype := Underlying_Type (Rectype);\n+\n       --  See if we have a fully repped derived tagged type\n \n       declare\n          PS : constant Entity_Id := Parent_Subtype (Rectype);\n \n       begin\n-         if Present (PS) and then Is_Fully_Repped_Tagged_Type (PS) then\n+         if Present (PS) and then Known_Static_RM_Size (PS) then\n             Tagged_Parent := PS;\n+            Parent_Last_Bit := RM_Size (PS) - 1;\n \n+         elsif Present (PS) and then Is_Fully_Repped_Tagged_Type (PS) then\n+            Tagged_Parent := PS;\n+\n             --  Find maximum bit of any component of the parent type\n \n             Parent_Last_Bit := UI_From_Int (System_Address_Size - 1);\n@@ -10063,7 +10067,7 @@\n                  (\"bit number out of range of specified size\",\n                   Last_Bit (CC));\n \n-               --  Check for overlap with tag component\n+               --  Check for overlap with tag or parent component\n \n             else\n                if Is_Tagged_Type (Rectype)\n@@ -10073,27 +10077,20 @@\n                     (\"component overlaps tag field of&\",\n                      Component_Name (CC), Rectype);\n                   Overlap_Detected := True;\n+\n+               elsif Present (Tagged_Parent)\n+                 and then Fbit <= Parent_Last_Bit\n+               then\n+                  Error_Msg_NE\n+                    (\"component overlaps parent field of&\",\n+                     Component_Name (CC), Rectype);\n+                  Overlap_Detected := True;\n                end if;\n \n                if Hbit < Lbit then\n                   Hbit := Lbit;\n                end if;\n             end if;\n-\n-            --  Check parent overlap if component might overlap parent field\n-\n-            if Present (Tagged_Parent) and then Fbit <= Parent_Last_Bit then\n-               Pcomp := First_Component_Or_Discriminant (Tagged_Parent);\n-               while Present (Pcomp) loop\n-                  if not Is_Tag (Pcomp)\n-                    and then Chars (Pcomp) /= Name_uParent\n-                  then\n-                     Check_Component_Overlap (Comp, Pcomp);\n-                  end if;\n-\n-                  Next_Component_Or_Discriminant (Pcomp);\n-               end loop;\n-            end if;\n          end if;\n \n          Next (CC);\n","prefixes":["Ada"]}