Commit 848f237b by Shujing Zhao Committed by Paolo Carlini

re PR c++/40892 (maybe_warn_cpp0x i18n problems)

/cp
2009-11-18  Shujing Zhao  <pearly.zhao@oracle.com>

	PR c++/40892
	* error.c (maybe_warn_cpp0x): Accept enum cpp0x_warn_str as argument.
	(maybe_warn_variadic_templates): Update the maybe_warn_cpp0x calls to
	match the new declaration.
	* cp-tree.h (cpp0x_warn_str): New type.
	(maybe_warn_cpp0x): Adjust prototype with new argument.
	* call.c (reference_binding): Update the maybe_warn_cpp0x calls.
	* decl.c (reshape_init_r, check_initializer, grokdeclarator):
	Likewise.
	* parser.c (cp_parser_primary_expression)
	(cp_parser_parenthesized_expression_list, cp_parser_new_initializer)
	(cp_parser_assignment_expression, cp_parser_condition)
	(cp_parser_jump_statement, cp_parser_mem_initializer)
	(cp_parser_simple_type_specifier, cp_parser_elaborated_type_specifier)
	(cp_parser_enum_specifier, cp_parser_initializer)
	(cp_parser_pure_specifier, cp_parser_functional_cast): Likewise.

/testsuite
2009-11-18  Shujing Zhao  <pearly.zhao@oracle.com>

	* g++.old-deja/g++.other/crash28.C: Make expected dg-error strings
	explicit.
	* g++.dg/inherit/error4.C: Likewise.
	* g++.dg/template/crash90.C: Likewise.

