mirror of git://gcc.gnu.org/git/gcc.git
re PR c/61405 (Not emitting "enumeration value not handled in switch" warning for bit-field enums)
PR c/61405 PR c/53874 gcc/ * asan.c (maybe_instrument_call): Add default case. * ipa-pure-const.c (special_builtin_state): Likewise. * predict.c (expr_expected_value_1): Likewise. * lto-streamer-out.c (write_symbol): Initialize variable. gcc/c-family/ * c-common.h (struct c_common_resword): Don't define CPP_KEYWORD. gcc/c/ * c-parser.c: Don't define CPP_KEYWORD. (c_parser_switch_statement): Pass original type to c_finish_case. * c-tree.h (c_finish_case): Update declaration. * c-typeck.c (c_finish_case): Add TYPE parameter. Pass it conditionally to c_do_switch_warnings. gcc/cp/ * semantics.c (finish_switch_cond): Call unlowered_expr_type. * tree.c (bot_manip): Add default case. * parser.c (cp_parser_primary_expression): Cast the controlling expression of a switch to an int. (cp_parser_unqualified_id): Likewise. gcc/testsuite/ * c-c++-common/pr53874.c: New test. * c-c++-common/pr61405.c: New test. libcpp/ * include/cpplib.h (enum cpp_ttype): Define CPP_KEYWORD. From-SVN: r215559
This commit is contained in:
parent
dc9c1b91e6
commit
083e891e69
|
|
@ -1,3 +1,12 @@
|
||||||
|
2014-09-24 Marek Polacek <polacek@redhat.com>
|
||||||
|
|
||||||
|
PR c/61405
|
||||||
|
PR c/53874
|
||||||
|
* asan.c (maybe_instrument_call): Add default case.
|
||||||
|
* ipa-pure-const.c (special_builtin_state): Likewise.
|
||||||
|
* predict.c (expr_expected_value_1): Likewise.
|
||||||
|
* lto-streamer-out.c (write_symbol): Initialize variable.
|
||||||
|
|
||||||
2014-09-24 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
|
2014-09-24 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
|
||||||
|
|
||||||
* config/aarch64/arm_neon.h (vmuld_lane_f64): Use macro for getting
|
* config/aarch64/arm_neon.h (vmuld_lane_f64): Use macro for getting
|
||||||
|
|
|
||||||
|
|
@ -2027,6 +2027,8 @@ maybe_instrument_call (gimple_stmt_iterator *iter)
|
||||||
case BUILT_IN_TRAP:
|
case BUILT_IN_TRAP:
|
||||||
/* Don't instrument these. */
|
/* Don't instrument these. */
|
||||||
return false;
|
return false;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tree decl = builtin_decl_implicit (BUILT_IN_ASAN_HANDLE_NO_RETURN);
|
tree decl = builtin_decl_implicit (BUILT_IN_ASAN_HANDLE_NO_RETURN);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
2014-09-24 Marek Polacek <polacek@redhat.com>
|
||||||
|
|
||||||
|
PR c/61405
|
||||||
|
PR c/53874
|
||||||
|
* c-common.h (struct c_common_resword): Don't define CPP_KEYWORD.
|
||||||
|
|
||||||
2014-09-23 Andi Kleen <ak@linux.intel.com>
|
2014-09-23 Andi Kleen <ak@linux.intel.com>
|
||||||
|
|
||||||
* c-common.c (handle_no_reorder_attribute): New function.
|
* c-common.c (handle_no_reorder_attribute): New function.
|
||||||
|
|
|
||||||
|
|
@ -327,9 +327,6 @@ struct c_common_resword
|
||||||
|
|
||||||
/* Extra cpp_ttype values for C++. */
|
/* Extra cpp_ttype values for C++. */
|
||||||
|
|
||||||
/* A token type for keywords, as opposed to ordinary identifiers. */
|
|
||||||
#define CPP_KEYWORD ((enum cpp_ttype) (N_TTYPES + 1))
|
|
||||||
|
|
||||||
/* A token type for template-ids. If a template-id is processed while
|
/* A token type for template-ids. If a template-id is processed while
|
||||||
parsing tentatively, it is replaced with a CPP_TEMPLATE_ID token;
|
parsing tentatively, it is replaced with a CPP_TEMPLATE_ID token;
|
||||||
the value of the CPP_TEMPLATE_ID is whatever was returned by
|
the value of the CPP_TEMPLATE_ID is whatever was returned by
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,13 @@
|
||||||
|
2014-09-24 Marek Polacek <polacek@redhat.com>
|
||||||
|
|
||||||
|
PR c/61405
|
||||||
|
PR c/53874
|
||||||
|
* c-parser.c: Don't define CPP_KEYWORD.
|
||||||
|
(c_parser_switch_statement): Pass original type to c_finish_case.
|
||||||
|
* c-tree.h (c_finish_case): Update declaration.
|
||||||
|
* c-typeck.c (c_finish_case): Add TYPE parameter. Pass it
|
||||||
|
conditionally to c_do_switch_warnings.
|
||||||
|
|
||||||
2014-09-03 Marek Polacek <polacek@redhat.com>
|
2014-09-03 Marek Polacek <polacek@redhat.com>
|
||||||
|
|
||||||
PR c/62024
|
PR c/62024
|
||||||
|
|
|
||||||
|
|
@ -126,11 +126,6 @@ c_parse_init (void)
|
||||||
C++). It would then be possible to share more of the C and C++
|
C++). It would then be possible to share more of the C and C++
|
||||||
lexer code, if desired. */
|
lexer code, if desired. */
|
||||||
|
|
||||||
/* The following local token type is used. */
|
|
||||||
|
|
||||||
/* A keyword. */
|
|
||||||
#define CPP_KEYWORD ((enum cpp_ttype) (N_TTYPES + 1))
|
|
||||||
|
|
||||||
/* More information about the type of a CPP_NAME token. */
|
/* More information about the type of a CPP_NAME token. */
|
||||||
typedef enum c_id_kind {
|
typedef enum c_id_kind {
|
||||||
/* An ordinary identifier. */
|
/* An ordinary identifier. */
|
||||||
|
|
@ -5232,7 +5227,7 @@ c_parser_switch_statement (c_parser *parser)
|
||||||
save_break = c_break_label;
|
save_break = c_break_label;
|
||||||
c_break_label = NULL_TREE;
|
c_break_label = NULL_TREE;
|
||||||
body = c_parser_c99_block_statement (parser);
|
body = c_parser_c99_block_statement (parser);
|
||||||
c_finish_case (body);
|
c_finish_case (body, ce.original_type);
|
||||||
if (c_break_label)
|
if (c_break_label)
|
||||||
{
|
{
|
||||||
location_t here = c_parser_peek_token (parser)->location;
|
location_t here = c_parser_peek_token (parser)->location;
|
||||||
|
|
|
||||||
|
|
@ -618,7 +618,7 @@ extern void process_init_element (location_t, struct c_expr, bool,
|
||||||
extern tree build_compound_literal (location_t, tree, tree, bool);
|
extern tree build_compound_literal (location_t, tree, tree, bool);
|
||||||
extern void check_compound_literal_type (location_t, struct c_type_name *);
|
extern void check_compound_literal_type (location_t, struct c_type_name *);
|
||||||
extern tree c_start_case (location_t, location_t, tree, bool);
|
extern tree c_start_case (location_t, location_t, tree, bool);
|
||||||
extern void c_finish_case (tree);
|
extern void c_finish_case (tree, tree);
|
||||||
extern tree build_asm_expr (location_t, tree, tree, tree, tree, tree, bool);
|
extern tree build_asm_expr (location_t, tree, tree, tree, tree, tree, bool);
|
||||||
extern tree build_asm_stmt (tree, tree);
|
extern tree build_asm_stmt (tree, tree);
|
||||||
extern int c_types_compatible_p (tree, tree);
|
extern int c_types_compatible_p (tree, tree);
|
||||||
|
|
|
||||||
|
|
@ -9486,10 +9486,11 @@ do_case (location_t loc, tree low_value, tree high_value)
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finish the switch statement. */
|
/* Finish the switch statement. TYPE is the original type of the
|
||||||
|
controlling expression of the switch, or NULL_TREE. */
|
||||||
|
|
||||||
void
|
void
|
||||||
c_finish_case (tree body)
|
c_finish_case (tree body, tree type)
|
||||||
{
|
{
|
||||||
struct c_switch *cs = c_switch_stack;
|
struct c_switch *cs = c_switch_stack;
|
||||||
location_t switch_location;
|
location_t switch_location;
|
||||||
|
|
@ -9499,7 +9500,7 @@ c_finish_case (tree body)
|
||||||
/* Emit warnings as needed. */
|
/* Emit warnings as needed. */
|
||||||
switch_location = EXPR_LOCATION (cs->switch_expr);
|
switch_location = EXPR_LOCATION (cs->switch_expr);
|
||||||
c_do_switch_warnings (cs->cases, switch_location,
|
c_do_switch_warnings (cs->cases, switch_location,
|
||||||
TREE_TYPE (cs->switch_expr),
|
type ? type : TREE_TYPE (cs->switch_expr),
|
||||||
SWITCH_COND (cs->switch_expr));
|
SWITCH_COND (cs->switch_expr));
|
||||||
|
|
||||||
/* Pop the stack. */
|
/* Pop the stack. */
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,13 @@
|
||||||
|
2014-09-24 Marek Polacek <polacek@redhat.com>
|
||||||
|
|
||||||
|
PR c/61405
|
||||||
|
PR c/53874
|
||||||
|
* semantics.c (finish_switch_cond): Call unlowered_expr_type.
|
||||||
|
* tree.c (bot_manip): Add default case.
|
||||||
|
* parser.c (cp_parser_primary_expression): Cast the controlling
|
||||||
|
expression of a switch to an int.
|
||||||
|
(cp_parser_unqualified_id): Likewise.
|
||||||
|
|
||||||
2014-09-23 Paolo Carlini <paolo.carlini@oracle.com>
|
2014-09-23 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
PR c++/61857
|
PR c++/61857
|
||||||
|
|
|
||||||
|
|
@ -4176,7 +4176,7 @@ cp_parser_primary_expression (cp_parser *parser,
|
||||||
|
|
||||||
/* Peek at the next token. */
|
/* Peek at the next token. */
|
||||||
token = cp_lexer_peek_token (parser->lexer);
|
token = cp_lexer_peek_token (parser->lexer);
|
||||||
switch (token->type)
|
switch ((int) token->type)
|
||||||
{
|
{
|
||||||
/* literal:
|
/* literal:
|
||||||
integer-literal
|
integer-literal
|
||||||
|
|
@ -4862,7 +4862,7 @@ cp_parser_unqualified_id (cp_parser* parser,
|
||||||
/* Peek at the next token. */
|
/* Peek at the next token. */
|
||||||
token = cp_lexer_peek_token (parser->lexer);
|
token = cp_lexer_peek_token (parser->lexer);
|
||||||
|
|
||||||
switch (token->type)
|
switch ((int) token->type)
|
||||||
{
|
{
|
||||||
case CPP_NAME:
|
case CPP_NAME:
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1127,7 +1127,8 @@ finish_switch_cond (tree cond, tree switch_stmt)
|
||||||
error ("switch quantity not an integer");
|
error ("switch quantity not an integer");
|
||||||
cond = error_mark_node;
|
cond = error_mark_node;
|
||||||
}
|
}
|
||||||
orig_type = TREE_TYPE (cond);
|
/* We want unlowered type here to handle enum bit-fields. */
|
||||||
|
orig_type = unlowered_expr_type (cond);
|
||||||
if (cond != error_mark_node)
|
if (cond != error_mark_node)
|
||||||
{
|
{
|
||||||
/* Warn if the condition has boolean value. */
|
/* Warn if the condition has boolean value. */
|
||||||
|
|
|
||||||
|
|
@ -2345,6 +2345,8 @@ bot_manip (tree* tp, int* walk_subtrees, void* data)
|
||||||
case BUILT_IN_FILE:
|
case BUILT_IN_FILE:
|
||||||
case BUILT_IN_LINE:
|
case BUILT_IN_LINE:
|
||||||
SET_EXPR_LOCATION (*tp, input_location);
|
SET_EXPR_LOCATION (*tp, input_location);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
|
|
|
||||||
|
|
@ -451,6 +451,8 @@ special_builtin_state (enum pure_const_state_e *state, bool *looping,
|
||||||
*looping = true;
|
*looping = true;
|
||||||
*state = IPA_CONST;
|
*state = IPA_CONST;
|
||||||
return true;
|
return true;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2422,7 +2422,7 @@ write_symbol (struct streamer_tree_cache_d *cache,
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
enum gcc_plugin_symbol_kind kind;
|
enum gcc_plugin_symbol_kind kind;
|
||||||
enum gcc_plugin_symbol_visibility visibility;
|
enum gcc_plugin_symbol_visibility visibility = GCCPV_DEFAULT;
|
||||||
unsigned slot_num;
|
unsigned slot_num;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
const char *comdat;
|
const char *comdat;
|
||||||
|
|
|
||||||
|
|
@ -1902,6 +1902,8 @@ expr_expected_value_1 (tree type, tree op0, enum tree_code code,
|
||||||
if (predictor)
|
if (predictor)
|
||||||
*predictor = PRED_COMPARE_AND_SWAP;
|
*predictor = PRED_COMPARE_AND_SWAP;
|
||||||
return boolean_true_node;
|
return boolean_true_node;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
|
2014-09-24 Marek Polacek <polacek@redhat.com>
|
||||||
|
|
||||||
|
PR c/61405
|
||||||
|
PR c/53874
|
||||||
|
* c-c++-common/pr53874.c: New test.
|
||||||
|
* c-c++-common/pr61405.c: New test.
|
||||||
|
|
||||||
2014-09-24 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
|
2014-09-24 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
|
||||||
|
|
||||||
* gcc.target/aarch64/simd/vmul_lane_const_lane_1.c: New test.
|
* gcc.target/aarch64/simd/vmul_lane_const_lane_1.c: New test.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
/* PR c/53874 */
|
||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-options "-Wswitch-enum" } */
|
||||||
|
|
||||||
|
enum E { A, B, C };
|
||||||
|
struct S { enum E e:2; };
|
||||||
|
typedef struct S TS;
|
||||||
|
|
||||||
|
int
|
||||||
|
fn0 (struct S *s)
|
||||||
|
{
|
||||||
|
switch (s->e) /* { dg-warning "enumeration value .C. not handled in switch" } */
|
||||||
|
{
|
||||||
|
case A:
|
||||||
|
return 1;
|
||||||
|
case B:
|
||||||
|
return 2;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
fn1 (TS *s)
|
||||||
|
{
|
||||||
|
switch (s->e) /* { dg-warning "enumeration value .C. not handled in switch" } */
|
||||||
|
{
|
||||||
|
case A:
|
||||||
|
return 1;
|
||||||
|
case B:
|
||||||
|
return 2;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
/* PR c/61405 */
|
||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-options "-Wswitch" } */
|
||||||
|
|
||||||
|
enum E { A, B, C };
|
||||||
|
struct S { enum E e:2; };
|
||||||
|
typedef struct S TS;
|
||||||
|
|
||||||
|
int
|
||||||
|
fn0 (struct S *s)
|
||||||
|
{
|
||||||
|
switch (s->e) /* { dg-warning "enumeration value .C. not handled in switch" } */
|
||||||
|
{
|
||||||
|
case A:
|
||||||
|
return 1;
|
||||||
|
case B:
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
fn1 (TS *s)
|
||||||
|
{
|
||||||
|
switch (s->e) /* { dg-warning "enumeration value .C. not handled in switch" } */
|
||||||
|
{
|
||||||
|
case A:
|
||||||
|
return 1;
|
||||||
|
case B:
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
2014-09-24 Marek Polacek <polacek@redhat.com>
|
||||||
|
|
||||||
|
PR c/61405
|
||||||
|
PR c/53874
|
||||||
|
* include/cpplib.h (enum cpp_ttype): Define CPP_KEYWORD.
|
||||||
|
|
||||||
2014-09-17 Jan Hubicka <hubicka@ucw.cz>
|
2014-09-17 Jan Hubicka <hubicka@ucw.cz>
|
||||||
|
|
||||||
* charset.c (conversion): Rename to ...
|
* charset.c (conversion): Rename to ...
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,9 @@ enum cpp_ttype
|
||||||
TTYPE_TABLE
|
TTYPE_TABLE
|
||||||
N_TTYPES,
|
N_TTYPES,
|
||||||
|
|
||||||
|
/* A token type for keywords, as opposed to ordinary identifiers. */
|
||||||
|
CPP_KEYWORD,
|
||||||
|
|
||||||
/* Positions in the table. */
|
/* Positions in the table. */
|
||||||
CPP_LAST_EQ = CPP_LSHIFT,
|
CPP_LAST_EQ = CPP_LSHIFT,
|
||||||
CPP_FIRST_DIGRAPH = CPP_HASH,
|
CPP_FIRST_DIGRAPH = CPP_HASH,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue