From 37009aa5d3b4e6f588efdda87bcbb6a4dd303ab0 Mon Sep 17 00:00:00 2001 From: lerdsuwa Date: Sun, 26 Oct 2003 11:04:36 +0000 Subject: [PATCH] PR c++/10371 * semantics.c (finish_non_static_data_member): Handle when both processing_template_decl and qualifying_scope are true. * g++.dg/lookup/scoped8.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72950 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 9 ++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/lookup/scoped8.C | 16 ++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/lookup/scoped8.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0d1cd91..0b7e809 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-10-26 Kriang Lerdsuwanakij + + PR c++/10371 + * semantics.c (finish_non_static_data_member): Handle when + both processing_template_decl and qualifying_scope are true. + 2003-10-24 Kriang Lerdsuwanakij PR c++/11076 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index b55059d..13d8734 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1224,7 +1224,7 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope) return error_mark_node; } TREE_USED (current_class_ptr) = 1; - if (processing_template_decl) + if (processing_template_decl && !qualifying_scope) { tree type = TREE_TYPE (decl); @@ -1263,6 +1263,13 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope) } } + /* If PROCESSING_TEMPLATE_DECL is non-zero here, then + QUALIFYING_SCOPE is also non-null. Wrap this in a SCOPE_REF + for now. */ + if (processing_template_decl) + return build_min (SCOPE_REF, TREE_TYPE (decl), + qualifying_scope, DECL_NAME (decl)); + perform_or_defer_access_check (TYPE_BINFO (access_type), decl); /* If the data member was named `C::M', convert `*this' to `C' diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 28a067b..47a7512 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-10-26 Kriang Lerdsuwanakij + + PR c++/10371 + * g++.dg/lookup/scoped8.C: New test. + 2003-10-25 Eric Botcazou * g++.dg/opt/reg-stack3.C: New test. diff --git a/gcc/testsuite/g++.dg/lookup/scoped8.C b/gcc/testsuite/g++.dg/lookup/scoped8.C new file mode 100644 index 0000000..1c30304 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/scoped8.C @@ -0,0 +1,16 @@ +// { dg-do compile } + +// Origin: Volker Reichelt + +// PR c++/10371: Incorrect tree node built in +// finish_non_static_data_member. + +struct A +{ + int i; // { dg-error "object missing" } +}; + +template struct B +{ + int foo() { return A::i; } // { dg-error "this location" } +}; -- 2.7.4