{"id":812742,"url":"http://patchwork.ozlabs.org/api/patches/812742/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20170912091237.GA64499@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":"<20170912091237.GA64499@adacore.com>","list_archive_url":null,"date":"2017-09-12T09:12:37","name":"[Ada] Dynamically tagged expr of expr function is illegal","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"8f2efea051f557578de99f4ac72da577384c0fc7","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/20170912091237.GA64499@adacore.com/mbox/","series":[{"id":2644,"url":"http://patchwork.ozlabs.org/api/series/2644/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=2644","date":"2017-09-12T09:12:37","name":"[Ada] Dynamically tagged expr of expr function is illegal","version":1,"mbox":"http://patchwork.ozlabs.org/series/2644/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/812742/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/812742/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-461898-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-461898-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=\"lf25E34K\"; 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 3xrzbP1Ttwz9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 19:12:48 +1000 (AEST)","(qmail 30280 invoked by alias); 12 Sep 2017 09:12:40 -0000","(qmail 30262 invoked by uid 89); 12 Sep 2017 09:12:40 -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\tTue, 12 Sep 2017 09:12:38 +0000","from localhost (localhost.localdomain [127.0.0.1])\tby\n\tfiltered-rock.gnat.com (Postfix) with ESMTP id 1FEBD56040;\n\tTue, 12 Sep 2017 05:12:37 -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\tNjX3ZSQdpMkT; Tue, 12 Sep 2017 05:12:37 -0400 (EDT)","from tron.gnat.com (tron.gnat.com [205.232.38.10])\tby\n\trock.gnat.com (Postfix) with ESMTP id 0DCB356037;\n\tTue, 12 Sep 2017 05:12:37 -0400 (EDT)","by tron.gnat.com (Postfix, from userid 4192)\tid 08105521;\n\tTue, 12 Sep 2017 05:12:37 -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=uMv6e4zG1SujeuwU9pnTGdt1lShAnSJJOs1JopXcui2mpGpNFD\n\tI+IfIBlxExUYQ/fREbGUDKMtp4cBo0LHd/YnCnKEiqODwx/NoqCWtLKJXFdkJLKf\n\tId44iocEmnq1TsQvqOpxRn0x8I589NNrgCkhO8oGBHiGQcyoRoDasJ+Vc=","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=ts2lLoO0TehbMtuG9ABiwfzWPXQ=; b=lf25E34KUsbVSfsvZlf/\n\tt6Vezzko5OzoSNQFgigZhlb5u1quGQYgf8WWWRQAdGwrvv1JBLF6VsEkjnkSj1QA\n\t3hq2oYGuQ5Ng8mBvdKLT6Ih/7AjF4lBDRESLmj2APkkWKNKoCaZ7jyBjDtkeiNyH\n\tov46uaee69qRsNakR+JxKvM=","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=-10.5 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS,\n\tRCVD_IN_DNSWL_NONE,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=","X-HELO":"rock.gnat.com","Date":"Tue, 12 Sep 2017 05:12:37 -0400","From":"Arnaud Charlet <charlet@adacore.com>","To":"gcc-patches@gcc.gnu.org","Cc":"Bob Duff <duff@adacore.com>","Subject":"[Ada] Dynamically tagged expr of expr function is illegal","Message-ID":"<20170912091237.GA64499@adacore.com>","MIME-Version":"1.0","Content-Type":"multipart/mixed; boundary=\"sm4nu43k4a2Rpi4c\"","Content-Disposition":"inline","User-Agent":"Mutt/1.5.23 (2014-03-12)"},"content":"It is illegal to return a dynamically tagged expression\nfrom an expression function that returns a specific type. See\nRM-3.9.2(9). This patch fixes a bug that caused the compiler\nto fail to detect this illegality.\n\nTested on x86_64-pc-linux-gnu, committed on trunk\n\n2017-09-12  Bob Duff  <duff@adacore.com>\n\n\t* sem_ch6.adb (Analyze_Expression_Function): Call\n\tCheck_Dynamically_Tagged_Expression.\n\t* sem_util.adb (Check_Dynamically_Tagged_Expression): Remove\n\t\"and then Is_Tagged_Type (Typ)\" because there is an earlier\n\t\"Assert (Is_Tagged_Type (Typ))\".","diff":"Index: sem_util.adb\n===================================================================\n--- sem_util.adb\t(revision 251998)\n+++ sem_util.adb\t(working copy)\n@@ -2022,7 +2022,6 @@\n            or else In_Generic_Actual (Expr))\n         and then (Is_Class_Wide_Type (Etype (Expr))\n                    or else Is_Dynamically_Tagged (Expr))\n-        and then Is_Tagged_Type (Typ)\n         and then not Is_Class_Wide_Type (Typ)\n       then\n          Error_Msg_N (\"dynamically tagged expression not allowed!\", Expr);\nIndex: sem_ch6.adb\n===================================================================\n--- sem_ch6.adb\t(revision 251998)\n+++ sem_ch6.adb\t(working copy)\n@@ -741,6 +741,21 @@\n          end;\n       end if;\n \n+      --  Check incorrect use of dynamically tagged expression. This doesn't\n+      --  fall out automatically when analyzing the generated function body,\n+      --  because Check_Dynamically_Tagged_Expression deliberately ignores\n+      --  nodes that don't come from source.\n+\n+      if Present (Def_Id)\n+        and then Nkind (Def_Id) in N_Has_Etype\n+        and then Is_Tagged_Type (Etype (Def_Id))\n+      then\n+         Check_Dynamically_Tagged_Expression\n+           (Expr => Expr,\n+            Typ  => Etype (Def_Id),\n+            Related_Nod => Original_Node (N));\n+      end if;\n+\n       --  If the return expression is a static constant, we suppress warning\n       --  messages on unused formals, which in most cases will be noise.\n \n","prefixes":["Ada"]}