aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorShujing Zhao <pearly.zhao@oracle.com>2009-11-18 11:36:00 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2009-11-18 11:36:00 +0000
commit848f237b0d51efe763c65723b05cd437cc7af632 (patch)
tree7036ec08c88d6e80941c5ee33f0aeb272eecb880 /gcc/cp
parent7b98c16f7ae55a9e74e93aeadfc7e3c456dd6a01 (diff)
downloadgcc-848f237b0d51efe763c65723b05cd437cc7af632.zip
gcc-848f237b0d51efe763c65723b05cd437cc7af632.tar.gz
gcc-848f237b0d51efe763c65723b05cd437cc7af632.tar.bz2
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
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog19
-rw-r--r--gcc/cp/call.c2
-rw-r--r--gcc/cp/cp-tree.h24
-rw-r--r--gcc/cp/decl.c6
-rw-r--r--gcc/cp/error.c43
-rw-r--r--gcc/cp/parser.c28
6 files changed, 100 insertions, 22 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b3acf8e..4e1f469 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,22 @@
+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>
PR c++/3187
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index e051e90..ca6bd0b 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -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))
{
- maybe_warn_cpp0x ("extended initializer lists");
+ maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
conv = implicit_conversion (to, from, expr, c_cast_p,
flags);
if (!CLASS_TYPE_P (to)
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 3652fe0..3aff7ec 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -382,6 +382,28 @@ typedef enum cp_id_kind
CP_ID_KIND_QUALIFIED
} 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. */
#define IDENTIFIER_NAMESPACE_BINDINGS(NODE) \
@@ -4672,7 +4694,7 @@ extern const char *language_to_string (enum languages);
extern const char *class_key_or_enum_as_string (tree);
extern void print_instantiation_context (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);
/* in except.c */
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index f57efb7..599b39a 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4929,7 +4929,7 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p)
init = error_mark_node;
}
else
- maybe_warn_cpp0x ("extended initializer lists");
+ maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
}
d->cur++;
@@ -5173,7 +5173,7 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup)
{
if (init_len == 0)
{
- maybe_warn_cpp0x ("extended initializer lists");
+ maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
init = build_zero_init (type, NULL_TREE, false);
}
else if (init_len != 1)
@@ -8526,7 +8526,7 @@ grokdeclarator (const cp_declarator *declarator,
{
if (explicitp == 1)
{
- maybe_warn_cpp0x ("explicit conversion operators");
+ maybe_warn_cpp0x (CPP0X_EXPLICIT_CONVERSION);
explicitp = 2;
}
}
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 7266d88..a424299 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -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. */
void
-maybe_warn_cpp0x (const char* str)
+maybe_warn_cpp0x (cpp0x_warn_str str)
{
if ((cxx_dialect == cxx98) && !in_system_header)
/* We really want to suppress this warning in system headers,
because libstdc++ uses variadic templates even when we aren't
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. */
void
maybe_warn_variadic_templates (void)
{
- maybe_warn_cpp0x ("variadic templates");
+ maybe_warn_cpp0x (CPP0X_VARIADIC_TEMPLATES);
}
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 57684264..284d167 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -3329,7 +3329,7 @@ cp_parser_primary_expression (cp_parser *parser,
if (c_dialect_objc ())
/* We have an Objective-C++ message. */
return cp_parser_objc_expression (parser);
- maybe_warn_cpp0x ("lambda expressions");
+ maybe_warn_cpp0x (CPP0X_LAMBDA_EXPR);
return cp_parser_lambda_expression (parser);
case CPP_OBJC_STRING:
@@ -5275,7 +5275,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser,
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
{
/* 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);
if (non_constant_p && expr_non_constant_p)
*non_constant_p = true;
@@ -5992,7 +5992,7 @@ cp_parser_new_initializer (cp_parser* parser)
{
tree t;
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);
CONSTRUCTOR_IS_DIRECT_INIT (t) = 1;
expression_list = make_tree_vector_single (t);
@@ -6553,7 +6553,7 @@ cp_parser_assignment_expression (cp_parser* parser, bool cast_p,
tree rhs = cp_parser_initializer_clause (parser, &non_constant_p);
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
constant-expression. */
@@ -8143,7 +8143,7 @@ cp_parser_condition (cp_parser* parser)
initializer = cp_parser_initializer_clause (parser, &non_constant_p);
}
if (BRACE_ENCLOSED_INITIALIZER_P (initializer))
- maybe_warn_cpp0x ("extended initializer lists");
+ maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
if (!non_constant_p)
initializer = fold_non_dependent_expr (initializer);
@@ -8407,7 +8407,7 @@ cp_parser_jump_statement (cp_parser* parser)
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);
}
else if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON))
@@ -9922,7 +9922,7 @@ cp_parser_mem_initializer (cp_parser* parser)
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
{
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);
CONSTRUCTOR_IS_DIRECT_INIT (expression_list) = 1;
expression_list = build_tree_list (NULL_TREE, expression_list);
@@ -11933,7 +11933,7 @@ cp_parser_simple_type_specifier (cp_parser* parser,
break;
case RID_AUTO:
- maybe_warn_cpp0x ("C++0x auto");
+ maybe_warn_cpp0x (CPP0X_AUTO);
type = make_auto ();
break;
@@ -12240,7 +12240,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
|| cp_lexer_next_token_is_keyword (parser->lexer, RID_STRUCT))
{
if (cxx_dialect == cxx98)
- maybe_warn_cpp0x ("scoped enums");
+ maybe_warn_cpp0x (CPP0X_SCOPED_ENUMS);
/* Consume the `struct' or `class'. */
cp_lexer_consume_token (parser->lexer);
@@ -12577,7 +12577,7 @@ cp_parser_enum_specifier (cp_parser* parser)
|| cp_lexer_next_token_is_keyword (parser->lexer, RID_STRUCT))
{
if (cxx_dialect == cxx98)
- maybe_warn_cpp0x ("scoped enums");
+ maybe_warn_cpp0x (CPP0X_SCOPED_ENUMS);
/* Consume the `struct' or `class' token. */
cp_lexer_consume_token (parser->lexer);
@@ -12611,7 +12611,7 @@ cp_parser_enum_specifier (cp_parser* parser)
return NULL_TREE;
if (cxx_dialect == cxx98)
- maybe_warn_cpp0x ("scoped enums");
+ maybe_warn_cpp0x (CPP0X_SCOPED_ENUMS);
has_underlying_type = true;
@@ -15425,7 +15425,7 @@ cp_parser_initializer (cp_parser* parser, bool* is_direct_init,
}
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);
CONSTRUCTOR_IS_DIRECT_INIT (init) = 1;
}
@@ -16895,7 +16895,7 @@ cp_parser_pure_specifier (cp_parser* parser)
if (token->keyword == RID_DEFAULT
|| token->keyword == RID_DELETE)
{
- maybe_warn_cpp0x ("defaulted and deleted functions");
+ maybe_warn_cpp0x (CPP0X_DEFAULTED_DELETED);
return token->u.value;
}
@@ -18895,7 +18895,7 @@ cp_parser_functional_cast (cp_parser* parser, tree type)
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);
CONSTRUCTOR_IS_DIRECT_INIT (expression_list) = 1;
if (TREE_CODE (type) == TYPE_DECL)