From-SVN: r154288
parent 7b98c16f
2009-11-18 Shujing Zhao <pearly.zhao@oracle.com>
PR c++/40892
* error.c (maybe_warn_cpp0x): Accept enum cpp0x_warn_str as argument.
(maybe_warn_variadic_templates): Update the maybe_warn_cpp0x calls to
match the new declaration.
* cp-tree.h (cpp0x_warn_str): New type.
(maybe_warn_cpp0x): Adjust prototype with new argument.
* call.c (reference_binding): Update the maybe_warn_cpp0x calls.
* decl.c (reshape_init_r, check_initializer, grokdeclarator):
Likewise.
* parser.c (cp_parser_primary_expression)
(cp_parser_parenthesized_expression_list, cp_parser_new_initializer)
(cp_parser_assignment_expression, cp_parser_condition)
(cp_parser_jump_statement, cp_parser_mem_initializer)
(cp_parser_simple_type_specifier, cp_parser_elaborated_type_specifier)
(cp_parser_enum_specifier, cp_parser_initializer)
(cp_parser_pure_specifier, cp_parser_functional_cast): Likewise.
2009-11-18 Jakub Jelinek <jakub@redhat.com> 2009-11-18 Jakub Jelinek <jakub@redhat.com>
PR c++/3187 PR c++/3187
......
...@@ -1228,7 +1228,7 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags) ...@@ -1228,7 +1228,7 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
if (expr && BRACE_ENCLOSED_INITIALIZER_P (expr)) if (expr && BRACE_ENCLOSED_INITIALIZER_P (expr))
{ {
maybe_warn_cpp0x ("extended initializer lists"); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
conv = implicit_conversion (to, from, expr, c_cast_p, conv = implicit_conversion (to, from, expr, c_cast_p,
flags); flags);
if (!CLASS_TYPE_P (to) if (!CLASS_TYPE_P (to)
......
...@@ -382,6 +382,28 @@ typedef enum cp_id_kind ...@@ -382,6 +382,28 @@ typedef enum cp_id_kind
CP_ID_KIND_QUALIFIED CP_ID_KIND_QUALIFIED
} cp_id_kind; } cp_id_kind;
/* The various kinds of C++0x warnings we encounter. */
typedef enum cpp0x_warn_str
{
/* extended initializer lists */
CPP0X_INITIALIZER_LISTS,
/* explicit conversion operators */
CPP0X_EXPLICIT_CONVERSION,
/* variadic templates */
CPP0X_VARIADIC_TEMPLATES,
/* lambda expressions */
CPP0X_LAMBDA_EXPR,
/* C++0x auto */
CPP0X_AUTO,
/* scoped enums */
CPP0X_SCOPED_ENUMS,
/* defaulted and deleted functions */
CPP0X_DEFAULTED_DELETED
} cpp0x_warn_str;
/* Macros for access to language-specific slots in an identifier. */ /* Macros for access to language-specific slots in an identifier. */
#define IDENTIFIER_NAMESPACE_BINDINGS(NODE) \ #define IDENTIFIER_NAMESPACE_BINDINGS(NODE) \
...@@ -4672,7 +4694,7 @@ extern const char *language_to_string (enum languages); ...@@ -4672,7 +4694,7 @@ extern const char *language_to_string (enum languages);
extern const char *class_key_or_enum_as_string (tree); extern const char *class_key_or_enum_as_string (tree);
extern void print_instantiation_context (void); extern void print_instantiation_context (void);
extern void maybe_warn_variadic_templates (void); extern void maybe_warn_variadic_templates (void);
extern void maybe_warn_cpp0x (const char *); extern void maybe_warn_cpp0x (cpp0x_warn_str str);
extern bool pedwarn_cxx98 (location_t, int, const char *, ...) ATTRIBUTE_GCC_CXXDIAG(3,4); extern bool pedwarn_cxx98 (location_t, int, const char *, ...) ATTRIBUTE_GCC_CXXDIAG(3,4);
/* in except.c */ /* in except.c */
......
...@@ -4929,7 +4929,7 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p) ...@@ -4929,7 +4929,7 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p)
init = error_mark_node; init = error_mark_node;
} }
else else
maybe_warn_cpp0x ("extended initializer lists"); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
} }
d->cur++; d->cur++;
...@@ -5173,7 +5173,7 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup) ...@@ -5173,7 +5173,7 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup)
{ {
if (init_len == 0) if (init_len == 0)
{ {
maybe_warn_cpp0x ("extended initializer lists"); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
init = build_zero_init (type, NULL_TREE, false); init = build_zero_init (type, NULL_TREE, false);
} }
else if (init_len != 1) else if (init_len != 1)
...@@ -8526,7 +8526,7 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -8526,7 +8526,7 @@ grokdeclarator (const cp_declarator *declarator,
{ {
if (explicitp == 1) if (explicitp == 1)
{ {
maybe_warn_cpp0x ("explicit conversion operators"); maybe_warn_cpp0x (CPP0X_EXPLICIT_CONVERSION);
explicitp = 2; explicitp = 2;
} }
} }
......
...@@ -2885,20 +2885,57 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec, ...@@ -2885,20 +2885,57 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec,
/* Warn about the use of C++0x features when appropriate. */ /* Warn about the use of C++0x features when appropriate. */
void void
maybe_warn_cpp0x (const char* str) maybe_warn_cpp0x (cpp0x_warn_str str)
{ {
if ((cxx_dialect == cxx98) && !in_system_header) if ((cxx_dialect == cxx98) && !in_system_header)
/* We really want to suppress this warning in system headers, /* We really want to suppress this warning in system headers,
because libstdc++ uses variadic templates even when we aren't because libstdc++ uses variadic templates even when we aren't
in C++0x mode. */ in C++0x mode. */
pedwarn (input_location, 0, "%s only available with -std=c++0x or -std=gnu++0x", str); switch (str)
{
case CPP0X_INITIALIZER_LISTS:
pedwarn (input_location, 0,
"extended initializer lists "
"only available with -std=c++0x or -std=gnu++0x");
break;
case CPP0X_EXPLICIT_CONVERSION:
pedwarn (input_location, 0,
"explicit conversion operators "
"only available with -std=c++0x or -std=gnu++0x");
break;
case CPP0X_VARIADIC_TEMPLATES:
pedwarn (input_location, 0,
"variadic templates "
"only available with -std=c++0x or -std=gnu++0x");
break;
case CPP0X_LAMBDA_EXPR:
pedwarn (input_location, 0,
"lambda expressions "
"only available with -std=c++0x or -std=gnu++0x");
break;
case CPP0X_AUTO:
pedwarn (input_location, 0,
"C++0x auto only available with -std=c++0x or -std=gnu++0x");
break;
case CPP0X_SCOPED_ENUMS:
pedwarn (input_location, 0,
"scoped enums only available with -std=c++0x or -std=gnu++0x");
break;
case CPP0X_DEFAULTED_DELETED:
pedwarn (input_location, 0,
"defaulted and deleted functions "
"only available with -std=c++0x or -std=gnu++0x");
break;
default:
gcc_unreachable();
}
} }
/* Warn about the use of variadic templates when appropriate. */ /* Warn about the use of variadic templates when appropriate. */
void void
maybe_warn_variadic_templates (void) maybe_warn_variadic_templates (void)
{ {
maybe_warn_cpp0x ("variadic templates"); maybe_warn_cpp0x (CPP0X_VARIADIC_TEMPLATES);
} }
......
...@@ -3329,7 +3329,7 @@ cp_parser_primary_expression (cp_parser *parser, ...@@ -3329,7 +3329,7 @@ cp_parser_primary_expression (cp_parser *parser,
if (c_dialect_objc ()) if (c_dialect_objc ())
/* We have an Objective-C++ message. */ /* We have an Objective-C++ message. */
return cp_parser_objc_expression (parser); return cp_parser_objc_expression (parser);
maybe_warn_cpp0x ("lambda expressions"); maybe_warn_cpp0x (CPP0X_LAMBDA_EXPR);
return cp_parser_lambda_expression (parser); return cp_parser_lambda_expression (parser);
case CPP_OBJC_STRING: case CPP_OBJC_STRING:
...@@ -5275,7 +5275,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, ...@@ -5275,7 +5275,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser,
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
{ {
/* A braced-init-list. */ /* A braced-init-list. */
maybe_warn_cpp0x ("extended initializer lists"); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
expr = cp_parser_braced_list (parser, &expr_non_constant_p); expr = cp_parser_braced_list (parser, &expr_non_constant_p);
if (non_constant_p && expr_non_constant_p) if (non_constant_p && expr_non_constant_p)
*non_constant_p = true; *non_constant_p = true;
...@@ -5992,7 +5992,7 @@ cp_parser_new_initializer (cp_parser* parser) ...@@ -5992,7 +5992,7 @@ cp_parser_new_initializer (cp_parser* parser)
{ {
tree t; tree t;
bool expr_non_constant_p; bool expr_non_constant_p;
maybe_warn_cpp0x ("extended initializer lists"); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
t = cp_parser_braced_list (parser, &expr_non_constant_p); t = cp_parser_braced_list (parser, &expr_non_constant_p);
CONSTRUCTOR_IS_DIRECT_INIT (t) = 1; CONSTRUCTOR_IS_DIRECT_INIT (t) = 1;
expression_list = make_tree_vector_single (t); expression_list = make_tree_vector_single (t);
...@@ -6553,7 +6553,7 @@ cp_parser_assignment_expression (cp_parser* parser, bool cast_p, ...@@ -6553,7 +6553,7 @@ cp_parser_assignment_expression (cp_parser* parser, bool cast_p,
tree rhs = cp_parser_initializer_clause (parser, &non_constant_p); tree rhs = cp_parser_initializer_clause (parser, &non_constant_p);
if (BRACE_ENCLOSED_INITIALIZER_P (rhs)) if (BRACE_ENCLOSED_INITIALIZER_P (rhs))
maybe_warn_cpp0x ("extended initializer lists"); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
/* An assignment may not appear in a /* An assignment may not appear in a
constant-expression. */ constant-expression. */
...@@ -8143,7 +8143,7 @@ cp_parser_condition (cp_parser* parser) ...@@ -8143,7 +8143,7 @@ cp_parser_condition (cp_parser* parser)
initializer = cp_parser_initializer_clause (parser, &non_constant_p); initializer = cp_parser_initializer_clause (parser, &non_constant_p);
} }
if (BRACE_ENCLOSED_INITIALIZER_P (initializer)) if (BRACE_ENCLOSED_INITIALIZER_P (initializer))
maybe_warn_cpp0x ("extended initializer lists"); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
if (!non_constant_p) if (!non_constant_p)
initializer = fold_non_dependent_expr (initializer); initializer = fold_non_dependent_expr (initializer);
...@@ -8407,7 +8407,7 @@ cp_parser_jump_statement (cp_parser* parser) ...@@ -8407,7 +8407,7 @@ cp_parser_jump_statement (cp_parser* parser)
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
{ {
maybe_warn_cpp0x ("extended initializer lists"); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
expr = cp_parser_braced_list (parser, &expr_non_constant_p); expr = cp_parser_braced_list (parser, &expr_non_constant_p);
} }
else if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON)) else if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON))
...@@ -9922,7 +9922,7 @@ cp_parser_mem_initializer (cp_parser* parser) ...@@ -9922,7 +9922,7 @@ cp_parser_mem_initializer (cp_parser* parser)
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
{ {
bool expr_non_constant_p; bool expr_non_constant_p;
maybe_warn_cpp0x ("extended initializer lists"); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
expression_list = cp_parser_braced_list (parser, &expr_non_constant_p); expression_list = cp_parser_braced_list (parser, &expr_non_constant_p);
CONSTRUCTOR_IS_DIRECT_INIT (expression_list) = 1; CONSTRUCTOR_IS_DIRECT_INIT (expression_list) = 1;
expression_list = build_tree_list (NULL_TREE, expression_list); expression_list = build_tree_list (NULL_TREE, expression_list);
...@@ -11933,7 +11933,7 @@ cp_parser_simple_type_specifier (cp_parser* parser, ...@@ -11933,7 +11933,7 @@ cp_parser_simple_type_specifier (cp_parser* parser,
break; break;
case RID_AUTO: case RID_AUTO:
maybe_warn_cpp0x ("C++0x auto"); maybe_warn_cpp0x (CPP0X_AUTO);
type = make_auto (); type = make_auto ();
break; break;
...@@ -12240,7 +12240,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, ...@@ -12240,7 +12240,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
|| cp_lexer_next_token_is_keyword (parser->lexer, RID_STRUCT)) || cp_lexer_next_token_is_keyword (parser->lexer, RID_STRUCT))
{ {
if (cxx_dialect == cxx98) if (cxx_dialect == cxx98)
maybe_warn_cpp0x ("scoped enums"); maybe_warn_cpp0x (CPP0X_SCOPED_ENUMS);
/* Consume the `struct' or `class'. */ /* Consume the `struct' or `class'. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
...@@ -12577,7 +12577,7 @@ cp_parser_enum_specifier (cp_parser* parser) ...@@ -12577,7 +12577,7 @@ cp_parser_enum_specifier (cp_parser* parser)
|| cp_lexer_next_token_is_keyword (parser->lexer, RID_STRUCT)) || cp_lexer_next_token_is_keyword (parser->lexer, RID_STRUCT))
{ {
if (cxx_dialect == cxx98) if (cxx_dialect == cxx98)
maybe_warn_cpp0x ("scoped enums"); maybe_warn_cpp0x (CPP0X_SCOPED_ENUMS);
/* Consume the `struct' or `class' token. */ /* Consume the `struct' or `class' token. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
...@@ -12611,7 +12611,7 @@ cp_parser_enum_specifier (cp_parser* parser) ...@@ -12611,7 +12611,7 @@ cp_parser_enum_specifier (cp_parser* parser)
return NULL_TREE; return NULL_TREE;
if (cxx_dialect == cxx98) if (cxx_dialect == cxx98)
maybe_warn_cpp0x ("scoped enums"); maybe_warn_cpp0x (CPP0X_SCOPED_ENUMS);
has_underlying_type = true; has_underlying_type = true;
...@@ -15425,7 +15425,7 @@ cp_parser_initializer (cp_parser* parser, bool* is_direct_init, ...@@ -15425,7 +15425,7 @@ cp_parser_initializer (cp_parser* parser, bool* is_direct_init,
} }
else if (token->type == CPP_OPEN_BRACE) else if (token->type == CPP_OPEN_BRACE)
{ {
maybe_warn_cpp0x ("extended initializer lists"); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
init = cp_parser_braced_list (parser, non_constant_p); init = cp_parser_braced_list (parser, non_constant_p);
CONSTRUCTOR_IS_DIRECT_INIT (init) = 1; CONSTRUCTOR_IS_DIRECT_INIT (init) = 1;
} }
...@@ -16895,7 +16895,7 @@ cp_parser_pure_specifier (cp_parser* parser) ...@@ -16895,7 +16895,7 @@ cp_parser_pure_specifier (cp_parser* parser)
if (token->keyword == RID_DEFAULT if (token->keyword == RID_DEFAULT
|| token->keyword == RID_DELETE) || token->keyword == RID_DELETE)
{ {
maybe_warn_cpp0x ("defaulted and deleted functions"); maybe_warn_cpp0x (CPP0X_DEFAULTED_DELETED);
return token->u.value; return token->u.value;
} }
...@@ -18895,7 +18895,7 @@ cp_parser_functional_cast (cp_parser* parser, tree type) ...@@ -18895,7 +18895,7 @@ cp_parser_functional_cast (cp_parser* parser, tree type)
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
{ {
maybe_warn_cpp0x ("extended initializer lists"); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
expression_list = cp_parser_braced_list (parser, &nonconst_p); expression_list = cp_parser_braced_list (parser, &nonconst_p);
CONSTRUCTOR_IS_DIRECT_INIT (expression_list) = 1; CONSTRUCTOR_IS_DIRECT_INIT (expression_list) = 1;
if (TREE_CODE (type) == TYPE_DECL) if (TREE_CODE (type) == TYPE_DECL)
......
2009-11-18 Shujing Zhao <pearly.zhao@oracle.com>
* g++.old-deja/g++.other/crash28.C: Make expected dg-error strings
explicit.
* g++.dg/inherit/error4.C: Likewise.
* g++.dg/template/crash90.C: Likewise.
2009-11-18 Jakub Jelinek <jakub@redhat.com> 2009-11-18 Jakub Jelinek <jakub@redhat.com>
PR c++/3187 PR c++/3187
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
struct A { virtual ~A(); }; struct A { virtual ~A(); };
struct B : A A {}; // { dg-error "" } struct B : A A {}; // { dg-error "expected|initializer|invalid" }
A foo(const B &b) // { dg-error "" } A foo(const B &b) // { dg-error "" }
{ {
......
...@@ -4,5 +4,5 @@ template < unsigned > ...@@ -4,5 +4,5 @@ template < unsigned >
struct A ; struct A ;
template < typename > template < typename >
struct B ; struct B ;
template < typename T , A < B < T > // { dg-error "" } template < typename T , A < B < T > // { dg-error "initializer|parse error|valid type|expected" }
{ } { }
...@@ -31,5 +31,5 @@ public: ...@@ -31,5 +31,5 @@ public:
}; };
void foo::x() throw(bar) void foo::x() throw(bar)
{ {
if (!b) throw bar (static_cast<::N::X*>(this)); // { dg-error "" } parse error if (!b) throw bar (static_cast<::N::X*>(this)); // { dg-error "lambda expressions|expected" } parse error
} }
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