public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: C++ PATCH for c++/65509 (constexpr address comparison)
Date: Fri, 27 Mar 2015 16:36:00 -0000	[thread overview]
Message-ID: <551586F7.8010106@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 354 bytes --]

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.

[-- Attachment #2: 65509.patch --]
[-- Type: text/x-patch, Size: 2304 bytes --]

commit 3fac157f5884e88d15a42b9c3136fd0e7024595a
Author: Jason Merrill <jason@redhat.com>
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);

                 reply	other threads:[~2015-03-27 16:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=551586F7.8010106@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).