From patchwork Sun May 24 23:20:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 476016 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A07CA140081 for ; Mon, 25 May 2015 09:20:44 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=O/6cpw4C; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=lh90PA4svKreND1MDOjEsKzFlRPaphtK2C58FvKN3sG MmO6nuRhMVvZzaFHB/3NQtJfwjwZSBFSwH4dEHLhDrlTUw1POxA1LAzEQ3bILFGq PU2kmUS9yfdMVAML5TuBk5agHJB27RNA8d2S6m0Eve8EPLpMJ6sc/jqBRSpt9kR4 = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=TzXfWvTh0O6BZ/6Q6xX4Fn8Adps=; b=O/6cpw4CL8qSsHLV0 qSso5YUl/7uzA7J2ZAgww5F9aX0K3PiKFC+HcJBmCbk6zsRN628bnEtAjqDhYXGY I0rwwBDN4mILbHcVccSJnm5l1DJ5YLa78YZSpTpMbDMH8Nu6jtMcv7kAGyu/nQ82 rCstROAD3FEh2Ish5GaPXagux8= Received: (qmail 2567 invoked by alias); 24 May 2015 23:20:37 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 2557 invoked by uid 89); 24 May 2015 23:20:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-qg0-f47.google.com Received: from mail-qg0-f47.google.com (HELO mail-qg0-f47.google.com) (209.85.192.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 24 May 2015 23:20:26 +0000 Received: by qgf2 with SMTP id 2so4368822qgf.3 for ; Sun, 24 May 2015 16:20:24 -0700 (PDT) X-Received: by 10.140.218.5 with SMTP id o5mr17905395qhb.13.1432509624389; Sun, 24 May 2015 16:20:24 -0700 (PDT) Received: from ?IPv6:2601:6:8380:343:a2a8:cdff:fe3e:b48? ([2601:6:8380:343:a2a8:cdff:fe3e:b48]) by mx.google.com with ESMTPSA id 64sm5793562qgg.26.2015.05.24.16.20.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 May 2015 16:20:23 -0700 (PDT) Message-ID: <55625CB6.1020403@acm.org> Date: Sun, 24 May 2015 19:20:22 -0400 From: Nathan Sidwell User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: GCC Patches CC: Jason Merrill Subject: [C++ Patch] Fix 66243, silent cast of scoped enum This is a pretty obvious patch. We were permitting a scoped enum initializer of an another enum to silently decay to int. That's not right, only unscoped enums have that privilege. committed. nathan 2015-05-24 Nathan Sidwell cp/ PR c++/66243 * decl.c (build_enumerator): Don't silently convert scoped enums. testsuite/ PR c++/66243 * g++.dg/cpp0x/pr66243.C: New. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 223613) +++ cp/decl.c (working copy) @@ -13097,7 +13097,8 @@ build_enumerator (tree name, tree value, if (tmp_value) value = tmp_value; } - else if (! INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (value))) + else if (! INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P + (TREE_TYPE (value))) value = perform_implicit_conversion_flags (ENUM_UNDERLYING_TYPE (enumtype), value, tf_warning_or_error, LOOKUP_IMPLICIT | LOOKUP_NO_NARROWING); Index: testsuite/g++.dg/cpp0x/pr66243.C =================================================================== --- testsuite/g++.dg/cpp0x/pr66243.C (revision 0) +++ testsuite/g++.dg/cpp0x/pr66243.C (working copy) @@ -0,0 +1,12 @@ +// { dg-do compile { target c++11 } } + +enum class A +{ + X +}; + +enum class B +{ + X = A::X // { dg-error "could not convert" } +}; +