From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101145 invoked by alias); 27 Mar 2015 16:36:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 101134 invoked by uid 89); 27 Mar 2015 16:36:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 27 Mar 2015 16:36:12 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2RGaBmw012679 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 27 Mar 2015 12:36:11 -0400 Received: from [10.10.116.31] ([10.10.116.31]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2RGaAvm022049 for ; Fri, 27 Mar 2015 12:36:11 -0400 Message-ID: <551586F7.8010106@redhat.com> Date: Fri, 27 Mar 2015 16:36:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/65509 (constexpr address comparison) Content-Type: multipart/mixed; boundary="------------050603000703000104010904" X-SW-Source: 2015-03/txt/msg01450.txt.bz2 This is a multi-part message in MIME format. --------------050603000703000104010904 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 354 This was breaking because ancient code in the front end to avoid emitting unreferenced static const variables was preventing the vdefinition flag from being set on the varpool node for the variables. Now that we have cgraph controlling what gets emitted, there is no point in keeping this code around. Tested x86_64-pc-linux-gnu, applying to trunk. --------------050603000703000104010904 Content-Type: text/x-patch; name="65509.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="65509.patch" Content-length: 2304 commit 3fac157f5884e88d15a42b9c3136fd0e7024595a Author: Jason Merrill Date: Fri Mar 27 12:01:44 2015 -0400 PR c++/65509 * decl.c (make_rtl_for_nonlocal_decl): Don't defer static constants. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index cb0f11f..f05aefa 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6061,7 +6061,6 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec) { int toplev = toplevel_bindings_p (); int defer_p; - const char *filename; /* Set the DECL_ASSEMBLER_NAME for the object. */ if (asmspec) @@ -6109,32 +6108,9 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec) DECL_EXPR is expanded. */ defer_p = DECL_FUNCTION_SCOPE_P (decl) || DECL_VIRTUAL_P (decl); - /* We try to defer namespace-scope static constants so that they are - not emitted into the object file unnecessarily. */ - filename = LOCATION_FILE (input_location); - if (!DECL_VIRTUAL_P (decl) - && TREE_READONLY (decl) - && DECL_INITIAL (decl) != NULL_TREE - && DECL_INITIAL (decl) != error_mark_node - && filename != NULL - && ! EMPTY_CONSTRUCTOR_P (DECL_INITIAL (decl)) - && toplev - && !TREE_PUBLIC (decl)) - { - /* Fool with the linkage of static consts according to #pragma - interface. */ - struct c_fileinfo *finfo = get_fileinfo (filename); - if (!finfo->interface_unknown && !TREE_PUBLIC (decl)) - { - TREE_PUBLIC (decl) = 1; - DECL_EXTERNAL (decl) = finfo->interface_only; - } - - defer_p = 1; - } - /* Likewise for template instantiations. */ - else if (DECL_LANG_SPECIFIC (decl) - && DECL_IMPLICIT_INSTANTIATION (decl)) + /* Defer template instantiations. */ + if (DECL_LANG_SPECIFIC (decl) + && DECL_IMPLICIT_INSTANTIATION (decl)) defer_p = 1; /* If we're not deferring, go ahead and assemble the variable. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrcomp1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrcomp1.C new file mode 100644 index 0000000..2eee1b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrcomp1.C @@ -0,0 +1,8 @@ +// PR c++/65509 +// { dg-do compile { target c++11 } } + +const int i1 = 1; +const int i2 = 2; + +#define SA(X) static_assert (X,#X) +SA(&i1 != &i2); --------------050603000703000104010904--