diff options
author | Mark Mitchell <mark@codesourcery.com> | 1999-05-28 00:20:07 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1999-05-28 00:20:07 +0000 |
commit | f30c84c9668a1b7e5d7cde91bb9f240ac2a995b2 (patch) | |
tree | d1c816cc0aaeebf4e5d1ab28dbb3754530ed32da /gcc | |
parent | 6f82ce7097e73aae0154ee1d1af286c63246c4a8 (diff) | |
download | gcc-f30c84c9668a1b7e5d7cde91bb9f240ac2a995b2.zip gcc-f30c84c9668a1b7e5d7cde91bb9f240ac2a995b2.tar.gz gcc-f30c84c9668a1b7e5d7cde91bb9f240ac2a995b2.tar.bz2 |
decl.c (lookup_namespace_name): Handle getting a TEMPLATE_ID_EXPR.
* decl.c (lookup_namespace_name): Handle getting a
TEMPLATE_ID_EXPR.
(expand_static_init): Don't call pushdecl for implicitly declared
`atexit' used to register destructors.
From-SVN: r27207
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/decl.c | 44 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.ns/template10.C | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/debug3.C | 22 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/static5.C | 16 |
5 files changed, 92 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 32de5b1..301199a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +1999-05-28 Mark Mitchell <mark@codesourcery.com> + + * decl.c (lookup_namespace_name): Handle getting a + TEMPLATE_ID_EXPR. + (expand_static_init): Don't call pushdecl for implicitly declared + `atexit' used to register destructors. + 1999-05-25 Mark Mitchell <mark@codesourcery.com> * class.c (finish_vtbls): Copy BINFO_VIRTUALs before using it to diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d990a82..0b2d588 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5326,6 +5326,7 @@ lookup_namespace_name (namespace, name) { struct tree_binding _b; tree val; + tree template_id = NULL_TREE; my_friendly_assert (TREE_CODE (namespace) == NAMESPACE_DECL, 370); @@ -5342,6 +5343,16 @@ lookup_namespace_name (namespace, name) namespace = ORIGINAL_NAMESPACE (namespace); + if (TREE_CODE (name) == TEMPLATE_ID_EXPR) + { + template_id = name; + name = TREE_OPERAND (name, 0); + if (TREE_CODE (name) == OVERLOAD) + name = DECL_NAME (OVL_CURRENT (name)); + else if (TREE_CODE_CLASS (TREE_CODE (name)) == 'd') + name = DECL_NAME (name); + } + my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 373); val = binding_init (&_b); @@ -5352,6 +5363,26 @@ lookup_namespace_name (namespace, name) { val = BINDING_VALUE (val); + if (template_id) + { + if (DECL_CLASS_TEMPLATE_P (val)) + val = lookup_template_class (val, + TREE_OPERAND (template_id, 1), + /*in_decl=*/NULL_TREE, + /*context=*/NULL_TREE, + /*entering_scope=*/0); + else if (DECL_FUNCTION_TEMPLATE_P (val) + || TREE_CODE (val) == OVERLOAD) + val = lookup_template_function (val, + TREE_OPERAND (template_id, 1)); + else + { + cp_error ("`%D::%D' is not a template", + namespace, name); + return error_mark_node; + } + } + /* If we have a single function from a using decl, pull it out. */ if (TREE_CODE (val) == OVERLOAD && ! really_overloaded_fn (val)) val = OVL_FUNCTION (val); @@ -8479,11 +8510,16 @@ expand_static_init (decl, init) pfvlist = tree_cons (NULL_TREE, PFV, void_list_node); push_lang_context (lang_name_c); + /* Note that we do not call pushdecl for this function; + there's no reason that this declaration should be + accessible to anyone. */ atexit_fndecl - = builtin_function ("atexit", - build_function_type (void_type_node, - pfvlist), - NOT_BUILT_IN, NULL_PTR); + = define_function ("atexit", + build_function_type (void_type_node, + pfvlist), + NOT_BUILT_IN, + /*pfn=*/0, + NULL_PTR); mark_used (atexit_fndecl); Atexit = default_conversion (atexit_fndecl); pop_lang_context (); diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template10.C b/gcc/testsuite/g++.old-deja/g++.ns/template10.C new file mode 100644 index 0000000..709844e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template10.C @@ -0,0 +1,7 @@ +// Build don't link: +// Origin: Manuel Menezes de Sequeira <mms@torga.iscte.pt> + +namespace N { + template <class T> void g() {} +} +void (*pf)() = N::g<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.other/debug3.C b/gcc/testsuite/g++.old-deja/g++.other/debug3.C new file mode 100644 index 0000000..d1c8cf7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/debug3.C @@ -0,0 +1,22 @@ +// Build don't link: +// Origin: Mark Mitchell <mark@codesourcery.com> +// Special g++ Options: -O2 + +struct S +{ + ~S(); +}; + +inline void f() +{ + static S s; +} + +typedef void (*fn_t)(); + +fn_t g() +{ + return &f; +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.other/static5.C b/gcc/testsuite/g++.old-deja/g++.other/static5.C new file mode 100644 index 0000000..aedecf2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static5.C @@ -0,0 +1,16 @@ +// Build don't link: +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ + ~S(); +}; + +inline void f() +{ + static S s; + atexit (0); // ERROR - implicit declaration +} + + + |