diff options
author | Jason Merrill <jason@redhat.com> | 2015-11-12 15:37:46 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2015-11-12 15:37:46 -0500 |
commit | 84edfc8aef7aabeaa5086e6a82f2d74917ec8b95 (patch) | |
tree | ddf60d660fd53d0909bb937bb96a2c465d07f1d5 /gcc | |
parent | 633ce9715781eb43a5e0af1858cfa861c3a86113 (diff) | |
download | gcc-84edfc8aef7aabeaa5086e6a82f2d74917ec8b95.zip gcc-84edfc8aef7aabeaa5086e6a82f2d74917ec8b95.tar.gz gcc-84edfc8aef7aabeaa5086e6a82f2d74917ec8b95.tar.bz2 |
pt.c (check_explicit_specialization): Check the namespace after we choose a template.
* pt.c (check_explicit_specialization): Check the namespace after
we choose a template.
From-SVN: r230271
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/pt.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/explicit-instantiation4.C | 7 |
3 files changed, 20 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d1bf121..9a02de2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-11-12 Jason Merrill <jason@redhat.com> + + * pt.c (check_explicit_specialization): Check the namespace after + we choose a template. + 2015-11-11 Jason Merrill <jason@redhat.com> * decl.c (duplicate_decls): When combining typedefs, remove the diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 62659ec..2e3d48b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2800,14 +2800,6 @@ check_explicit_specialization (tree declarator, error ("%qD is not a template function", dname); fns = error_mark_node; } - else - { - tree fn = OVL_CURRENT (fns); - if (!is_associated_namespace (CP_DECL_CONTEXT (decl), - CP_DECL_CONTEXT (fn))) - error ("%qD is not declared in %qD", - decl, current_namespace); - } } declarator = lookup_template_function (fns, NULL_TREE); @@ -2941,6 +2933,14 @@ check_explicit_specialization (tree declarator, return error_mark_node; else { + if (!ctype && !was_template_id + && (specialization || member_specialization + || explicit_instantiation) + && !is_associated_namespace (CP_DECL_CONTEXT (decl), + CP_DECL_CONTEXT (tmpl))) + error ("%qD is not declared in %qD", + tmpl, current_namespace); + tree gen_tmpl = most_general_template (tmpl); if (explicit_instantiation) diff --git a/gcc/testsuite/g++.dg/template/explicit-instantiation4.C b/gcc/testsuite/g++.dg/template/explicit-instantiation4.C new file mode 100644 index 0000000..72417b4 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/explicit-instantiation4.C @@ -0,0 +1,7 @@ +void f(); + +namespace A { + template <class T> void f(T) { } + using ::f; + template void f(int); +} |