aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-11-02 22:37:35 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2007-11-02 22:37:35 +0100
commiteba5fc70add5affbea167c0084fdfc39acba5bac (patch)
treeba29739d0ecf05b40f1009692a1b470d1790c5c4 /gcc
parent444a356a3bc8de75d802214b2ef110ebec78a72c (diff)
downloadgcc-eba5fc70add5affbea167c0084fdfc39acba5bac.zip
gcc-eba5fc70add5affbea167c0084fdfc39acba5bac.tar.gz
gcc-eba5fc70add5affbea167c0084fdfc39acba5bac.tar.bz2
re PR c++/33516 (Rejects typedef qualified name-lookup)
PR c++/33516 * parser.c (cp_parser_nested_name_specifier_opt): Use TYPE_MAIN_VARIANT (new_scope) as scope if new_scope is an incomplete typedef of currently open class. * g++.dg/lookup/typedef1.C: New test. From-SVN: r129862
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/parser.c10
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/lookup/typedef1.C32
4 files changed, 53 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3a90378..1acce71 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2007-11-02 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/33516
+ * parser.c (cp_parser_nested_name_specifier_opt): Use
+ TYPE_MAIN_VARIANT (new_scope) as scope if new_scope is an incomplete
+ typedef of currently open class.
+
2007-11-02 Paolo Carlini <pcarlini@suse.de>
PR c++/33495
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 7734cc1..0772c87 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -4085,7 +4085,15 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser,
&& !COMPLETE_TYPE_P (new_scope)
/* Do not try to complete dependent types. */
&& !dependent_type_p (new_scope))
- new_scope = complete_type (new_scope);
+ {
+ new_scope = complete_type (new_scope);
+ /* If it is a typedef to current class, use the current
+ class instead, as the typedef won't have any names inside
+ it yet. */
+ if (!COMPLETE_TYPE_P (new_scope)
+ && currently_open_class (new_scope))
+ new_scope = TYPE_MAIN_VARIANT (new_scope);
+ }
/* Make sure we look in the right scope the next time through
the loop. */
parser->scope = new_scope;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 514829c..ccd4ccb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-11-02 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/33516
+ * g++.dg/lookup/typedef1.C: New test.
+
2007-11-02 Janis Johnson <janis187@us.ibm.com>
PR testsuite/32076
diff --git a/gcc/testsuite/g++.dg/lookup/typedef1.C b/gcc/testsuite/g++.dg/lookup/typedef1.C
new file mode 100644
index 0000000..f712fc2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/typedef1.C
@@ -0,0 +1,32 @@
+// PR c++/33516
+// { dg-do compile }
+
+struct S1;
+typedef S1 T1;
+struct S1 {
+ typedef int U;
+ T1::U i;
+};
+struct S2;
+typedef S2 T2;
+struct S2 {
+ typedef int U;
+};
+T2::U j;
+struct S3;
+typedef S3 T3;
+struct S3 {
+ typedef int U;
+ S3::U i;
+};
+
+void
+foo ()
+{
+ S1 s1;
+ S2 s2;
+ S3 s3;
+ s1.i = 6;
+ j = 7;
+ s3.i = 8;
+}