This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: PR c++/17775
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 3 Oct 2005 10:24:36 -0700
- Subject: PATCH: PR c++/17775
- Reply-to: mark at codesourcery dot com
This PR is about an -frepo failure when a mangled name depends on a
anonymous namespace. Since we randomize the anonymous namespace name,
we don't get the same mangled names when we recompile. Fixed by
providing the -frandom-seed= option to subsequent compilations.
Tested on x86_64-unkonwn-linux-gnu, applied on the mainline and on the
4.0 branch.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2005-10-03 Mark Mitchell <mark@codesourcery.com>
PR c++/17775
* repo.c: Include flags.h.
(finish_repo): Add -frandom-seed to the arguments.
2005-10-03 Mark Mitchell <mark@codesourcery.com>
PR c++/17775
* g++.dg/template/repo4.C: New test.
Index: gcc/cp/repo.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/repo.c,v
retrieving revision 1.59
diff -c -5 -p -r1.59 repo.c
*** gcc/cp/repo.c 16 Jul 2005 00:25:01 -0000 1.59
--- gcc/cp/repo.c 3 Oct 2005 15:47:55 -0000
*************** Boston, MA 02110-1301, USA. */
*** 34,43 ****
--- 34,44 ----
#include "cp-tree.h"
#include "input.h"
#include "obstack.h"
#include "toplev.h"
#include "diagnostic.h"
+ #include "flags.h"
static char *extract_string (char **);
static const char *get_base_filename (const char *);
static void open_repo_file (const char *);
static char *afgets (FILE *);
*************** finish_repo (void)
*** 237,247 ****
fprintf (repo_file, "M %s\n", main_input_filename);
dir = getpwd ();
fprintf (repo_file, "D %s\n", dir);
args = getenv ("COLLECT_GCC_OPTIONS");
if (args)
! fprintf (repo_file, "A %s\n", args);
for (t = pending_repo; t; t = TREE_CHAIN (t))
{
tree val = TREE_VALUE (t);
tree name = DECL_ASSEMBLER_NAME (val);
--- 238,257 ----
fprintf (repo_file, "M %s\n", main_input_filename);
dir = getpwd ();
fprintf (repo_file, "D %s\n", dir);
args = getenv ("COLLECT_GCC_OPTIONS");
if (args)
! {
! fprintf (repo_file, "A %s", args);
! /* If -frandom-seed is not among the ARGS, then add the value
! that we chose. That will ensure that the names of types from
! anonymous namespaces will get the same mangling when this
! file is recompiled. */
! if (!strstr (args, "'-frandom-seed="))
! fprintf (repo_file, " '-frandom-seed=%s'", flag_random_seed);
! fprintf (repo_file, "\n");
! }
for (t = pending_repo; t; t = TREE_CHAIN (t))
{
tree val = TREE_VALUE (t);
tree name = DECL_ASSEMBLER_NAME (val);
Index: gcc/testsuite/g++.dg/template/repo4.C
===================================================================
RCS file: gcc/testsuite/g++.dg/template/repo4.C
diff -N gcc/testsuite/g++.dg/template/repo4.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/g++.dg/template/repo4.C 3 Oct 2005 15:47:55 -0000
***************
*** 0 ****
--- 1,16 ----
+ // PR c++/17775
+ // { dg-options "-frepo" }
+ // { dg-final { cleanup-repo-files } }
+
+ namespace {
+ struct Foo {};
+ }
+
+ template <typename Tp>
+ void foo(Tp) {}
+
+ int
+ main()
+ {
+ foo(Foo());
+ }