Commit 2642b9bf by Jason Merrill Committed by Jason Merrill

decl.c (build_typename_type): Set DECL_ARTIFICIAL.

	* decl.c (build_typename_type): Set DECL_ARTIFICIAL.
	* error.c (dump_simple_decl): Also print namespace context.
	(dump_function_decl): Likewise.
	* decl2.c (ambiguous_decl): Don't print old value if it's
	error_mark_node.
	* decl.c (lookup_name_real): Fix handling of local types shadowed
	by a non-type decl.  Remove obsolete code.
	* cp-tree.h (DECL_FUNCTION_SCOPE_P): New macro.
Fixes g++.other/lookup6.C
	* lang-options.h: Add -fpermissive.
	* decl2.c: Likewise.
	* cp-tree.h: Add flag_permissive.
	* decl.c (init_decl_processing): If neither -fpermissive or -pedantic
	were specified, set flag_pedantic_errors.
	* call.c (build_over_call): Turn dropped qualifier messages
	back into pedwarns.
	* cvt.c (convert_to_reference): Likewise.
	* typeck.c (convert_for_assignment): Likewise.

From-SVN: r24150
parent 1db9f6ce
1998-12-07 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (build_typename_type): Set DECL_ARTIFICIAL.
* error.c (dump_simple_decl): Also print namespace context.
(dump_function_decl): Likewise.
* decl2.c (ambiguous_decl): Don't print old value if it's
error_mark_node.
* decl.c (lookup_name_real): Fix handling of local types shadowed
by a non-type decl. Remove obsolete code.
* cp-tree.h (DECL_FUNCTION_SCOPE_P): New macro.
* lang-options.h: Add -fpermissive.
* decl2.c: Likewise.
* cp-tree.h: Add flag_permissive.
* decl.c (init_decl_processing): If neither -fpermissive or -pedantic
were specified, set flag_pedantic_errors.
* call.c (build_over_call): Turn dropped qualifier messages
back into pedwarns.
* cvt.c (convert_to_reference): Likewise.
* typeck.c (convert_for_assignment): Likewise.
1998-12-05 Jason Merrill <jason@yorick.cygnus.com> 1998-12-05 Jason Merrill <jason@yorick.cygnus.com>
* decl2.c (coerce_new_type): Use same_type_p. * decl2.c (coerce_new_type): Use same_type_p.
......
*** Changes since EGCS 1.1:
* Messages about non-conformant code that we can still handle ("pedwarns")
are now errors by default, rather than warnings. This can be reverted
with -fpermissive, and is overridden by -pedantic or -pedantic-errors.
*** Changes in EGCS 1.1: *** Changes in EGCS 1.1:
* Namespaces are fully supported. The library has not yet been converted * Namespaces are fully supported. The library has not yet been converted
......
...@@ -3258,8 +3258,8 @@ build_over_call (cand, args, flags) ...@@ -3258,8 +3258,8 @@ build_over_call (cand, args, flags)
tree argtype = TREE_TYPE (TREE_VALUE (arg)); tree argtype = TREE_TYPE (TREE_VALUE (arg));
tree t; tree t;
if (ICS_BAD_FLAG (TREE_VEC_ELT (convs, i))) if (ICS_BAD_FLAG (TREE_VEC_ELT (convs, i)))
cp_error ("passing `%T' as `this' argument of `%#D' discards qualifiers", cp_pedwarn ("passing `%T' as `this' argument of `%#D' discards qualifiers",
TREE_TYPE (argtype), fn); TREE_TYPE (argtype), fn);
/* [class.mfct.nonstatic]: If a nonstatic member function of a class /* [class.mfct.nonstatic]: If a nonstatic member function of a class
X is called for an object that is not of type X, or of a type X is called for an object that is not of type X, or of a type
......
...@@ -498,11 +498,14 @@ extern int flag_optional_diags; ...@@ -498,11 +498,14 @@ extern int flag_optional_diags;
/* Nonzero means do not consider empty argument prototype to mean function /* Nonzero means do not consider empty argument prototype to mean function
takes no arguments. */ takes no arguments. */
extern int flag_strict_prototype; extern int flag_strict_prototype;
/* Nonzero means output .vtable_{entry,inherit} for use in doing vtable gc. */ /* Nonzero means output .vtable_{entry,inherit} for use in doing vtable gc. */
extern int flag_vtable_gc; extern int flag_vtable_gc;
/* Nonzero means make the default pedwarns warnings instead of errors.
The value of this flag is ignored if -pedantic is specified. */
int flag_permissive;
/* C++ language-specific tree codes. */ /* C++ language-specific tree codes. */
#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM, #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
...@@ -1286,6 +1289,11 @@ struct lang_decl ...@@ -1286,6 +1289,11 @@ struct lang_decl
(DECL_CONTEXT (NODE) \ (DECL_CONTEXT (NODE) \
&& TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (NODE))) == 't') && TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (NODE))) == 't')
/* 1 iff NODE is function-local. */
#define DECL_FUNCTION_SCOPE_P(NODE) \
(DECL_CONTEXT (NODE) \
&& TREE_CODE (DECL_CONTEXT (NODE)) == FUNCTION_DECL)
/* For a NAMESPACE_DECL: the list of using namespace directives /* For a NAMESPACE_DECL: the list of using namespace directives
The PURPOSE is the used namespace, the value is the namespace The PURPOSE is the used namespace, the value is the namespace
that is the common ancestor. */ that is the common ancestor. */
......
...@@ -468,13 +468,13 @@ convert_to_reference (reftype, expr, convtype, flags, decl) ...@@ -468,13 +468,13 @@ convert_to_reference (reftype, expr, convtype, flags, decl)
else else
msg = "conversion to non-const reference type `%#T'"; msg = "conversion to non-const reference type `%#T'";
cp_error (msg, reftype); cp_pedwarn (msg, reftype);
cp_error ("from rvalue of type `%T'", intype); cp_pedwarn ("from rvalue of type `%T'", intype);
} }
else if (! (convtype & CONV_CONST) else if (! (convtype & CONV_CONST)
&& !at_least_as_qualified_p (ttl, ttr)) && !at_least_as_qualified_p (ttl, ttr))
cp_error ("conversion from `%T' to `%T' discards qualifiers", cp_pedwarn ("conversion from `%T' to `%T' discards qualifiers",
ttr, reftype); ttr, reftype);
} }
return build_up_reference (reftype, expr, flags); return build_up_reference (reftype, expr, flags);
......
...@@ -4834,6 +4834,7 @@ build_typename_type (context, name, fullname, base_type) ...@@ -4834,6 +4834,7 @@ build_typename_type (context, name, fullname, base_type)
TYPE_NAME (TREE_TYPE (d)) = d; TYPE_NAME (TREE_TYPE (d)) = d;
TYPE_STUB_DECL (TREE_TYPE (d)) = d; TYPE_STUB_DECL (TREE_TYPE (d)) = d;
DECL_CONTEXT (d) = FROB_CONTEXT (context); DECL_CONTEXT (d) = FROB_CONTEXT (context);
DECL_ARTIFICIAL (d) = 1;
/* See if we already have this type. */ /* See if we already have this type. */
e = hash_lookup (&ht, t, /*create=*/false, /*copy=*/0); e = hash_lookup (&ht, t, /*create=*/false, /*copy=*/0);
...@@ -5166,8 +5167,22 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only) ...@@ -5166,8 +5167,22 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only)
locval = classval = NULL_TREE; locval = classval = NULL_TREE;
if (! namespace_bindings_p ()) if (! namespace_bindings_p () && IDENTIFIER_LOCAL_VALUE (name))
locval = qualify_lookup (IDENTIFIER_LOCAL_VALUE (name), flags); {
locval = qualify_lookup (IDENTIFIER_LOCAL_VALUE (name), flags);
/* Kludge kludge kludge */
if (locval == NULL_TREE && prefer_type)
{
locval = REAL_IDENTIFIER_TYPE_VALUE (name);
if (locval && locval != global_type_node
&& TYPE_NAME (locval)
&& DECL_FUNCTION_SCOPE_P (TYPE_NAME (locval)))
locval = TYPE_NAME (locval);
else
locval = NULL_TREE;
}
}
/* In C++ class fields are between local and global scope, /* In C++ class fields are between local and global scope,
just before the global scope. */ just before the global scope. */
...@@ -5308,17 +5323,6 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only) ...@@ -5308,17 +5323,6 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only)
val = from_obj; val = from_obj;
} }
if ((TREE_CODE (val) == TEMPLATE_DECL && looking_for_template)
|| TREE_CODE (val) == TYPE_DECL || prefer_type <= 0)
;
/* Caller wants a class-or-namespace-name. */
else if (prefer_type == 1 && TREE_CODE (val) == NAMESPACE_DECL)
;
else if (IDENTIFIER_HAS_TYPE_VALUE (name))
val = TYPE_MAIN_DECL (IDENTIFIER_TYPE_VALUE (name));
else if (TREE_TYPE (val) == error_mark_node)
val = error_mark_node;
/* If we have a single function from a using decl, pull it out. */ /* If we have a single function from a using decl, pull it out. */
if (TREE_CODE (val) == OVERLOAD && ! really_overloaded_fn (val)) if (TREE_CODE (val) == OVERLOAD && ! really_overloaded_fn (val))
val = OVL_FUNCTION (val); val = OVL_FUNCTION (val);
...@@ -5620,6 +5624,8 @@ init_decl_processing () ...@@ -5620,6 +5624,8 @@ init_decl_processing ()
if (flag_strict_prototype == 2) if (flag_strict_prototype == 2)
flag_strict_prototype = pedantic; flag_strict_prototype = pedantic;
if (! flag_permissive && ! pedantic)
flag_pedantic_errors = 1;
strict_prototypes_lang_c = flag_strict_prototype; strict_prototypes_lang_c = flag_strict_prototype;
......
...@@ -445,6 +445,11 @@ int flag_do_squangling; ...@@ -445,6 +445,11 @@ int flag_do_squangling;
int flag_vtable_gc; int flag_vtable_gc;
/* Nonzero means make the default pedwarns warnings instead of errors.
The value of this flag is ignored if -pedantic is specified. */
int flag_permissive;
/* Table of language-dependent -f options. /* Table of language-dependent -f options.
STRING is the option name. VARIABLE is the address of the variable. STRING is the option name. VARIABLE is the address of the variable.
ON_VALUE is the value to store in VARIABLE ON_VALUE is the value to store in VARIABLE
...@@ -488,6 +493,7 @@ static struct { char *string; int *variable; int on_value;} lang_f_options[] = ...@@ -488,6 +493,7 @@ static struct { char *string; int *variable; int on_value;} lang_f_options[] =
{"nonansi-builtins", &flag_no_nonansi_builtin, 0}, {"nonansi-builtins", &flag_no_nonansi_builtin, 0},
{"operator-names", &flag_operator_names, 1}, {"operator-names", &flag_operator_names, 1},
{"optional-diags", &flag_optional_diags, 1}, {"optional-diags", &flag_optional_diags, 1},
{"permissive", &flag_permissive, 1},
{"repo", &flag_use_repository, 1}, {"repo", &flag_use_repository, 1},
{"rtti", &flag_rtti, 1}, {"rtti", &flag_rtti, 1},
{"squangle", &flag_do_squangling, 1}, {"squangle", &flag_do_squangling, 1},
...@@ -4115,9 +4121,15 @@ ambiguous_decl (name, old, new, flags) ...@@ -4115,9 +4121,15 @@ ambiguous_decl (name, old, new, flags)
/* Some declarations are functions, some are not. */ /* Some declarations are functions, some are not. */
if (flags & LOOKUP_COMPLAIN) if (flags & LOOKUP_COMPLAIN)
{ {
cp_error ("use of `%D' is ambiguous", name); /* If we've already given this error for this lookup,
cp_error_at (" first declared as `%#D' here", BINDING_VALUE (old) is error_mark_node, so let's not
BINDING_VALUE (old)); repeat ourselves. */
if (BINDING_VALUE (old) != error_mark_node)
{
cp_error ("use of `%D' is ambiguous", name);
cp_error_at (" first declared as `%#D' here",
BINDING_VALUE (old));
}
cp_error_at (" also declared as `%#D' here", val); cp_error_at (" also declared as `%#D' here", val);
} }
return error_mark_node; return error_mark_node;
......
...@@ -679,10 +679,10 @@ dump_simple_decl (t, type, v) ...@@ -679,10 +679,10 @@ dump_simple_decl (t, type, v)
dump_type_prefix (type, v, 0); dump_type_prefix (type, v, 0);
OB_PUTC (' '); OB_PUTC (' ');
} }
if (DECL_CLASS_SCOPE_P (t)) if (CP_DECL_CONTEXT (t) != global_namespace)
{ {
dump_type (DECL_CONTEXT (t), 0); dump_decl (DECL_CONTEXT (t), 0);
OB_PUTC2 (':', ':'); OB_PUTC2 (':',':');
} }
if (DECL_NAME (t)) if (DECL_NAME (t))
dump_decl (DECL_NAME (t), v); dump_decl (DECL_NAME (t), v);
...@@ -965,7 +965,7 @@ dump_function_decl (t, v) ...@@ -965,7 +965,7 @@ dump_function_decl (t, v)
parmtypes = TYPE_ARG_TYPES (fntype); parmtypes = TYPE_ARG_TYPES (fntype);
/* Friends have DECL_CLASS_CONTEXT set, but not DECL_CONTEXT. */ /* Friends have DECL_CLASS_CONTEXT set, but not DECL_CONTEXT. */
if (DECL_CONTEXT (t)) if (DECL_CLASS_SCOPE_P (t))
cname = DECL_CLASS_CONTEXT (t); cname = DECL_CLASS_CONTEXT (t);
/* this is for partially instantiated template methods */ /* this is for partially instantiated template methods */
else if (TREE_CODE (fntype) == METHOD_TYPE) else if (TREE_CODE (fntype) == METHOD_TYPE)
...@@ -997,6 +997,11 @@ dump_function_decl (t, v) ...@@ -997,6 +997,11 @@ dump_function_decl (t, v)
/* Skip past "in_charge" identifier. */ /* Skip past "in_charge" identifier. */
parmtypes = TREE_CHAIN (parmtypes); parmtypes = TREE_CHAIN (parmtypes);
} }
else if (CP_DECL_CONTEXT (t) != global_namespace)
{
dump_decl (DECL_CONTEXT (t), 0);
OB_PUTC2 (':',':');
}
if (DESTRUCTOR_NAME_P (name) && DECL_LANGUAGE (t) == lang_cplusplus) if (DESTRUCTOR_NAME_P (name) && DECL_LANGUAGE (t) == lang_cplusplus)
parmtypes = TREE_CHAIN (parmtypes); parmtypes = TREE_CHAIN (parmtypes);
......
...@@ -82,6 +82,8 @@ DEFINE_LANG_NAME ("C++") ...@@ -82,6 +82,8 @@ DEFINE_LANG_NAME ("C++")
{ "-fno-operator-names", "" }, { "-fno-operator-names", "" },
{ "-foptional-diags", "" }, { "-foptional-diags", "" },
{ "-fno-optional-diags", "Disable optional diagnostics" }, { "-fno-optional-diags", "Disable optional diagnostics" },
{ "-fpermissive", "Downgrade conformance errors to warnings" },
{ "-fno-permissive", "" },
{ "-frepo", "Enable automatic template instantiation" }, { "-frepo", "Enable automatic template instantiation" },
{ "-fno-repo", "" }, { "-fno-repo", "" },
{ "-fsave-memoized", "" }, { "-fsave-memoized", "" },
......
...@@ -2918,7 +2918,7 @@ do_identifier (token, parsing, args) ...@@ -2918,7 +2918,7 @@ do_identifier (token, parsing, args)
else else
{ {
cp_error ("invalid use of member `%D' from base class `%T'", field, cp_error ("invalid use of member `%D' from base class `%T'", field,
DECL_FIELD_CONTEXT (field)); DECL_FIELD_CONTEXT (field));
id = error_mark_node; id = error_mark_node;
return id; return id;
} }
......
...@@ -6618,11 +6618,11 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum) ...@@ -6618,11 +6618,11 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum)
if (!at_least_as_qualified_p (ttl, ttr)) if (!at_least_as_qualified_p (ttl, ttr))
{ {
if (fndecl) if (fndecl)
cp_error ("passing `%T' as argument %P of `%D' discards qualifiers", cp_pedwarn ("passing `%T' as argument %P of `%D' discards qualifiers",
rhstype, parmnum, fndecl); rhstype, parmnum, fndecl);
else else
cp_error ("%s to `%T' from `%T' discards qualifiers", cp_pedwarn ("%s to `%T' from `%T' discards qualifiers",
errtype, type, rhstype); errtype, type, rhstype);
} }
} }
...@@ -6675,10 +6675,10 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum) ...@@ -6675,10 +6675,10 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum)
if (string_conv_p (type, rhs, 1)) if (string_conv_p (type, rhs, 1))
/* converting from string constant to char *, OK. */; /* converting from string constant to char *, OK. */;
else if (fndecl) else if (fndecl)
cp_error ("passing `%T' as argument %P of `%D' discards qualifiers", cp_pedwarn ("passing `%T' as argument %P of `%D' discards qualifiers",
rhstype, parmnum, fndecl); rhstype, parmnum, fndecl);
else else
cp_error ("%s to `%T' from `%T' discards qualifiers", cp_pedwarn ("%s to `%T' from `%T' discards qualifiers",
errtype, type, rhstype); errtype, type, rhstype);
} }
else if (TREE_CODE (ttl) == TREE_CODE (ttr) else if (TREE_CODE (ttl) == TREE_CODE (ttr)
...@@ -6739,10 +6739,10 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum) ...@@ -6739,10 +6739,10 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum)
if (drops_quals) if (drops_quals)
{ {
if (fndecl) if (fndecl)
cp_error ("passing `%T' as argument %P of `%D' discards qualifiers", cp_pedwarn ("passing `%T' as argument %P of `%D' discards qualifiers",
rhstype, parmnum, fndecl); rhstype, parmnum, fndecl);
else else
cp_error ("%s to `%T' from `%T' discards qualifiers", cp_pedwarn ("%s to `%T' from `%T' discards qualifiers",
errtype, type, rhstype); errtype, type, rhstype);
} }
if (unsigned_parity > 0) if (unsigned_parity > 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