aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2014-09-24 17:23:56 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2014-09-24 17:23:56 +0000
commit083e891e69429f93b958f6c18e2d52f515bae572 (patch)
tree5828257c837204733ae0f5091cb5468196499f9b /gcc/c
parentdc9c1b91e6be77b710751e935d6c1e09d1f289a1 (diff)
downloadgcc-083e891e69429f93b958f6c18e2d52f515bae572.zip
gcc-083e891e69429f93b958f6c18e2d52f515bae572.tar.gz
gcc-083e891e69429f93b958f6c18e2d52f515bae572.tar.bz2
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
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog10
-rw-r--r--gcc/c/c-parser.c7
-rw-r--r--gcc/c/c-tree.h2
-rw-r--r--gcc/c/c-typeck.c7
4 files changed, 16 insertions, 10 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index af175a4..67099c1 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -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>
PR c/62024
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 3f4a92b..71f40b7 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -126,11 +126,6 @@ c_parse_init (void)
C++). It would then be possible to share more of the C and C++
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. */
typedef enum c_id_kind {
/* An ordinary identifier. */
@@ -5232,7 +5227,7 @@ c_parser_switch_statement (c_parser *parser)
save_break = c_break_label;
c_break_label = NULL_TREE;
body = c_parser_c99_block_statement (parser);
- c_finish_case (body);
+ c_finish_case (body, ce.original_type);
if (c_break_label)
{
location_t here = c_parser_peek_token (parser)->location;
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h
index 6004d50..fc145a85 100644
--- a/gcc/c/c-tree.h
+++ b/gcc/c/c-tree.h
@@ -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 void check_compound_literal_type (location_t, struct c_type_name *);
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_stmt (tree, tree);
extern int c_types_compatible_p (tree, tree);
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index da71ab2..f69c28b 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -9486,10 +9486,11 @@ do_case (location_t loc, tree low_value, tree high_value)
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
-c_finish_case (tree body)
+c_finish_case (tree body, tree type)
{
struct c_switch *cs = c_switch_stack;
location_t switch_location;
@@ -9499,7 +9500,7 @@ c_finish_case (tree body)
/* Emit warnings as needed. */
switch_location = EXPR_LOCATION (cs->switch_expr);
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));
/* Pop the stack. */