Commit 93678513 by Mark Mitchell Committed by Mark Mitchell

decl.c (build_enumerator): Do not issue duplicate error messages about invalid…

decl.c (build_enumerator): Do not issue duplicate error messages about invalid enumeration constants.

	* decl.c (build_enumerator): Do not issue duplicate error messages
	about invalid enumeration constants.
	* parser.c (cp_parser_non_integral_constant_expression): Always
	set parser->non_integral_constant_expression_p.
	(cp_parser_primary_expression): Add cast_p parameter.  Issue
	errors about invalid uses of floating-point literals in
	cast-expressions.
	(cp_parser_postfix_expression): Add cast_p parameter.
	(cp_parser_open_square_expression): Pass it.
	(cp_parser_parenthesized_expression_list): Add cast_p parameter.
	(cp_parser_unary_expression): Likewise.
	(cp_parser_new_placement): Pass it.
	(cp_parser_direct_new_declarator): Likewise.
	(cp_parser_new_initializer): Likewise.
	(cp_parser_cast_expression): Add cast_p parameter.
	(cp_parser_binary_expression): Likewise.
	(cp_parser_question_colon_clause): Likewise.
	(cp_parser_assignment_expression): Likewise.
	(cp_parser_expression): Likewise.
	(cp_parser_constant_expression): If an integral constant
	expression is invalid, return error_mark_node.
	(cp_parser_expression_statement): Pass cast_p.
	(cp_parser_condition): Likewise.
	(cp_parser_iteration_statement): Likewise.
	(cp_parser_jump_statement): Likewise.
	(cp_parser_mem_initializer): Likewise.
	(cp_parser_template_argument): Likewise.
	(cp_parser_parameter_declaration): Likewise.
	(cp_parser_initializer): Likewise.
	(cp_parser_throw_expression): Likewise.
	(cp_parser_attribute_list): Likewise.
	(cp_parser_simple_cast_expression): Likewise.
	(cp_parser_functional_cast): Likewise.
	(cp_parser_late_parsing_default_args): Likewise.
	(cp_parser_sizeof_operand): Save/restore
	non_integral_constant_expression_p.

	* include/std/std_limits.h (numeric_limits<float>::has_denorm):
	Add required cast.
	(numeric_limits<double>::has_denorm): Likewise.
	(numeric_limits<long double>::has_denorm): Likewise.

	* g++.dg/other/warning1.C: Adjust error messags.
	* g++.dg/parse/constant5.C: New test.

