Commit 7813d14c by Mark Mitchell Committed by Mark Mitchell

re PR c++/12862 (Conflicts Between typedefs/enums and Namespace Member Declarations)

	* c-common.c (flag_external_templates): Remove.
	(flag_alt_external_templates): Likewise.
	* c-common.h (flag_external_templates): Remove.
	(flag_alt_external_templates): Likewise.
	* c-opts.c (c_common_handle_option): Unsupport
	-falt-external-templates and -ftemplates.
	* doc/invoke.texi: Remove mention of -fexternal-templates and
	-falt-external-templates.

	* decl.c (start_function): Do not check
	flag_alt_external_templates or flag_external_templates.
	* decl2.c (warn_if_unknown_interface): Likewise.
	* lex.c (extract_interface_info): Likewise.
	* pt.c (lookup_template_class): Likewise.

	PR c++/12862
	* name-lookup.c (pushdecl): Look up all namespace-scope entities
	in their corresponding namespace.

	* g++.old-deja/g++.jason/template18.C: Remove.
	* g++.old-deja/g++.jason/template37.C: Likewise.

	PR c++/12862
	* g++.dg/lookup/ns1.C: New test.

From-SVN: r74954
parent 1c8cfe03
2003-12-22 Mark Mitchell <mark@codesourcery.com>
* c-common.c (flag_external_templates): Remove.
(flag_alt_external_templates): Likewise.
* c-common.h (flag_external_templates): Remove.
(flag_alt_external_templates): Likewise.
* c-opts.c (c_common_handle_option): Unsupport
-falt-external-templates and -ftemplates.
* doc/invoke.texi: Remove mention of -fexternal-templates and
-falt-external-templates.
2003-12-22 Andrew Pinski <pinskia@physics.uc.edu> 2003-12-22 Andrew Pinski <pinskia@physics.uc.edu>
PR target/13466 PR target/13466
......
...@@ -510,17 +510,6 @@ int flag_no_gnu_keywords; ...@@ -510,17 +510,6 @@ int flag_no_gnu_keywords;
int flag_implement_inlines = 1; int flag_implement_inlines = 1;
/* Nonzero means do emit exported implementations of templates, instead of
multiple static copies in each file that needs a definition. */
int flag_external_templates;
/* Nonzero means that the decision to emit or not emit the implementation of a
template depends on where the template is instantiated, rather than where
it is defined. */
int flag_alt_external_templates;
/* Nonzero means that implicit instantiations will be emitted if needed. */ /* Nonzero means that implicit instantiations will be emitted if needed. */
int flag_implicit_templates = 1; int flag_implicit_templates = 1;
......
...@@ -674,17 +674,6 @@ extern int flag_no_gnu_keywords; ...@@ -674,17 +674,6 @@ extern int flag_no_gnu_keywords;
extern int flag_implement_inlines; extern int flag_implement_inlines;
/* Nonzero means do emit exported implementations of templates, instead of
multiple static copies in each file that needs a definition. */
extern int flag_external_templates;
/* Nonzero means that the decision to emit or not emit the implementation of a
template depends on where the template is instantiated, rather than where
it is defined. */
extern int flag_alt_external_templates;
/* Nonzero means that implicit instantiations will be emitted if needed. */ /* Nonzero means that implicit instantiations will be emitted if needed. */
extern int flag_implicit_templates; extern int flag_implicit_templates;
......
...@@ -672,7 +672,9 @@ c_common_handle_option (size_t scode, const char *arg, int value) ...@@ -672,7 +672,9 @@ c_common_handle_option (size_t scode, const char *arg, int value)
/* Fall through. */ /* Fall through. */
case OPT_fall_virtual: case OPT_fall_virtual:
case OPT_falt_external_templates:
case OPT_fenum_int_equiv: case OPT_fenum_int_equiv:
case OPT_fexternal_templates:
case OPT_fguiding_decls: case OPT_fguiding_decls:
case OPT_fhonor_std: case OPT_fhonor_std:
case OPT_fhuge_objects: case OPT_fhuge_objects:
...@@ -697,15 +699,6 @@ c_common_handle_option (size_t scode, const char *arg, int value) ...@@ -697,15 +699,6 @@ c_common_handle_option (size_t scode, const char *arg, int value)
flag_access_control = value; flag_access_control = value;
break; break;
case OPT_falt_external_templates:
flag_alt_external_templates = value;
if (value)
flag_external_templates = true;
cp_deprecated:
warning ("switch \"%s\" is deprecated, please see documentation "
"for details", option->opt_text);
break;
case OPT_fasm: case OPT_fasm:
flag_no_asm = !value; flag_no_asm = !value;
break; break;
...@@ -799,10 +792,6 @@ c_common_handle_option (size_t scode, const char *arg, int value) ...@@ -799,10 +792,6 @@ c_common_handle_option (size_t scode, const char *arg, int value)
flag_enforce_eh_specs = value; flag_enforce_eh_specs = value;
break; break;
case OPT_fexternal_templates:
flag_external_templates = value;
goto cp_deprecated;
case OPT_ffixed_form: case OPT_ffixed_form:
case OPT_ffixed_line_length_: case OPT_ffixed_line_length_:
/* Fortran front end options ignored when preprocessing only. */ /* Fortran front end options ignored when preprocessing only. */
......
2003-12-22 Mark Mitchell <mark@codesourcery.com> 2003-12-22 Mark Mitchell <mark@codesourcery.com>
* decl.c (start_function): Do not check
flag_alt_external_templates or flag_external_templates.
* decl2.c (warn_if_unknown_interface): Likewise.
* lex.c (extract_interface_info): Likewise.
* pt.c (lookup_template_class): Likewise.
PR c++/12862
* name-lookup.c (pushdecl): Look up all namespace-scope entities
in their corresponding namespace.
PR c++/12397 PR c++/12397
* typeck.c (finish_class_member_access_expr): Don't tree * typeck.c (finish_class_member_access_expr): Don't tree
IDENTIFIER_NODEs as non-dependent expressions. IDENTIFIER_NODEs as non-dependent expressions.
......
...@@ -10310,8 +10310,7 @@ start_function (tree declspecs, tree declarator, tree attrs, int flags) ...@@ -10310,8 +10310,7 @@ start_function (tree declspecs, tree declarator, tree attrs, int flags)
If it belongs to someone else's interface, it is also external. If it belongs to someone else's interface, it is also external.
This only affects inlines and template instantiations. */ This only affects inlines and template instantiations. */
else if (interface_unknown == 0 else if (interface_unknown == 0
&& (! DECL_TEMPLATE_INSTANTIATION (decl1) && ! DECL_TEMPLATE_INSTANTIATION (decl1))
|| flag_alt_external_templates))
{ {
if (DECL_DECLARED_INLINE_P (decl1) if (DECL_DECLARED_INLINE_P (decl1)
|| DECL_TEMPLATE_INSTANTIATION (decl1) || DECL_TEMPLATE_INSTANTIATION (decl1)
...@@ -10332,8 +10331,7 @@ start_function (tree declspecs, tree declarator, tree attrs, int flags) ...@@ -10332,8 +10331,7 @@ start_function (tree declspecs, tree declarator, tree attrs, int flags)
DECL_INTERFACE_KNOWN (decl1) = 1; DECL_INTERFACE_KNOWN (decl1) = 1;
} }
else if (interface_unknown && interface_only else if (interface_unknown && interface_only
&& (! DECL_TEMPLATE_INSTANTIATION (decl1) && ! DECL_TEMPLATE_INSTANTIATION (decl1))
|| flag_alt_external_templates))
{ {
/* If MULTIPLE_SYMBOL_SPACES is defined and we saw a #pragma /* If MULTIPLE_SYMBOL_SPACES is defined and we saw a #pragma
interface, we will have interface_only set but not interface, we will have interface_only set but not
......
...@@ -167,23 +167,8 @@ warn_if_unknown_interface (tree decl) ...@@ -167,23 +167,8 @@ warn_if_unknown_interface (tree decl)
if (already_warned++) if (already_warned++)
return; return;
if (flag_alt_external_templates) cp_warning_at ("template `%#D' defined in file without #pragma interface",
{ decl);
tree til = tinst_for_decl ();
location_t saved_loc = input_location;
if (til)
{
input_line = TINST_LINE (til);
input_filename = TINST_FILE (til);
}
warning ("template `%#D' instantiated in file without #pragma interface",
decl);
input_location = saved_loc;
}
else
cp_warning_at ("template `%#D' defined in file without #pragma interface",
decl);
} }
/* A subroutine of the parser, to handle a component list. */ /* A subroutine of the parser, to handle a component list. */
......
...@@ -436,18 +436,9 @@ cxx_init (void) ...@@ -436,18 +436,9 @@ cxx_init (void)
void void
extract_interface_info (void) extract_interface_info (void)
{ {
struct c_fileinfo *finfo = 0; struct c_fileinfo *finfo;
if (flag_alt_external_templates)
{
tree til = tinst_for_decl ();
if (til)
finfo = get_fileinfo (TINST_FILE (til));
}
if (!finfo)
finfo = get_fileinfo (input_filename);
finfo = get_fileinfo (input_filename);
interface_only = finfo->interface_only; interface_only = finfo->interface_only;
interface_unknown = finfo->interface_unknown; interface_unknown = finfo->interface_unknown;
} }
......
...@@ -590,8 +590,7 @@ pushdecl (tree x) ...@@ -590,8 +590,7 @@ pushdecl (tree x)
/* In case this decl was explicitly namespace-qualified, look it /* In case this decl was explicitly namespace-qualified, look it
up in its namespace context. */ up in its namespace context. */
if (TREE_CODE (x) == VAR_DECL && DECL_NAMESPACE_SCOPE_P (x) if (DECL_NAMESPACE_SCOPE_P (x) && namespace_bindings_p ())
&& namespace_bindings_p ())
t = namespace_binding (name, DECL_CONTEXT (x)); t = namespace_binding (name, DECL_CONTEXT (x));
else else
t = lookup_name_current_level (name); t = lookup_name_current_level (name);
......
...@@ -4485,19 +4485,7 @@ lookup_template_class (tree d1, ...@@ -4485,19 +4485,7 @@ lookup_template_class (tree d1,
is set up. */ is set up. */
if (TREE_CODE (t) != ENUMERAL_TYPE) if (TREE_CODE (t) != ENUMERAL_TYPE)
DECL_NAME (type_decl) = classtype_mangled_name (t); DECL_NAME (type_decl) = classtype_mangled_name (t);
if (!is_partial_instantiation) if (is_partial_instantiation)
{
/* For backwards compatibility; code that uses
-fexternal-templates expects looking up a template to
instantiate it. I think DDD still relies on this.
(jason 8/20/1998) */
if (TREE_CODE (t) != ENUMERAL_TYPE
&& flag_external_templates
&& CLASSTYPE_INTERFACE_KNOWN (TREE_TYPE (template))
&& ! CLASSTYPE_INTERFACE_ONLY (TREE_TYPE (template)))
add_pending_template (t);
}
else
/* If the type makes use of template parameters, the /* If the type makes use of template parameters, the
code that generates debugging information will crash. */ code that generates debugging information will crash. */
DECL_IGNORED_P (TYPE_STUB_DECL (t)) = 1; DECL_IGNORED_P (TYPE_STUB_DECL (t)) = 1;
...@@ -5279,24 +5267,7 @@ instantiate_class_template (tree type) ...@@ -5279,24 +5267,7 @@ instantiate_class_template (tree type)
args = inner_args; args = inner_args;
} }
if (flag_external_templates) SET_CLASSTYPE_INTERFACE_UNKNOWN (type);
{
if (flag_alt_external_templates)
{
CLASSTYPE_INTERFACE_ONLY (type) = interface_only;
SET_CLASSTYPE_INTERFACE_UNKNOWN_X (type, interface_unknown);
}
else
{
CLASSTYPE_INTERFACE_ONLY (type) = CLASSTYPE_INTERFACE_ONLY (pattern);
SET_CLASSTYPE_INTERFACE_UNKNOWN_X
(type, CLASSTYPE_INTERFACE_UNKNOWN (pattern));
}
}
else
{
SET_CLASSTYPE_INTERFACE_UNKNOWN (type);
}
/* Set the input location to the template definition. This is needed /* Set the input location to the template definition. This is needed
if tsubsting causes an error. */ if tsubsting causes an error. */
...@@ -8642,9 +8613,6 @@ instantiate_template (tree tmpl, tree targ_ptr, tsubst_flags_t complain) ...@@ -8642,9 +8613,6 @@ instantiate_template (tree tmpl, tree targ_ptr, tsubst_flags_t complain)
template, not the most general template. */ template, not the most general template. */
DECL_TI_TEMPLATE (fndecl) = tmpl; DECL_TI_TEMPLATE (fndecl) = tmpl;
if (flag_external_templates)
add_pending_template (fndecl);
/* If we've just instantiated the main entry point for a function, /* If we've just instantiated the main entry point for a function,
instantiate all the alternate entry points as well. We do this instantiate all the alternate entry points as well. We do this
by cloning the instantiation of the main entry point, not by by cloning the instantiation of the main entry point, not by
...@@ -10529,9 +10497,6 @@ do_decl_instantiation (tree decl, tree storage) ...@@ -10529,9 +10497,6 @@ do_decl_instantiation (tree decl, tree storage)
return; return;
} }
if (flag_external_templates)
return;
if (storage == NULL_TREE) if (storage == NULL_TREE)
; ;
else if (storage == ridpointers[(int) RID_EXTERN]) else if (storage == ridpointers[(int) RID_EXTERN])
...@@ -10600,11 +10565,6 @@ do_type_instantiation (tree t, tree storage, tsubst_flags_t complain) ...@@ -10600,11 +10565,6 @@ do_type_instantiation (tree t, tree storage, tsubst_flags_t complain)
complete_type (t); complete_type (t);
/* With -fexternal-templates, explicit instantiations are treated the same
as implicit ones. */
if (flag_external_templates)
return;
if (!COMPLETE_TYPE_P (t)) if (!COMPLETE_TYPE_P (t))
{ {
if (complain & tf_error) if (complain & tf_error)
...@@ -10987,22 +10947,6 @@ instantiate_decl (tree d, int defer_ok) ...@@ -10987,22 +10947,6 @@ instantiate_decl (tree d, int defer_ok)
else else
repo_template_used (d); repo_template_used (d);
if (flag_external_templates && ! DECL_INTERFACE_KNOWN (d))
{
if (flag_alt_external_templates)
{
if (interface_unknown)
warn_if_unknown_interface (d);
}
else if (DECL_INTERFACE_KNOWN (code_pattern))
{
DECL_INTERFACE_KNOWN (d) = 1;
DECL_NOT_REALLY_EXTERN (d) = ! DECL_EXTERNAL (code_pattern);
}
else
warn_if_unknown_interface (code_pattern);
}
if (at_eof) if (at_eof)
import_export_decl (d); import_export_decl (d);
} }
......
...@@ -174,8 +174,7 @@ in the following sections. ...@@ -174,8 +174,7 @@ in the following sections.
@gccoptlist{-fabi-version=@var{n} -fno-access-control -fcheck-new @gol @gccoptlist{-fabi-version=@var{n} -fno-access-control -fcheck-new @gol
-fconserve-space -fno-const-strings @gol -fconserve-space -fno-const-strings @gol
-fno-elide-constructors @gol -fno-elide-constructors @gol
-fno-enforce-eh-specs -fexternal-templates @gol -fno-enforce-eh-specs @gol
-falt-external-templates @gol
-ffor-scope -fno-for-scope -fno-gnu-keywords @gol -ffor-scope -fno-for-scope -fno-gnu-keywords @gol
-fno-implicit-templates @gol -fno-implicit-templates @gol
-fno-implicit-inline-templates @gol -fno-implicit-inline-templates @gol
...@@ -1336,24 +1335,6 @@ option violates the C++ standard, but may be useful for reducing code ...@@ -1336,24 +1335,6 @@ option violates the C++ standard, but may be useful for reducing code
size in production builds, much like defining @samp{NDEBUG}. The compiler size in production builds, much like defining @samp{NDEBUG}. The compiler
will still optimize based on the exception specifications. will still optimize based on the exception specifications.
@item -fexternal-templates
@opindex fexternal-templates
Cause @samp{#pragma interface} and @samp{implementation} to apply to
template instantiation; template instances are emitted or not according
to the location of the template definition. @xref{Template
Instantiation}, for more information.
This option is deprecated.
@item -falt-external-templates
@opindex falt-external-templates
Similar to @option{-fexternal-templates}, but template instances are
emitted or not according to the place where they are first instantiated.
@xref{Template Instantiation}, for more information.
This option is deprecated.
@item -ffor-scope @item -ffor-scope
@itemx -fno-for-scope @itemx -fno-for-scope
@opindex ffor-scope @opindex ffor-scope
......
2003-12-22 Mark Mitchell <mark@codesourcery.com> 2003-12-22 Mark Mitchell <mark@codesourcery.com>
* g++.old-deja/g++.jason/template18.C: Remove.
* g++.old-deja/g++.jason/template37.C: Likewise.
PR c++/12862
* g++.dg/lookup/ns1.C: New test.
PR c++/12397 PR c++/12397
* g++.dg/template/lookup3.C: New test. * g++.dg/template/lookup3.C: New test.
......
// PR c++/12862
typedef int Thingo;
namespace A
{
void
Thingo();
}
void
A::Thingo()
{
;
}
int
main()
{
A::Thingo();
return 0;
}
// { dg-do link }
// { dg-options "-g -fno-inline -Wno-deprecated -fexternal-templates" }
// GROUPS passed templates
// Bug: g++ emits template instances when it shouldn't.
// Suppressed-instantiation tests like this are known to break on
// Cygwin, because of the MULTIPLE_SYMBOL_SPACES stuff. This is OK.
#pragma implementation "irrelevant_file"
#line 1 "template18.h"
#pragma interface
template <class T> inline T min (T a, T b) { return a<b?a:b; }
#line 13 "template18.C"
main()
{
min (1, 1); // { dg-error "" "" { target *-*-* } 0 } should produce an undefined symbol error.
}
// { dg-do run }
// { dg-options "-Wno-deprecated -fexternal-templates" }
// { dg-warning "switch.*deprecated" "" { target *-*-* } 0 }
// PRMS Id: 9930
// Test of -fexternal-templates hackery in new template code
#pragma implementation "foo.hh"
#pragma interface "foo.hh"
template<class T>
class ONE
{
public:
static void func();
};
template<class T>
void ONE<T>::func()
{
}
template <>
class ONE<int>
{
public:
static void func();
};
void ONE<int>::func()
{
}
int main()
{
ONE<char>::func();
ONE<int>::func();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment