* 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
+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>
* 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:
* Namespaces are fully supported. The library has not yet been converted
tree argtype = TREE_TYPE (TREE_VALUE (arg));
tree t;
if (ICS_BAD_FLAG (TREE_VEC_ELT (convs, i)))
- cp_error ("passing `%T' as `this' argument of `%#D' discards qualifiers",
- TREE_TYPE (argtype), fn);
+ cp_pedwarn ("passing `%T' as `this' argument of `%#D' discards qualifiers",
+ TREE_TYPE (argtype), fn);
/* [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
/* Nonzero means do not consider empty argument prototype to mean function
takes no arguments. */
-
extern int flag_strict_prototype;
/* Nonzero means output .vtable_{entry,inherit} for use in doing 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;
\f
/* C++ language-specific tree codes. */
#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
(DECL_CONTEXT (NODE) \
&& 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
The PURPOSE is the used namespace, the value is the namespace
that is the common ancestor. */
else
msg = "conversion to non-const reference type `%#T'";
- cp_error (msg, reftype);
- cp_error ("from rvalue of type `%T'", intype);
+ cp_pedwarn (msg, reftype);
+ cp_pedwarn ("from rvalue of type `%T'", intype);
}
else if (! (convtype & CONV_CONST)
&& !at_least_as_qualified_p (ttl, ttr))
- cp_error ("conversion from `%T' to `%T' discards qualifiers",
- ttr, reftype);
+ cp_pedwarn ("conversion from `%T' to `%T' discards qualifiers",
+ ttr, reftype);
}
return build_up_reference (reftype, expr, flags);
TYPE_NAME (TREE_TYPE (d)) = d;
TYPE_STUB_DECL (TREE_TYPE (d)) = d;
DECL_CONTEXT (d) = FROB_CONTEXT (context);
+ DECL_ARTIFICIAL (d) = 1;
/* See if we already have this type. */
e = hash_lookup (&ht, t, /*create=*/false, /*copy=*/0);
locval = classval = NULL_TREE;
- if (! namespace_bindings_p ())
- locval = qualify_lookup (IDENTIFIER_LOCAL_VALUE (name), flags);
+ if (! namespace_bindings_p () && IDENTIFIER_LOCAL_VALUE (name))
+ {
+ 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,
just before the global scope. */
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 (TREE_CODE (val) == OVERLOAD && ! really_overloaded_fn (val))
val = OVL_FUNCTION (val);
if (flag_strict_prototype == 2)
flag_strict_prototype = pedantic;
+ if (! flag_permissive && ! pedantic)
+ flag_pedantic_errors = 1;
strict_prototypes_lang_c = flag_strict_prototype;
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.
STRING is the option name. VARIABLE is the address of the variable.
ON_VALUE is the value to store in VARIABLE
{"nonansi-builtins", &flag_no_nonansi_builtin, 0},
{"operator-names", &flag_operator_names, 1},
{"optional-diags", &flag_optional_diags, 1},
+ {"permissive", &flag_permissive, 1},
{"repo", &flag_use_repository, 1},
{"rtti", &flag_rtti, 1},
{"squangle", &flag_do_squangling, 1},
/* Some declarations are functions, some are not. */
if (flags & LOOKUP_COMPLAIN)
{
- cp_error ("use of `%D' is ambiguous", name);
- cp_error_at (" first declared as `%#D' here",
- BINDING_VALUE (old));
+ /* If we've already given this error for this lookup,
+ BINDING_VALUE (old) is error_mark_node, so let's not
+ 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);
}
return error_mark_node;
dump_type_prefix (type, v, 0);
OB_PUTC (' ');
}
- if (DECL_CLASS_SCOPE_P (t))
+ if (CP_DECL_CONTEXT (t) != global_namespace)
{
- dump_type (DECL_CONTEXT (t), 0);
- OB_PUTC2 (':', ':');
+ dump_decl (DECL_CONTEXT (t), 0);
+ OB_PUTC2 (':',':');
}
if (DECL_NAME (t))
dump_decl (DECL_NAME (t), v);
parmtypes = TYPE_ARG_TYPES (fntype);
/* 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);
/* this is for partially instantiated template methods */
else if (TREE_CODE (fntype) == METHOD_TYPE)
/* Skip past "in_charge" identifier. */
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)
parmtypes = TREE_CHAIN (parmtypes);
{ "-fno-operator-names", "" },
{ "-foptional-diags", "" },
{ "-fno-optional-diags", "Disable optional diagnostics" },
+ { "-fpermissive", "Downgrade conformance errors to warnings" },
+ { "-fno-permissive", "" },
{ "-frepo", "Enable automatic template instantiation" },
{ "-fno-repo", "" },
{ "-fsave-memoized", "" },
else
{
cp_error ("invalid use of member `%D' from base class `%T'", field,
- DECL_FIELD_CONTEXT (field));
+ DECL_FIELD_CONTEXT (field));
id = error_mark_node;
return id;
}
if (!at_least_as_qualified_p (ttl, ttr))
{
if (fndecl)
- cp_error ("passing `%T' as argument %P of `%D' discards qualifiers",
- rhstype, parmnum, fndecl);
+ cp_pedwarn ("passing `%T' as argument %P of `%D' discards qualifiers",
+ rhstype, parmnum, fndecl);
else
- cp_error ("%s to `%T' from `%T' discards qualifiers",
- errtype, type, rhstype);
+ cp_pedwarn ("%s to `%T' from `%T' discards qualifiers",
+ errtype, type, rhstype);
}
}
if (string_conv_p (type, rhs, 1))
/* converting from string constant to char *, OK. */;
else if (fndecl)
- cp_error ("passing `%T' as argument %P of `%D' discards qualifiers",
- rhstype, parmnum, fndecl);
+ cp_pedwarn ("passing `%T' as argument %P of `%D' discards qualifiers",
+ rhstype, parmnum, fndecl);
else
- cp_error ("%s to `%T' from `%T' discards qualifiers",
+ cp_pedwarn ("%s to `%T' from `%T' discards qualifiers",
errtype, type, rhstype);
}
else if (TREE_CODE (ttl) == TREE_CODE (ttr)
if (drops_quals)
{
if (fndecl)
- cp_error ("passing `%T' as argument %P of `%D' discards qualifiers",
- rhstype, parmnum, fndecl);
+ cp_pedwarn ("passing `%T' as argument %P of `%D' discards qualifiers",
+ rhstype, parmnum, fndecl);
else
- cp_error ("%s to `%T' from `%T' discards qualifiers",
+ cp_pedwarn ("%s to `%T' from `%T' discards qualifiers",
errtype, type, rhstype);
}
if (unsigned_parity > 0)