From patchwork Fri May 27 19:28:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 97742 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]) by ozlabs.org (Postfix) with SMTP id 17C9CB6F75 for ; Sat, 28 May 2011 05:28:53 +1000 (EST) Received: (qmail 7831 invoked by alias); 27 May 2011 19:28:51 -0000 Received: (qmail 7815 invoked by uid 22791); 27 May 2011 19:28:50 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 May 2011 19:28:36 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4RJSaF8020407 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 27 May 2011 15:28:36 -0400 Received: from [127.0.0.1] (ovpn-113-23.phx2.redhat.com [10.3.113.23]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p4RJSZng007167 for ; Fri, 27 May 2011 15:28:35 -0400 Message-ID: <4DDFFB63.8000006@redhat.com> Date: Fri, 27 May 2011 15:28:35 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/49181 (error reporting re-entered) 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 Here, the problem was that when we went to generate the partially-instantiated function type in the mangler, we weren't in the proper scope so lookup of an identifier failed. Fixed by doing push_access_scope like we do in other situations. Tested x86_64-pc-linux-gnu, applying to trunk. commit 5d930ac29cdc6d91f6e5325b4946bb784cfdb6f4 Author: Jason Merrill Date: Fri May 27 10:45:51 2011 -0400 PR c++/49181 * pt.c (get_mostly_instantiated_function_type): Use push_access_scope. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 767c4f6..71fe0a0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -18080,9 +18080,9 @@ get_mostly_instantiated_function_type (tree decl) TMPL_ARGS_DEPTH (targs), make_tree_vec (DECL_NTPARMS (tmpl))); - /* Disable access control as this function is used only during - name-mangling. */ - push_deferring_access_checks (dk_no_check); + /* Make sure that we can see identifiers, and compute access + correctly. */ + push_access_scope (decl); ++processing_template_decl; /* Now, do the (partial) substitution to figure out the @@ -18097,7 +18097,7 @@ get_mostly_instantiated_function_type (tree decl) TREE_VEC_LENGTH (partial_args)--; tparms = tsubst_template_parms (tparms, partial_args, tf_error); - pop_deferring_access_checks (); + pop_access_scope (decl); } return fn_type; diff --git a/gcc/testsuite/g++.dg/cpp0x/error5.C b/gcc/testsuite/g++.dg/cpp0x/error5.C new file mode 100644 index 0000000..1931926 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/error5.C @@ -0,0 +1,107 @@ +// PR c++/49181 +// { dg-options -std=c++0x } + +namespace std +{ + typedef __SIZE_TYPE__ size_t; + + template + struct integral_constant; + + template + struct integral_constant + { + static constexpr _Tp value = __v; + typedef _Tp value_type; + typedef integral_constant<_Tp, __v> type; + constexpr operator value_type() { return value; } + }; + + typedef integral_constant true_type; + + typedef integral_constant false_type; + + template + constexpr _Tp integral_constant<_Tp, __v>::value; + + template + struct enable_if + { }; + + template + struct enable_if + { typedef _Tp type; }; + + template + inline _Tp + declval(); + +struct bad_alloc { }; +} + +void* operator new(std::size_t) throw (std::bad_alloc); + +namespace std +{ + + template + class allocator + { + public: + typedef _Tp* pointer; + typedef _Tp value_type; + + pointer + allocate(size_t, const void* = 0); + }; + + template + struct allocator_traits + { + typedef typename _Alloc::value_type value_type; + + template static typename _Tp::pointer +_S_pointer_helper(_Tp*); + static value_type* _S_pointer_helper(...); + typedef decltype(_S_pointer_helper((_Alloc*)0)) __pointer; + + typedef __pointer pointer; + + typedef const void* const_void_pointer; + + private: + template + struct __allocate_helper + { + template()->allocate( + std::declval(), + std::declval()))> + static true_type __test(int); + + template + static false_type __test(...); + + typedef decltype(__test<_Alloc>(0)) type; + static const bool value = type::value; + }; + + template + static typename + enable_if<__allocate_helper<_Alloc2>::value, pointer>::type + _S_allocate(_Alloc2& __a, size_t __n, const_void_pointer __hint) + { return __a.allocate(__n, __hint); } + + public: + static pointer + allocate(_Alloc& __a, size_t __n, const_void_pointer __hint) + { return _S_allocate(__a, __n, __hint); } + }; + +} + +namespace std +{ + typedef short test_type; + template struct allocator_traits>; +}