{"id":814835,"url":"http://patchwork.ozlabs.org/api/1.2/patches/814835/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20170918091158.GA36995@adacore.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.2/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":"<20170918091158.GA36995@adacore.com>","list_archive_url":null,"date":"2017-09-18T09:11:58","name":"[Ada] Crash on illegal current instance","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"2068cd1514746ecf83d9ec30051c0f52bba8430a","submitter":{"id":64226,"url":"http://patchwork.ozlabs.org/api/1.2/people/64226/?format=json","name":"Pierre-Marie de Rodat","email":"derodat@adacore.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20170918091158.GA36995@adacore.com/mbox/","series":[{"id":3595,"url":"http://patchwork.ozlabs.org/api/1.2/series/3595/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=3595","date":"2017-09-18T09:11:58","name":"[Ada] Crash on illegal current instance","version":1,"mbox":"http://patchwork.ozlabs.org/series/3595/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814835/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814835/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-462361-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-462361-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=\"qqpY9oF5\"; 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 3xwgHx5dWnz9s7h\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 19:12:13 +1000 (AEST)","(qmail 128811 invoked by alias); 18 Sep 2017 09:12:06 -0000","(qmail 127878 invoked by uid 89); 18 Sep 2017 09:12:06 -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\tMon, 18 Sep 2017 09:11:59 +0000","from localhost (localhost.localdomain [127.0.0.1])\tby\n\tfiltered-rock.gnat.com (Postfix) with ESMTP id 8D427560EA;\n\tMon, 18 Sep 2017 05:11:58 -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\t4p99D7+PPj5F; Mon, 18 Sep 2017 05:11:58 -0400 (EDT)","from tron.gnat.com (tron.gnat.com [205.232.38.10])\tby\n\trock.gnat.com (Postfix) with ESMTP id 7CF6F560E6;\n\tMon, 18 Sep 2017 05:11:58 -0400 (EDT)","by tron.gnat.com (Postfix, from userid 4862)\tid 7837B4FC;\n\tMon, 18 Sep 2017 05:11:58 -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=G/OYXU4x382ORv92bf+/q3j8E/ZxlZKpFchGJjf5GPuDBfNboA\n\tr/3IsRCVREZh5d426wOXPweQlJIjqg5el3cc89vDiJeOVNID5F4qQQHyz2NDXrRX\n\tztvDbYd83CrPRg9EYhptajHlRBhIvb/TfiQmt8baWxjFzget621nvZts0=","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=xQbhkOEQDXhSOhZ4ys1W0WpMfGU=; b=qqpY9oF56rNUWwKV0i/d\n\tU1iPUD4Z2o4de/QA/9xywBrFug3ZnFwB/zWlGccHXLUHM2Cz8x5WkEWeB5UXsVsn\n\toHmXNB66NLCi9014yMUbbmeGsnTO5jFzsUsx6lhw8PRhrHIXsKdb2IIRMCwLncwB\n\ttF1kaVeX3ZYthoyh51ZM45s=","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.9 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=Hx-languages-length:1438,\n\tColor, Crash","X-HELO":"rock.gnat.com","Date":"Mon, 18 Sep 2017 05:11:58 -0400","From":"Pierre-Marie de Rodat <derodat@adacore.com>","To":"gcc-patches@gcc.gnu.org","Cc":"Bob Duff <duff@adacore.com>","Subject":"[Ada] Crash on illegal current instance","Message-ID":"<20170918091158.GA36995@adacore.com>","MIME-Version":"1.0","Content-Type":"multipart/mixed; boundary=\"7JfCtLOvnd9MIVvH\"","Content-Disposition":"inline","User-Agent":"Mutt/1.5.23 (2014-03-12)","X-IsSubscribed":"yes"},"content":"If the type_mark of a qualified_expression refers to the current\ninstance of the type, do not crash; instead give a proper error\nmessage. This is illegal by RM-8.6(17).\n\nThe following test should get an error:\n\ncurrent_instance_default.ads:2:54: current instance not allowed\n\npackage Current_Instance_Default is\n   type Color is (Red, Orange) with Default_Value => Color'(Red); -- ERROR:\nend Current_Instance_Default;\n\nTested on x86_64-pc-linux-gnu, committed on trunk\n\n2017-09-18  Bob Duff  <duff@adacore.com>\n\n\t* sem_ch4.adb (Analyze_Qualified_Expression): Give an error if the type\n\tmark refers to the current instance. Set the type to Any_Type in that\n\tcase, to avoid later crashes.","diff":"Index: sem_ch4.adb\n===================================================================\n--- sem_ch4.adb\t(revision 252907)\n+++ sem_ch4.adb\t(working copy)\n@@ -3930,6 +3930,23 @@\n       Set_Etype (N, Any_Type);\n       Find_Type (Mark);\n       T := Entity (Mark);\n+\n+      if Nkind_In\n+        (Enclosing_Declaration (N),\n+         N_Formal_Type_Declaration,\n+         N_Full_Type_Declaration,\n+         N_Incomplete_Type_Declaration,\n+         N_Protected_Type_Declaration,\n+         N_Private_Extension_Declaration,\n+         N_Private_Type_Declaration,\n+         N_Subtype_Declaration,\n+         N_Task_Type_Declaration)\n+        and then T = Defining_Identifier (Enclosing_Declaration (N))\n+      then\n+         Error_Msg_N (\"current instance not allowed\", Mark);\n+         T := Any_Type;\n+      end if;\n+\n       Set_Etype (N, T);\n \n       if T = Any_Type then\n","prefixes":["Ada"]}