+2008-03-02 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR 24924
+ * c-common.c (flag_permissive): Delete.
+ (constant_expression_warnings): Check flags first.
+ (constant_expression_error): New.
+ * c-common.h (flag_permissive): Delete.
+ (constant_expression_error): Declare.
+ * flags.h (flag_permissive): Declare. Update description.
+ * diagnostic.c (pedwarn): Update.
+ (permerror): New.
+ * diagnostic.h: (pedantic_error_kind): Rename as pedantic_warning_kind.
+ (permissive_error_kind): New.
+ * toplev.c (flag_permissive): Define. Update description.
+ * toplev.h (permissive_error_kind): Declare.
+ * c-errors.c (pedwarn_c99): Use pedantic_warning_kind.
+ (pedwarn_c90): Use pedantic_warning_kind.
+ * c-opts.c (c_common_post_options): flag_permissive does not affect
+ flag_pedantic_errors.
+
2008-03-02 Joseph Myers <joseph@codesourcery.com>
* libgcc2.c (__addvSI3, __addvsi3, __addvDI3, __subvSI3,
int flag_use_cxa_get_exception_ptr = 2;
-/* Nonzero means make the default pedwarns warnings instead of errors.
- The value of this flag is ignored if -pedantic is specified. */
-
-int flag_permissive;
-
/* Nonzero means to implement standard semantics for exception
specifications, calling unexpected if an exception is thrown that
doesn't match the specification. Zero means to treat them as
void
constant_expression_warning (tree value)
+{
+ if (warn_overflow && pedantic
+ && (TREE_CODE (value) == INTEGER_CST || TREE_CODE (value) == REAL_CST
+ || TREE_CODE (value) == FIXED_CST
+ || TREE_CODE (value) == VECTOR_CST
+ || TREE_CODE (value) == COMPLEX_CST)
+ && TREE_OVERFLOW (value))
+ pedwarn ("overflow in constant expression");
+}
+
+/* The same as above but print an unconditional error. */
+void
+constant_expression_error (tree value)
{
if ((TREE_CODE (value) == INTEGER_CST || TREE_CODE (value) == REAL_CST
|| TREE_CODE (value) == FIXED_CST
|| TREE_CODE (value) == VECTOR_CST
|| TREE_CODE (value) == COMPLEX_CST)
- && TREE_OVERFLOW (value)
- && warn_overflow
- && pedantic)
- pedwarn ("overflow in constant expression");
+ && TREE_OVERFLOW (value))
+ error ("overflow in constant expression");
}
/* Print a warning if an expression had overflow in folding and its
extern int flag_use_cxa_get_exception_ptr;
-/* Nonzero means make the default pedwarns warnings instead of errors.
- The value of this flag is ignored if -pedantic is specified. */
-
-extern int flag_permissive;
-
/* Nonzero means to implement standard semantics for exception
specifications, calling unexpected if an exception is thrown that
doesn't match the specification. Zero means to treat them as
extern tree fix_string_type (tree);
struct varray_head_tag;
extern void constant_expression_warning (tree);
+extern void constant_expression_error (tree);
extern bool strict_aliasing_warning (tree, tree, tree);
extern void empty_if_body_warning (tree, tree);
extern void warnings_for_convert_and_check (tree, tree, tree);
va_start (ap, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
- flag_isoc99 ? pedantic_error_kind () : DK_WARNING);
+ flag_isoc99 ? pedantic_warning_kind () : DK_WARNING);
report_diagnostic (&diagnostic);
va_end (ap);
}
va_start (ap, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
- flag_isoc99 ? DK_WARNING : pedantic_error_kind ());
+ flag_isoc99 ? DK_WARNING : pedantic_warning_kind ());
report_diagnostic (&diagnostic);
va_end (ap);
}
/* Adjust various flags for C++ based on command-line settings. */
if (c_dialect_cxx ())
{
- if (!flag_permissive)
- {
- flag_pedantic_errors = 1;
- /* FIXME: For consistency pedantic_errors should have the
- same value in the front-end and in CPP. However, this
- will break existing applications. The right fix is
- disentagle flag_permissive from flag_pedantic_errors,
- create a new diagnostic function permerror that is
- controlled by flag_permissive and convert most C++
- pedwarns to this new function.
- cpp_opts->pedantic_errors = 1; */
- }
if (!flag_no_inline)
{
flag_inline_trees = 1;
+2008-03-02 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR 24924
+ * class.c (finish_struct_anon): Use permerror instead of pedwarn.
+ (check_field_decls): Likewise.
+ (note_name_declared_in_class): Likewise.
+ * call.c (build_new_op): Likewise.
+ (convert_like_real): Likewise.
+ (build_over_call): Likewise.
+ * lex.c (unqualified_fn_lookup_error): Likewise.
+ * parser.c (cp_parser_template_id): Likewise.
+ * cvt.c (warn_ref_binding): Likewise.
+ (convert_to_reference): Likewise.
+ (ocp_convert): Likewise.
+ (convert_to_void): Use error instead of pedwarn.
+ * error.c (cp_cpp_error): Use pedantic_warning_kind.
+ * decl.c (compute_array_index_type): Use constant_expression_error.
+
2008-03-01 Douglas Gregor <doug.gregor@gmail.com>
* parser.c (cp_lexer_next_token_is_decl_specifier_keyword): Note
/* Look for an `operator++ (int)'. If they didn't have
one, then we fall back to the old way of doing things. */
if (flags & LOOKUP_COMPLAIN)
- pedwarn ("no %<%D(int)%> declared for postfix %qs, "
- "trying prefix operator instead",
- fnname,
- operator_name_info[code].name);
+ permerror ("no %<%D(int)%> declared for postfix %qs, "
+ "trying prefix operator instead",
+ fnname,
+ operator_name_info[code].name);
if (code == POSTINCREMENT_EXPR)
code = PREINCREMENT_EXPR;
else
else if (t->kind == ck_identity)
break;
}
- pedwarn ("invalid conversion from %qT to %qT", TREE_TYPE (expr), totype);
+ permerror ("invalid conversion from %qT to %qT", TREE_TYPE (expr), totype);
if (fn)
- pedwarn (" initializing argument %P of %qD", argnum, fn);
+ permerror (" initializing argument %P of %qD", argnum, fn);
return cp_convert (totype, expr);
}
tree base_binfo;
if (convs[i]->bad_p)
- pedwarn ("passing %qT as %<this%> argument of %q#D discards qualifiers",
+ permerror ("passing %qT as %<this%> argument of %q#D discards qualifiers",
TREE_TYPE (argtype), fn);
/* [class.mfct.nonstatic]: If a nonstatic member function of a class
if (TREE_CODE (elt) != FIELD_DECL)
{
if (is_union)
- pedwarn ("%q+#D invalid; an anonymous union can "
- "only have non-static data members", elt);
+ permerror ("%q+#D invalid; an anonymous union can "
+ "only have non-static data members", elt);
else
- pedwarn ("%q+#D invalid; an anonymous struct can "
- "only have non-static data members", elt);
+ permerror ("%q+#D invalid; an anonymous struct can "
+ "only have non-static data members", elt);
continue;
}
if (TREE_PRIVATE (elt))
{
if (is_union)
- pedwarn ("private member %q+#D in anonymous union", elt);
+ permerror ("private member %q+#D in anonymous union", elt);
else
- pedwarn ("private member %q+#D in anonymous struct", elt);
+ permerror ("private member %q+#D in anonymous struct", elt);
}
else if (TREE_PROTECTED (elt))
{
if (is_union)
- pedwarn ("protected member %q+#D in anonymous union", elt);
+ permerror ("protected member %q+#D in anonymous union", elt);
else
- pedwarn ("protected member %q+#D in anonymous struct", elt);
+ permerror ("protected member %q+#D in anonymous struct", elt);
}
TREE_PRIVATE (elt) = TREE_PRIVATE (field);
user-defined constructor. */
if (constructor_name_p (DECL_NAME (x), t)
&& TYPE_HAS_USER_CONSTRUCTOR (t))
- pedwarn ("field %q+#D with same name as class", x);
+ permerror ("field %q+#D with same name as class", x);
/* We set DECL_C_BIT_FIELD in grokbitfield.
If the type and width are valid, we'll also set DECL_BIT_FIELD. */
if (!(flags & tf_error))
return error_mark_node;
- pedwarn ("assuming pointer to member %qD", fn);
+ permerror ("assuming pointer to member %qD", fn);
if (!explained)
{
- pedwarn ("(a pointer to member can only be formed with %<&%E%>)", fn);
+ inform ("(a pointer to member can only be formed with %<&%E%>)", fn);
explained = 1;
}
}
A name N used in a class S shall refer to the same declaration
in its context and when re-evaluated in the completed scope of
S. */
- pedwarn ("declaration of %q#D", decl);
- pedwarn ("changes meaning of %qD from %q+#D",
+ permerror ("declaration of %q#D", decl);
+ permerror ("changes meaning of %qD from %q+#D",
DECL_NAME (OVL_CURRENT (decl)), (tree) n->value);
}
}
msg = "conversion to non-const reference type %q#T from"
" rvalue of type %qT";
- pedwarn (msg, reftype, intype);
+ permerror (msg, reftype, intype);
}
}
if (! (convtype & CONV_CONST)
&& !at_least_as_qualified_p (ttl, ttr))
- pedwarn ("conversion from %qT to %qT discards qualifiers",
- ttr, reftype);
+ permerror ("conversion from %qT to %qT discards qualifiers",
+ ttr, reftype);
}
return build_up_reference (reftype, expr, flags, decl);
|| TREE_CODE (intype) == POINTER_TYPE))
{
if (flags & LOOKUP_COMPLAIN)
- pedwarn ("conversion from %q#T to %q#T", intype, type);
+ permerror ("conversion from %q#T to %q#T", intype, type);
- if (flag_pedantic_errors)
+ if (!flag_permissive)
return error_mark_node;
}
if (IS_AGGR_TYPE (intype))
{
/* [over.over] enumerates the places where we can take the address
of an overloaded function, and this is not one of them. */
- pedwarn ("%s cannot resolve address of overloaded function",
- implicit ? implicit : "void cast");
+ error ("%s cannot resolve address of overloaded function",
+ implicit ? implicit : "void cast");
expr = void_zero_node;
}
else if (implicit && probe == expr && is_overloaded_fn (probe))
{
/* Check to see if the array bound overflowed. Make that an
error, no matter how generous we're being. */
- int old_flag_pedantic_errors = flag_pedantic_errors;
- int old_pedantic = pedantic;
- pedantic = flag_pedantic_errors = 1;
- constant_expression_warning (size);
- pedantic = old_pedantic;
- flag_pedantic_errors = old_flag_pedantic_errors;
+ constant_expression_error (size);
/* An array must have a positive number of elements. */
if (INT_CST_LT (size, integer_zero_node))
dlevel = DK_WARNING;
break;
case CPP_DL_PEDWARN:
- dlevel = pedantic_error_kind ();
+ dlevel = pedantic_warning_kind ();
break;
case CPP_DL_ERROR:
dlevel = DK_ERROR;
Note that we have the exact wording of the following message in
the manual (trouble.texi, node "Name lookup"), so they need to
be kept in synch. */
- pedwarn ("there are no arguments to %qD that depend on a template "
- "parameter, so a declaration of %qD must be available",
- name, name);
+ permerror ("there are no arguments to %qD that depend on a template "
+ "parameter, so a declaration of %qD must be available",
+ name, name);
if (!flag_permissive)
{
static bool hint;
if (!hint)
{
- error ("(if you use %<-fpermissive%>, G++ will accept your "
+ inform ("(if you use %<-fpermissive%>, G++ will accept your "
"code, but allowing the use of an undeclared name is "
"deprecated)");
hint = true;
}
/* Otherwise, emit an error about the invalid digraph, but continue
parsing because we got our argument list. */
- pedwarn ("%<<::%> cannot begin a template-argument list");
+ permerror ("%<<::%> cannot begin a template-argument list");
inform ("%<<:%> is an alternate spelling for %<[%>. Insert whitespace "
"between %<<%> and %<::%>");
if (!flag_permissive)
va_start (ap, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
- pedantic_error_kind ());
+ pedantic_warning_kind ());
report_diagnostic (&diagnostic);
va_end (ap);
}
+/* A "permissive" error: issues an error unless -fpermissive was given
+ on the command line, in which case it issues a warning. Use this
+ for things that really should be errors but we want to support
+ legacy code. */
+
+void
+permerror (const char *gmsgid, ...)
+{
+ diagnostic_info diagnostic;
+ va_list ap;
+
+ va_start (ap, gmsgid);
+ diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
+ permissive_error_kind ());
+ diagnostic.option_index = OPT_fpermissive;
+ report_diagnostic (&diagnostic);
+ va_end (ap);
+}
+
+
/* A hard error: the code is definitely ill-formed, and an object file
will not be produced. */
void
int option_index;
} diagnostic_info;
-#define pedantic_error_kind() (flag_pedantic_errors ? DK_ERROR : DK_WARNING)
+#define pedantic_warning_kind() (flag_pedantic_errors ? DK_ERROR : DK_WARNING)
+#define permissive_error_kind() (flag_permissive ? DK_WARNING : DK_ERROR)
/* Forward declarations. */
extern int flag_pedantic_errors;
+/* Nonzero means make permerror produce warnings instead of errors. */
+
+extern int flag_permissive;
+
/* Nonzero if we are compiling code for a shared library, zero for
executable. */
+2008-03-02 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR 24924
+ * g++.dg/cpp/string-2.C: This is a warning now.
+ * g++.dg/cpp/pedantic-errors.C: -pedantic-errors is not enabled by
+ default, so add it.
+
2008-03-01 Douglas Gregor <doug.gregor@gmail.com>
* g++.dg/cpp0x/auto1.C: New.
--- /dev/null
+/* { dg-do preprocess } */
+/* { dg-options "-std=c++98 -pedantic-errors" } */
+
+#if 1
+#endif 1 /* { dg-error "error: extra tokens at end of #endif directive" } */
-// Test diagnostics for interpreting strings: should be an error by
-// default.
+// Test diagnostics for interpreting strings: This is a pedwarn.
// Origin: Joseph Myers <joseph@codesourcery.com>
// { dg-do compile }
// { dg-options "" }
-const char *s = "\q"; // { dg-error "error: unknown escape sequence" }
+const char *s = "\q"; // { dg-warning "warning: unknown escape sequence" }
int flag_pedantic_errors = 0;
+/* Nonzero means make permerror produce warnings instead of errors. */
+
+int flag_permissive = 0;
+
/* -dA causes debug commentary information to be produced in
the generated assembly code (to make it more readable). This option
is generally only of use to those who actually need to read the
extern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
ATTRIBUTE_NORETURN;
extern void pedwarn (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
+extern void permerror (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void inform (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);