From d6eec20888fbdf6eca96fb0ea0f1bc2c24af9eec Mon Sep 17 00:00:00 2001
From: Mark Mitchell <mark@codesourcery.com>
Date: Wed, 24 Nov 2004 17:57:00 +0000
Subject: [PATCH] re PR c++/18530 (Bogus warnings about shadowed variables
 __ct, __dt)

	PR c++/18530
	* cp-tree.h (CTOR_NAME): Remove.
	(DTOR_NAME): Remove.
	* decl.c (initialize_predefined_identifiers): Add spaces to the
	end of constructor and destructor names.

	PR c++/18530
	* g++.dg/warn/Wshadow-3.C: New test.

From-SVN: r91179
---
 gcc/cp/ChangeLog                      |  8 ++++++++
 gcc/cp/cp-tree.h                      |  2 --
 gcc/cp/decl.c                         | 16 +++++++++-------
 gcc/testsuite/ChangeLog               |  5 +++++
 gcc/testsuite/g++.dg/warn/Wshadow-3.C |  8 ++++++++
 5 files changed, 30 insertions(+), 9 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/warn/Wshadow-3.C

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8797df9d516e..faf73ad89fd3 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2004-11-24  Mark Mitchell  <mark@codesourcery.com>
+
+	PR c++/18530
+	* cp-tree.h (CTOR_NAME): Remove.
+	(DTOR_NAME): Remove.
+	* decl.c (initialize_predefined_identifiers): Add spaces to the
+	end of constructor and destructor names.
+
 2004-11-24  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
 
 	PR c++/8929
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 40979fb21a32..64f5ab9b8ada 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3162,8 +3162,6 @@ extern GTY(()) varray_type local_classes;
 #endif	/* NO_DOLLAR_IN_LABEL */
 
 #define THIS_NAME "this"
-#define CTOR_NAME "__ct"
-#define DTOR_NAME "__dt"
 
 #define IN_CHARGE_NAME "__in_chrg"
 
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index bca328846e55..258ae43baea3 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2923,13 +2923,15 @@ initialize_predefined_identifiers (void)
     { "C++", &lang_name_cplusplus, 0 },
     { "C", &lang_name_c, 0 },
     { "Java", &lang_name_java, 0 },
-    { CTOR_NAME, &ctor_identifier, 1 },
-    { "__base_ctor", &base_ctor_identifier, 1 },
-    { "__comp_ctor", &complete_ctor_identifier, 1 },
-    { DTOR_NAME, &dtor_identifier, 1 },
-    { "__comp_dtor", &complete_dtor_identifier, 1 },
-    { "__base_dtor", &base_dtor_identifier, 1 },
-    { "__deleting_dtor", &deleting_dtor_identifier, 1 },
+    /* Some of these names have a trailing space so that it is
+       impossible for them to conflict with names written by users.  */
+    { "__ct ", &ctor_identifier, 1 },
+    { "__base_ctor ", &base_ctor_identifier, 1 },
+    { "__comp_ctor ", &complete_ctor_identifier, 1 },
+    { "__dt ", &dtor_identifier, 1 },
+    { "__comp_dtor ", &complete_dtor_identifier, 1 },
+    { "__base_dtor ", &base_dtor_identifier, 1 },
+    { "__deleting_dtor ", &deleting_dtor_identifier, 1 },
     { IN_CHARGE_NAME, &in_charge_identifier, 0 },
     { "nelts", &nelts_identifier, 0 },
     { THIS_NAME, &this_identifier, 0 },
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cb68c281d228..03014a1ee3f3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2004-11-24  Mark Mitchell  <mark@codesourcery.com>
+
+	PR c++/18530
+	* g++.dg/warn/Wshadow-3.C: New test.
+
 2004-11-24  Devang Patel  <dpatel@apple.com>
 
 	PR/18555
diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-3.C b/gcc/testsuite/g++.dg/warn/Wshadow-3.C
new file mode 100644
index 000000000000..99add19a4357
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wshadow-3.C
@@ -0,0 +1,8 @@
+// PR c++/18530
+// { dg-options "-Wshadow" }
+
+struct A {
+  A();
+  ~A();
+  void foo (int __ct, int __dt) {}
+};
-- 
GitLab