mirror of git://gcc.gnu.org/git/gcc.git
re PR c++/24924 (front end and preprocessor pedantic_errors settings should agree)
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. cp/ * 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. testsuite/ * 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. From-SVN: r132817
This commit is contained in:
parent
92331508a6
commit
393eda6a41
|
|
@ -1,3 +1,23 @@
|
||||||
|
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>
|
2008-03-02 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
* libgcc2.c (__addvSI3, __addvsi3, __addvDI3, __subvSI3,
|
* libgcc2.c (__addvSI3, __addvsi3, __addvDI3, __subvSI3,
|
||||||
|
|
|
||||||
|
|
@ -443,11 +443,6 @@ int flag_use_cxa_atexit = DEFAULT_USE_CXA_ATEXIT;
|
||||||
|
|
||||||
int flag_use_cxa_get_exception_ptr = 2;
|
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
|
/* Nonzero means to implement standard semantics for exception
|
||||||
specifications, calling unexpected if an exception is thrown that
|
specifications, calling unexpected if an exception is thrown that
|
||||||
doesn't match the specification. Zero means to treat them as
|
doesn't match the specification. Zero means to treat them as
|
||||||
|
|
@ -926,15 +921,26 @@ fix_string_type (tree value)
|
||||||
|
|
||||||
void
|
void
|
||||||
constant_expression_warning (tree value)
|
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
|
if ((TREE_CODE (value) == INTEGER_CST || TREE_CODE (value) == REAL_CST
|
||||||
|| TREE_CODE (value) == FIXED_CST
|
|| TREE_CODE (value) == FIXED_CST
|
||||||
|| TREE_CODE (value) == VECTOR_CST
|
|| TREE_CODE (value) == VECTOR_CST
|
||||||
|| TREE_CODE (value) == COMPLEX_CST)
|
|| TREE_CODE (value) == COMPLEX_CST)
|
||||||
&& TREE_OVERFLOW (value)
|
&& TREE_OVERFLOW (value))
|
||||||
&& warn_overflow
|
error ("overflow in constant expression");
|
||||||
&& pedantic)
|
|
||||||
pedwarn ("overflow in constant expression");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print a warning if an expression had overflow in folding and its
|
/* Print a warning if an expression had overflow in folding and its
|
||||||
|
|
|
||||||
|
|
@ -584,11 +584,6 @@ extern int flag_use_cxa_atexit;
|
||||||
|
|
||||||
extern int flag_use_cxa_get_exception_ptr;
|
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
|
/* Nonzero means to implement standard semantics for exception
|
||||||
specifications, calling unexpected if an exception is thrown that
|
specifications, calling unexpected if an exception is thrown that
|
||||||
doesn't match the specification. Zero means to treat them as
|
doesn't match the specification. Zero means to treat them as
|
||||||
|
|
@ -688,6 +683,7 @@ extern void binary_op_error (enum tree_code, tree, tree);
|
||||||
extern tree fix_string_type (tree);
|
extern tree fix_string_type (tree);
|
||||||
struct varray_head_tag;
|
struct varray_head_tag;
|
||||||
extern void constant_expression_warning (tree);
|
extern void constant_expression_warning (tree);
|
||||||
|
extern void constant_expression_error (tree);
|
||||||
extern bool strict_aliasing_warning (tree, tree, tree);
|
extern bool strict_aliasing_warning (tree, tree, tree);
|
||||||
extern void empty_if_body_warning (tree, tree);
|
extern void empty_if_body_warning (tree, tree);
|
||||||
extern void warnings_for_convert_and_check (tree, tree, tree);
|
extern void warnings_for_convert_and_check (tree, tree, tree);
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ pedwarn_c99 (const char *gmsgid, ...)
|
||||||
|
|
||||||
va_start (ap, gmsgid);
|
va_start (ap, gmsgid);
|
||||||
diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
|
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);
|
report_diagnostic (&diagnostic);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +56,7 @@ pedwarn_c90 (const char *gmsgid, ...)
|
||||||
|
|
||||||
va_start (ap, gmsgid);
|
va_start (ap, gmsgid);
|
||||||
diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
|
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);
|
report_diagnostic (&diagnostic);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
gcc/c-opts.c
12
gcc/c-opts.c
|
|
@ -1107,18 +1107,6 @@ c_common_post_options (const char **pfilename)
|
||||||
/* Adjust various flags for C++ based on command-line settings. */
|
/* Adjust various flags for C++ based on command-line settings. */
|
||||||
if (c_dialect_cxx ())
|
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)
|
if (!flag_no_inline)
|
||||||
{
|
{
|
||||||
flag_inline_trees = 1;
|
flag_inline_trees = 1;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,21 @@
|
||||||
|
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>
|
2008-03-01 Douglas Gregor <doug.gregor@gmail.com>
|
||||||
|
|
||||||
* parser.c (cp_lexer_next_token_is_decl_specifier_keyword): Note
|
* parser.c (cp_lexer_next_token_is_decl_specifier_keyword): Note
|
||||||
|
|
|
||||||
|
|
@ -3857,10 +3857,10 @@ build_new_op (enum tree_code code, int flags, tree arg1, tree arg2, tree arg3,
|
||||||
/* Look for an `operator++ (int)'. If they didn't have
|
/* Look for an `operator++ (int)'. If they didn't have
|
||||||
one, then we fall back to the old way of doing things. */
|
one, then we fall back to the old way of doing things. */
|
||||||
if (flags & LOOKUP_COMPLAIN)
|
if (flags & LOOKUP_COMPLAIN)
|
||||||
pedwarn ("no %<%D(int)%> declared for postfix %qs, "
|
permerror ("no %<%D(int)%> declared for postfix %qs, "
|
||||||
"trying prefix operator instead",
|
"trying prefix operator instead",
|
||||||
fnname,
|
fnname,
|
||||||
operator_name_info[code].name);
|
operator_name_info[code].name);
|
||||||
if (code == POSTINCREMENT_EXPR)
|
if (code == POSTINCREMENT_EXPR)
|
||||||
code = PREINCREMENT_EXPR;
|
code = PREINCREMENT_EXPR;
|
||||||
else
|
else
|
||||||
|
|
@ -4343,9 +4343,9 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
|
||||||
else if (t->kind == ck_identity)
|
else if (t->kind == ck_identity)
|
||||||
break;
|
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)
|
if (fn)
|
||||||
pedwarn (" initializing argument %P of %qD", argnum, fn);
|
permerror (" initializing argument %P of %qD", argnum, fn);
|
||||||
return cp_convert (totype, expr);
|
return cp_convert (totype, expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4955,7 +4955,7 @@ build_over_call (struct z_candidate *cand, int flags)
|
||||||
tree base_binfo;
|
tree base_binfo;
|
||||||
|
|
||||||
if (convs[i]->bad_p)
|
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);
|
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
|
||||||
|
|
|
||||||
|
|
@ -2493,27 +2493,27 @@ finish_struct_anon (tree t)
|
||||||
if (TREE_CODE (elt) != FIELD_DECL)
|
if (TREE_CODE (elt) != FIELD_DECL)
|
||||||
{
|
{
|
||||||
if (is_union)
|
if (is_union)
|
||||||
pedwarn ("%q+#D invalid; an anonymous union can "
|
permerror ("%q+#D invalid; an anonymous union can "
|
||||||
"only have non-static data members", elt);
|
"only have non-static data members", elt);
|
||||||
else
|
else
|
||||||
pedwarn ("%q+#D invalid; an anonymous struct can "
|
permerror ("%q+#D invalid; an anonymous struct can "
|
||||||
"only have non-static data members", elt);
|
"only have non-static data members", elt);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TREE_PRIVATE (elt))
|
if (TREE_PRIVATE (elt))
|
||||||
{
|
{
|
||||||
if (is_union)
|
if (is_union)
|
||||||
pedwarn ("private member %q+#D in anonymous union", elt);
|
permerror ("private member %q+#D in anonymous union", elt);
|
||||||
else
|
else
|
||||||
pedwarn ("private member %q+#D in anonymous struct", elt);
|
permerror ("private member %q+#D in anonymous struct", elt);
|
||||||
}
|
}
|
||||||
else if (TREE_PROTECTED (elt))
|
else if (TREE_PROTECTED (elt))
|
||||||
{
|
{
|
||||||
if (is_union)
|
if (is_union)
|
||||||
pedwarn ("protected member %q+#D in anonymous union", elt);
|
permerror ("protected member %q+#D in anonymous union", elt);
|
||||||
else
|
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);
|
TREE_PRIVATE (elt) = TREE_PRIVATE (field);
|
||||||
|
|
@ -3044,7 +3044,7 @@ check_field_decls (tree t, tree *access_decls,
|
||||||
user-defined constructor. */
|
user-defined constructor. */
|
||||||
if (constructor_name_p (DECL_NAME (x), t)
|
if (constructor_name_p (DECL_NAME (x), t)
|
||||||
&& TYPE_HAS_USER_CONSTRUCTOR (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.
|
/* We set DECL_C_BIT_FIELD in grokbitfield.
|
||||||
If the type and width are valid, we'll also set DECL_BIT_FIELD. */
|
If the type and width are valid, we'll also set DECL_BIT_FIELD. */
|
||||||
|
|
@ -6072,10 +6072,10 @@ resolve_address_of_overloaded_function (tree target_type,
|
||||||
if (!(flags & tf_error))
|
if (!(flags & tf_error))
|
||||||
return error_mark_node;
|
return error_mark_node;
|
||||||
|
|
||||||
pedwarn ("assuming pointer to member %qD", fn);
|
permerror ("assuming pointer to member %qD", fn);
|
||||||
if (!explained)
|
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;
|
explained = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6435,8 +6435,8 @@ note_name_declared_in_class (tree name, tree decl)
|
||||||
A name N used in a class S shall refer to the same declaration
|
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
|
in its context and when re-evaluated in the completed scope of
|
||||||
S. */
|
S. */
|
||||||
pedwarn ("declaration of %q#D", decl);
|
permerror ("declaration of %q#D", decl);
|
||||||
pedwarn ("changes meaning of %qD from %q+#D",
|
permerror ("changes meaning of %qD from %q+#D",
|
||||||
DECL_NAME (OVL_CURRENT (decl)), (tree) n->value);
|
DECL_NAME (OVL_CURRENT (decl)), (tree) n->value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
gcc/cp/cvt.c
14
gcc/cp/cvt.c
|
|
@ -379,7 +379,7 @@ warn_ref_binding (tree reftype, tree intype, tree decl)
|
||||||
msg = "conversion to non-const reference type %q#T from"
|
msg = "conversion to non-const reference type %q#T from"
|
||||||
" rvalue of type %qT";
|
" rvalue of type %qT";
|
||||||
|
|
||||||
pedwarn (msg, reftype, intype);
|
permerror (msg, reftype, intype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -449,8 +449,8 @@ convert_to_reference (tree reftype, tree expr, int convtype,
|
||||||
|
|
||||||
if (! (convtype & CONV_CONST)
|
if (! (convtype & CONV_CONST)
|
||||||
&& !at_least_as_qualified_p (ttl, ttr))
|
&& !at_least_as_qualified_p (ttl, ttr))
|
||||||
pedwarn ("conversion from %qT to %qT discards qualifiers",
|
permerror ("conversion from %qT to %qT discards qualifiers",
|
||||||
ttr, reftype);
|
ttr, reftype);
|
||||||
}
|
}
|
||||||
|
|
||||||
return build_up_reference (reftype, expr, flags, decl);
|
return build_up_reference (reftype, expr, flags, decl);
|
||||||
|
|
@ -646,9 +646,9 @@ ocp_convert (tree type, tree expr, int convtype, int flags)
|
||||||
|| TREE_CODE (intype) == POINTER_TYPE))
|
|| TREE_CODE (intype) == POINTER_TYPE))
|
||||||
{
|
{
|
||||||
if (flags & LOOKUP_COMPLAIN)
|
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;
|
return error_mark_node;
|
||||||
}
|
}
|
||||||
if (IS_AGGR_TYPE (intype))
|
if (IS_AGGR_TYPE (intype))
|
||||||
|
|
@ -892,8 +892,8 @@ convert_to_void (tree expr, const char *implicit)
|
||||||
{
|
{
|
||||||
/* [over.over] enumerates the places where we can take the address
|
/* [over.over] enumerates the places where we can take the address
|
||||||
of an overloaded function, and this is not one of them. */
|
of an overloaded function, and this is not one of them. */
|
||||||
pedwarn ("%s cannot resolve address of overloaded function",
|
error ("%s cannot resolve address of overloaded function",
|
||||||
implicit ? implicit : "void cast");
|
implicit ? implicit : "void cast");
|
||||||
expr = void_zero_node;
|
expr = void_zero_node;
|
||||||
}
|
}
|
||||||
else if (implicit && probe == expr && is_overloaded_fn (probe))
|
else if (implicit && probe == expr && is_overloaded_fn (probe))
|
||||||
|
|
|
||||||
|
|
@ -7028,12 +7028,7 @@ compute_array_index_type (tree name, tree size)
|
||||||
{
|
{
|
||||||
/* Check to see if the array bound overflowed. Make that an
|
/* Check to see if the array bound overflowed. Make that an
|
||||||
error, no matter how generous we're being. */
|
error, no matter how generous we're being. */
|
||||||
int old_flag_pedantic_errors = flag_pedantic_errors;
|
constant_expression_error (size);
|
||||||
int old_pedantic = pedantic;
|
|
||||||
pedantic = flag_pedantic_errors = 1;
|
|
||||||
constant_expression_warning (size);
|
|
||||||
pedantic = old_pedantic;
|
|
||||||
flag_pedantic_errors = old_flag_pedantic_errors;
|
|
||||||
|
|
||||||
/* An array must have a positive number of elements. */
|
/* An array must have a positive number of elements. */
|
||||||
if (INT_CST_LT (size, integer_zero_node))
|
if (INT_CST_LT (size, integer_zero_node))
|
||||||
|
|
|
||||||
|
|
@ -2651,7 +2651,7 @@ cp_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level,
|
||||||
dlevel = DK_WARNING;
|
dlevel = DK_WARNING;
|
||||||
break;
|
break;
|
||||||
case CPP_DL_PEDWARN:
|
case CPP_DL_PEDWARN:
|
||||||
dlevel = pedantic_error_kind ();
|
dlevel = pedantic_warning_kind ();
|
||||||
break;
|
break;
|
||||||
case CPP_DL_ERROR:
|
case CPP_DL_ERROR:
|
||||||
dlevel = DK_ERROR;
|
dlevel = DK_ERROR;
|
||||||
|
|
|
||||||
|
|
@ -647,16 +647,16 @@ unqualified_fn_lookup_error (tree name)
|
||||||
Note that we have the exact wording of the following message in
|
Note that we have the exact wording of the following message in
|
||||||
the manual (trouble.texi, node "Name lookup"), so they need to
|
the manual (trouble.texi, node "Name lookup"), so they need to
|
||||||
be kept in synch. */
|
be kept in synch. */
|
||||||
pedwarn ("there are no arguments to %qD that depend on a template "
|
permerror ("there are no arguments to %qD that depend on a template "
|
||||||
"parameter, so a declaration of %qD must be available",
|
"parameter, so a declaration of %qD must be available",
|
||||||
name, name);
|
name, name);
|
||||||
|
|
||||||
if (!flag_permissive)
|
if (!flag_permissive)
|
||||||
{
|
{
|
||||||
static bool hint;
|
static bool hint;
|
||||||
if (!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 "
|
"code, but allowing the use of an undeclared name is "
|
||||||
"deprecated)");
|
"deprecated)");
|
||||||
hint = true;
|
hint = true;
|
||||||
|
|
|
||||||
|
|
@ -9775,7 +9775,7 @@ cp_parser_template_id (cp_parser *parser,
|
||||||
}
|
}
|
||||||
/* Otherwise, emit an error about the invalid digraph, but continue
|
/* Otherwise, emit an error about the invalid digraph, but continue
|
||||||
parsing because we got our argument list. */
|
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 "
|
inform ("%<<:%> is an alternate spelling for %<[%>. Insert whitespace "
|
||||||
"between %<<%> and %<::%>");
|
"between %<<%> and %<::%>");
|
||||||
if (!flag_permissive)
|
if (!flag_permissive)
|
||||||
|
|
|
||||||
|
|
@ -544,11 +544,31 @@ pedwarn (const char *gmsgid, ...)
|
||||||
|
|
||||||
va_start (ap, gmsgid);
|
va_start (ap, gmsgid);
|
||||||
diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
|
diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location,
|
||||||
pedantic_error_kind ());
|
pedantic_warning_kind ());
|
||||||
report_diagnostic (&diagnostic);
|
report_diagnostic (&diagnostic);
|
||||||
va_end (ap);
|
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
|
/* A hard error: the code is definitely ill-formed, and an object file
|
||||||
will not be produced. */
|
will not be produced. */
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,8 @@ typedef struct diagnostic_info
|
||||||
int option_index;
|
int option_index;
|
||||||
} diagnostic_info;
|
} 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. */
|
/* Forward declarations. */
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,10 @@ extern int flag_dump_unnumbered;
|
||||||
|
|
||||||
extern int flag_pedantic_errors;
|
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
|
/* Nonzero if we are compiling code for a shared library, zero for
|
||||||
executable. */
|
executable. */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
|
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>
|
2008-03-01 Douglas Gregor <doug.gregor@gmail.com>
|
||||||
|
|
||||||
* g++.dg/cpp0x/auto1.C: New.
|
* g++.dg/cpp0x/auto1.C: New.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* { dg-do preprocess } */
|
||||||
|
/* { dg-options "-std=c++98 -pedantic-errors" } */
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
#endif 1 /* { dg-error "error: extra tokens at end of #endif directive" } */
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Test diagnostics for interpreting strings: should be an error by
|
// Test diagnostics for interpreting strings: This is a pedwarn.
|
||||||
// default.
|
|
||||||
// Origin: Joseph Myers <joseph@codesourcery.com>
|
// Origin: Joseph Myers <joseph@codesourcery.com>
|
||||||
// { dg-do compile }
|
// { dg-do compile }
|
||||||
// { dg-options "" }
|
// { dg-options "" }
|
||||||
|
|
||||||
const char *s = "\q"; // { dg-error "error: unknown escape sequence" }
|
const char *s = "\q"; // { dg-warning "warning: unknown escape sequence" }
|
||||||
|
|
|
||||||
|
|
@ -281,6 +281,10 @@ enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
|
||||||
|
|
||||||
int flag_pedantic_errors = 0;
|
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
|
/* -dA causes debug commentary information to be produced in
|
||||||
the generated assembly code (to make it more readable). This option
|
the generated assembly code (to make it more readable). This option
|
||||||
is generally only of use to those who actually need to read the
|
is generally only of use to those who actually need to read the
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
|
||||||
extern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
|
extern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
|
||||||
ATTRIBUTE_NORETURN;
|
ATTRIBUTE_NORETURN;
|
||||||
extern void pedwarn (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
|
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 sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
|
||||||
extern void inform (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);
|
extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue