aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-04-25 08:31:19 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-04-25 08:31:19 +0000
commit6bda7a5e41bfca06a2cfdabbeb1c49948c8ab9eb (patch)
treeef721534e660501653ea55caa7abccbc52394844
parent12da8316cc54ad403a1c9dc5cd236c3f34727cd5 (diff)
downloadgcc-6bda7a5e41bfca06a2cfdabbeb1c49948c8ab9eb.zip
gcc-6bda7a5e41bfca06a2cfdabbeb1c49948c8ab9eb.tar.gz
gcc-6bda7a5e41bfca06a2cfdabbeb1c49948c8ab9eb.tar.bz2
decl.c (grokdeclarator): Set context of namespace scope TYPE_DECLS.
cp: * decl.c (grokdeclarator): Set context of namespace scope TYPE_DECLS. testsuite: * g++.old-deja/g++.ns/type2.C: New test. From-SVN: r41533
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c8
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.ns/type2.C19
4 files changed, 34 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 618ba0d..4ea7d43 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2001-04-25 Nathan Sidwell <nathan@codesourcery.com>
+
+ * decl.c (grokdeclarator): Set context of namespace scope
+ TYPE_DECLS.
+
2001-04-24 Zack Weinberg <zackw@stanford.edu>
* cp/optimize.c: Include hashtab.h.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 834e2dc..ea37eb4 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -11035,8 +11035,12 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
decl = build_lang_decl (TYPE_DECL, declarator, type);
}
else
- decl = build_decl (TYPE_DECL, declarator, type);
-
+ {
+ decl = build_decl (TYPE_DECL, declarator, type);
+ if (!current_function_decl)
+ DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace);
+ }
+
/* If the user declares "typedef struct {...} foo" then the
struct will have an anonymous name. Fill that name in now.
Nothing can refer to it, so nothing needs know about the name
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 39abc4e..a0f0f25 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2001-04-25 Nathan Sidwell <nathan@codesourcery.com>
+
+ * g++.old-deja/g++.ns/type2.C: New test.
+
2001-04-24 Zack Weinberg <zackw@stanford.edu>
* g++.old-deja/g++.other/perf1.C: New test.
diff --git a/gcc/testsuite/g++.old-deja/g++.ns/type2.C b/gcc/testsuite/g++.old-deja/g++.ns/type2.C
new file mode 100644
index 0000000..d8407b1
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.ns/type2.C
@@ -0,0 +1,19 @@
+// Build don't link:
+//
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 11 April 2001 <nathan@codesourcery.com>
+// Origin:stephen.webb@cybersafe.com
+
+// Bug 2125. TYPE_DECLS never had their DECL_CONTEXT set, which
+// confused forward references to classes.
+
+typedef void T;
+namespace A {
+ class C;
+ typedef class C C;
+ typedef int T;
+ class C
+ {
+ T i; // got bogus error, found wrong T
+ };
+}