re PR c++/65509 ([C++11] GCC rejects operator== with two distinct pointers as not...
authorJason Merrill <jason@redhat.com>
Fri, 27 Mar 2015 16:36:32 +0000 (12:36 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 27 Mar 2015 16:36:32 +0000 (12:36 -0400)
PR c++/65509
* decl.c (make_rtl_for_nonlocal_decl): Don't defer static
constants.

From-SVN: r221737

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/cpp0x/constexpr-ptrcomp1.C [new file with mode: 0644]

index 684129b2200cf05abea199dcc8ccd36f04bd869d..baed6e14732f620b87f2e8b0c4cc819574e056ec 100644 (file)
@@ -1,3 +1,9 @@
+2015-03-27  Jason Merrill  <jason@redhat.com>
+
+       PR c++/65509
+       * decl.c (make_rtl_for_nonlocal_decl): Don't defer static
+       constants.
+
 2015-03-26  Mikhail Maltsev  <maltsevm@gmail.com>
 
        PR c++/65154
index cb0f11f5749f03d77d7ee27fcd06f1895b06972c..f05aefaddfbac364b0b24a0483419845c8327048 100644 (file)
@@ -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 (file)
index 0000000..2eee1b0
--- /dev/null
@@ -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);