From patchwork Wed May 20 01:56:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 474118 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 55119140781 for ; Wed, 20 May 2015 11:56:20 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=LaMINPD4; 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=GhlIebmfjCVFX91YSU2q0Nmpl7Mocu98q6Ljj5/KS63 GMc2hTpkfnle0pb0hr4piRrmHtZ3kQE48n7sz2ABpofj86LWIXX4xPl5Pjmh709u IELC6/YctjlN27oLVSjHZoxL/wXtQOTqlMuf6Fpv3DInfw9SDB+3DeoriU8Bcid8 = 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=eZe9850uUXYlmIUQYVIwiNZZJVE=; b=LaMINPD4L/D/4Wxll WWtB72PXvP25Q7o4ZJ4C7Gh8NIubq2XbesHNe5VoOMmPubKvsb2Nes5ftftCR/2R Qz9ufTUfo5ysFyFtF1rnP2u5AbUUh9Yyzzsa9qto5T+dg3/z1gwJoe0jKFwlGxhi PQMolxhWxRM+j4GDH9fJ4HOY/g= Received: (qmail 112880 invoked by alias); 20 May 2015 01:56:11 -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 112684 invoked by uid 89); 20 May 2015 01:56:10 -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-f50.google.com Received: from mail-qg0-f50.google.com (HELO mail-qg0-f50.google.com) (209.85.192.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 20 May 2015 01:56:09 +0000 Received: by qget53 with SMTP id t53so17118526qge.3 for ; Tue, 19 May 2015 18:56:07 -0700 (PDT) X-Received: by 10.55.24.39 with SMTP id j39mr52482935qkh.60.1432086967598; Tue, 19 May 2015 18:56:07 -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 b109sm10266142qga.48.2015.05.19.18.56.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 May 2015 18:56:06 -0700 (PDT) Message-ID: <555BE9B6.1060307@acm.org> Date: Tue, 19 May 2015 21:56:06 -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: fix class enum lookup I've committed this obvious patch for 65954. We failed to issue a diagnostic for a failed class enum lookup, and returned NULL, rather than error_mark_node, leading to a seg fault. booted & tested on x86_64-linux. nathan 2015-05-19 Nathan sidwell cp/ PR c++/65954 * typeck.c (finish_class_member_access_expr): Diagnose failed lookup of enum class member. testsuite/ * g++.dg/cpp0x/pr65954.C: New. Index: cp/typeck.c =================================================================== --- cp/typeck.c (revision 223414) +++ cp/typeck.c (working copy) @@ -2731,6 +2731,14 @@ finish_class_member_access_expr (tree ob return error_mark_node; } tree val = lookup_enumerator (scope, name); + if (!val) + { + if (complain & tf_error) + error ("%qD is not a member of %qD", + name, scope); + return error_mark_node; + } + if (TREE_SIDE_EFFECTS (object)) val = build2 (COMPOUND_EXPR, TREE_TYPE (val), object, val); return val; Index: testsuite/g++.dg/cpp0x/pr65954.C =================================================================== --- testsuite/g++.dg/cpp0x/pr65954.C (revision 0) +++ testsuite/g++.dg/cpp0x/pr65954.C (working copy) @@ -0,0 +1,12 @@ +// { dg-do compile { target c++11 } } + +struct Shape { + enum class Type + { Circle, Square }; +}; + + +void Foo (Shape &shape) +{ + +shape.Type::NOPE; // { dg-error "is not a member of" } +}