diff options
-rw-r--r-- | gcc/cp/ChangeLog | 24 | ||||
-rw-r--r-- | gcc/cp/NEWS | 6 | ||||
-rw-r--r-- | gcc/cp/call.c | 4 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 10 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 8 | ||||
-rw-r--r-- | gcc/cp/decl.c | 32 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 18 | ||||
-rw-r--r-- | gcc/cp/error.c | 13 | ||||
-rw-r--r-- | gcc/cp/lang-options.h | 2 | ||||
-rw-r--r-- | gcc/cp/lex.c | 2 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 20 |
11 files changed, 101 insertions, 38 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fa87972bfe7..25e53036020 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,27 @@ +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. diff --git a/gcc/cp/NEWS b/gcc/cp/NEWS index 9cb7d5b2c26..0cdcc229a4e 100644 --- a/gcc/cp/NEWS +++ b/gcc/cp/NEWS @@ -1,3 +1,9 @@ +*** 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 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index ea8874532ce..dd1f33b7e66 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3258,8 +3258,8 @@ build_over_call (cand, args, flags) 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 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 8f2dc856c98..a515d66a79a 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -498,11 +498,14 @@ extern int flag_optional_diags; /* 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; /* C++ language-specific tree codes. */ #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM, @@ -1286,6 +1289,11 @@ struct lang_decl (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. */ diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index af2f4191e5a..17363b6fccc 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -468,13 +468,13 @@ convert_to_reference (reftype, expr, convtype, flags, decl) 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); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 81b835d83ef..260053b3bc4 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4834,6 +4834,7 @@ build_typename_type (context, name, fullname, base_type) 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); @@ -5166,8 +5167,22 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only) 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. */ @@ -5308,17 +5323,6 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only) 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); @@ -5620,6 +5624,8 @@ init_decl_processing () if (flag_strict_prototype == 2) flag_strict_prototype = pedantic; + if (! flag_permissive && ! pedantic) + flag_pedantic_errors = 1; strict_prototypes_lang_c = flag_strict_prototype; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 1f560289fc4..7f32cf8ba80 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -445,6 +445,11 @@ int flag_do_squangling; 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 @@ -488,6 +493,7 @@ static struct { char *string; int *variable; int on_value;} lang_f_options[] = {"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}, @@ -4115,9 +4121,15 @@ ambiguous_decl (name, old, new, flags) /* 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; diff --git a/gcc/cp/error.c b/gcc/cp/error.c index c3ec3b52fa7..fba5005b5df 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -679,10 +679,10 @@ dump_simple_decl (t, type, v) 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); @@ -965,7 +965,7 @@ dump_function_decl (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) @@ -997,6 +997,11 @@ dump_function_decl (t, v) /* 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); diff --git a/gcc/cp/lang-options.h b/gcc/cp/lang-options.h index 9f68bb81e9a..f9cfa8c85d5 100644 --- a/gcc/cp/lang-options.h +++ b/gcc/cp/lang-options.h @@ -82,6 +82,8 @@ DEFINE_LANG_NAME ("C++") { "-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", "" }, diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index fbd5215c815..3543cf5ffcf 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -2918,7 +2918,7 @@ do_identifier (token, parsing, args) 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; } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 18160be6637..58f42d2ffa5 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6618,11 +6618,11 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum) 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); } } @@ -6675,10 +6675,10 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum) 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) @@ -6739,10 +6739,10 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum) 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) |