From-SVN: r94512
parent 782c0a3e
2005-01-31 Mark Mitchell <mark@codesourcery.com>
* decl.c (build_enumerator): Do not issue duplicate error messages
about invalid enumeration constants.
* parser.c (cp_parser_non_integral_constant_expression): Always
set parser->non_integral_constant_expression_p.
(cp_parser_primary_expression): Add cast_p parameter. Issue
errors about invalid uses of floating-point literals in
cast-expressions.
(cp_parser_postfix_expression): Add cast_p parameter.
(cp_parser_open_square_expression): Pass it.
(cp_parser_parenthesized_expression_list): Add cast_p parameter.
(cp_parser_unary_expression): Likewise.
(cp_parser_new_placement): Pass it.
(cp_parser_direct_new_declarator): Likewise.
(cp_parser_new_initializer): Likewise.
(cp_parser_cast_expression): Add cast_p parameter.
(cp_parser_binary_expression): Likewise.
(cp_parser_question_colon_clause): Likewise.
(cp_parser_assignment_expression): Likewise.
(cp_parser_expression): Likewise.
(cp_parser_constant_expression): If an integral constant
expression is invalid, return error_mark_node.
(cp_parser_expression_statement): Pass cast_p.
(cp_parser_condition): Likewise.
(cp_parser_iteration_statement): Likewise.
(cp_parser_jump_statement): Likewise.
(cp_parser_mem_initializer): Likewise.
(cp_parser_template_argument): Likewise.
(cp_parser_parameter_declaration): Likewise.
(cp_parser_initializer): Likewise.
(cp_parser_throw_expression): Likewise.
(cp_parser_attribute_list): Likewise.
(cp_parser_simple_cast_expression): Likewise.
(cp_parser_functional_cast): Likewise.
(cp_parser_late_parsing_default_args): Likewise.
(cp_parser_sizeof_operand): Save/restore
non_integral_constant_expression_p.
2005-01-31 Mike Stump <mrs@apple.com> 2005-01-31 Mike Stump <mrs@apple.com>
* parser.c (cp_lexer_new_main): Get the first token, first, before * parser.c (cp_lexer_new_main): Get the first token, first, before
......
...@@ -9682,6 +9682,11 @@ build_enumerator (tree name, tree value, tree enumtype) ...@@ -9682,6 +9682,11 @@ build_enumerator (tree name, tree value, tree enumtype)
tree context; tree context;
tree type; tree type;
/* If the VALUE was erroneous, pretend it wasn't there; that will
result in the enum being assigned the next value in sequence. */
if (value == error_mark_node)
value = NULL_TREE;
/* Remove no-op casts from the value. */ /* Remove no-op casts from the value. */
if (value) if (value)
STRIP_TYPE_NOPS (value); STRIP_TYPE_NOPS (value);
......
2005-01-31 Mark Mitchell <mark@codesourcery.com>
* g++.dg/other/warning1.C: Adjust error messags.
* g++.dg/parse/constant5.C: New test.
2005-01-31 Steven Bosscher <stevenb@suse.de> 2005-01-31 Steven Bosscher <stevenb@suse.de>
PR c/19333 PR c/19333
......
...@@ -7,8 +7,8 @@ extern "C" int printf(const char *, ...); ...@@ -7,8 +7,8 @@ extern "C" int printf(const char *, ...);
struct S struct S
{ {
static const float inf = 1.0f / 0.0f; // { dg-warning "1.0|initialization" } static const float inf = 1.0f / 0.0f; // { dg-warning "1.0|float|initialization" }
static const float nan = 0.0f / 0.0f; // { dg-warning "0.0|initialization" } static const float nan = 0.0f / 0.0f; // { dg-warning "0.0|float|initialization" }
}; };
int main() int main()
......
enum E {
a = 24.2, // { dg-error "constant" }
b = (int)3.7,
c = int(4.2),
d = (int)(4.2 + 3.7), // { dg-error "constant" }
e = int(4.2 - 3.7), // { dg-error "constant" }
f = (int)17.25
};
struct S {
static const int i = (int)4.2;
int j[(int)4.2];
static const int k = static_cast<short>(3.7);
};
2005-01-31 Mark Mitchell <mark@codesourcery.com>
* include/std/std_limits.h (numeric_limits<float>::has_denorm):
Add required cast.
(numeric_limits<double>::has_denorm): Likewise.
(numeric_limits<long double>::has_denorm): Likewise.
2005-01-31 Paolo Carlini <pcarlini@suse.de> 2005-01-31 Paolo Carlini <pcarlini@suse.de>
Gabriel Dos Reis <gdr@integrable-solutions.net> Gabriel Dos Reis <gdr@integrable-solutions.net>
......
...@@ -1007,7 +1007,7 @@ namespace std ...@@ -1007,7 +1007,7 @@ namespace std
static const bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__; static const bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__;
static const bool has_signaling_NaN = has_quiet_NaN; static const bool has_signaling_NaN = has_quiet_NaN;
static const float_denorm_style has_denorm static const float_denorm_style has_denorm
= __FLT_DENORM_MIN__ ? denorm_present : denorm_absent; = bool(__FLT_DENORM_MIN__) ? denorm_present : denorm_absent;
static const bool has_denorm_loss = __glibcxx_float_has_denorm_loss; static const bool has_denorm_loss = __glibcxx_float_has_denorm_loss;
static float infinity() throw() static float infinity() throw()
...@@ -1064,7 +1064,7 @@ namespace std ...@@ -1064,7 +1064,7 @@ namespace std
static const bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__; static const bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__;
static const bool has_signaling_NaN = has_quiet_NaN; static const bool has_signaling_NaN = has_quiet_NaN;
static const float_denorm_style has_denorm static const float_denorm_style has_denorm
= __DBL_DENORM_MIN__ ? denorm_present : denorm_absent; = bool(__DBL_DENORM_MIN__) ? denorm_present : denorm_absent;
static const bool has_denorm_loss = __glibcxx_double_has_denorm_loss; static const bool has_denorm_loss = __glibcxx_double_has_denorm_loss;
static double infinity() throw() static double infinity() throw()
...@@ -1121,7 +1121,7 @@ namespace std ...@@ -1121,7 +1121,7 @@ namespace std
static const bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__; static const bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__;
static const bool has_signaling_NaN = has_quiet_NaN; static const bool has_signaling_NaN = has_quiet_NaN;
static const float_denorm_style has_denorm static const float_denorm_style has_denorm
= __LDBL_DENORM_MIN__ ? denorm_present : denorm_absent; = bool(__LDBL_DENORM_MIN__) ? denorm_present : denorm_absent;
static const bool has_denorm_loss static const bool has_denorm_loss
= __glibcxx_long_double_has_denorm_loss; = __glibcxx_long_double_has_denorm_loss;
......
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