From 222dbebefbbc07f78e51d82ba605988ef57e5fc9 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 1 Jan 2022 06:29:36 +0100 Subject: objc: Fix handling of break stmt inside of switch inside of ObjC foreach [PR103639] The r11-3302-g3696a50beeb73f changes broke the following ObjC testcase. in_statement is either 0 (not in a looping statement), various IN_* flags for various kinds of looping statements (or OpenMP structured blocks) or those flags ored with IN_SWITCH_STMT when a switch appears inside of those contexts. This is because break binds to switch in that last case, but continue binds to the looping construct in that case. The c_finish_bc_stmt function performs diagnostics on incorrect break/continue uses and then checks if in_statement & IN_OBJC_FOREACH and in that case jumps to the label provided by the caller, otherwise emits a BREAK_STMT or CONTINUE_STMT. This is incorrect if we have ObjC foreach with switch nested in it and break inside of that, in_statement in that case is IN_OBJC_FOREACH | IN_SWITCH_STMT and is_break is true. We want to handle it like other breaks inside of switch, i.e. emit a BREAK_STMT. The following patch fixes that. 2022-01-01 Jakub Jelinek PR objc/103639 * c-typeck.c (c_finish_bc_stmt): For break inside of switch inside of ObjC foreach, emit normal BREAK_STMT rather than goto to label. 2022-01-01 Iain Sandoe PR objc/103639 * objc.dg/pr103639.m: New test. --- gcc/c/c-typeck.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/c') diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 78a6c68..71724be 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -11257,7 +11257,8 @@ c_finish_bc_stmt (location_t loc, tree label, bool is_break) if (skip) return NULL_TREE; - else if (in_statement & IN_OBJC_FOREACH) + else if ((in_statement & IN_OBJC_FOREACH) + && !(is_break && (in_statement & IN_SWITCH_STMT))) { /* The foreach expander produces low-level code using gotos instead of a structured loop construct. */ -- cgit v1.1 From 62eb5308fe6c46f7eded3c9e06c53491515a6e63 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sun, 2 Jan 2022 00:16:28 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 212d4c7..d58fb91 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2022-01-01 Jakub Jelinek + + PR objc/103639 + * c-typeck.c (c_finish_bc_stmt): For break inside of switch inside of + ObjC foreach, emit normal BREAK_STMT rather than goto to label. + 2021-12-17 Marek Polacek PR c/103649 -- cgit v1.1 From 877e3c2abf7a29d746ffda6354d6f19855595905 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 3 Jan 2022 10:31:39 +0100 Subject: Update Copyright in ChangeLog files Do this separately from all other Copyright updates, as ChangeLog files can be modified only separately. --- gcc/c/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index d58fb91..c3933da 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -8158,7 +8158,7 @@ * c-decl.c: Likewise. Include gt-c-c-decl.h, not gt-c-decl.h. * c-parser.c: Likewise. Include gt-c-c-parser.h, not gt-c-parser.h. -Copyright (C) 2012-2021 Free Software Foundation, Inc. +Copyright (C) 2012-2022 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright -- cgit v1.1 From 7adcbafe45f8001b698967defe682687b52c0007 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 3 Jan 2022 10:42:10 +0100 Subject: Update copyright years. --- gcc/c/Make-lang.in | 2 +- gcc/c/c-aux-info.c | 2 +- gcc/c/c-convert.c | 2 +- gcc/c/c-decl.c | 2 +- gcc/c/c-errors.c | 2 +- gcc/c/c-fold.c | 2 +- gcc/c/c-lang.c | 2 +- gcc/c/c-lang.h | 2 +- gcc/c/c-objc-common.c | 2 +- gcc/c/c-objc-common.h | 2 +- gcc/c/c-parser.c | 2 +- gcc/c/c-parser.h | 2 +- gcc/c/c-tree.h | 2 +- gcc/c/c-typeck.c | 2 +- gcc/c/config-lang.in | 2 +- gcc/c/gccspec.c | 2 +- gcc/c/gimple-parser.c | 2 +- gcc/c/gimple-parser.h | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/Make-lang.in b/gcc/c/Make-lang.in index 9090096..b0e9994 100644 --- a/gcc/c/Make-lang.in +++ b/gcc/c/Make-lang.in @@ -1,5 +1,5 @@ # Top level -*- makefile -*- fragment for GNU C - C language. -# Copyright (C) 1994-2021 Free Software Foundation, Inc. +# Copyright (C) 1994-2022 Free Software Foundation, Inc. #This file is part of GCC. diff --git a/gcc/c/c-aux-info.c b/gcc/c/c-aux-info.c index 81860cb..bf01315 100644 --- a/gcc/c/c-aux-info.c +++ b/gcc/c/c-aux-info.c @@ -1,7 +1,7 @@ /* Generate information regarding function declarations and definitions based on information stored in GCC's tree structure. This code implements the -aux-info option. - Copyright (C) 1989-2021 Free Software Foundation, Inc. + Copyright (C) 1989-2022 Free Software Foundation, Inc. Contributed by Ron Guilmette (rfg@segfault.us.com). This file is part of GCC. diff --git a/gcc/c/c-convert.c b/gcc/c/c-convert.c index 905b26a..5e92759 100644 --- a/gcc/c/c-convert.c +++ b/gcc/c/c-convert.c @@ -1,5 +1,5 @@ /* Language-level data type conversion for GNU C. - Copyright (C) 1987-2021 Free Software Foundation, Inc. + Copyright (C) 1987-2022 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 516e3c2..29a79eb 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -1,5 +1,5 @@ /* Process declarations and variables for C compiler. - Copyright (C) 1988-2021 Free Software Foundation, Inc. + Copyright (C) 1988-2022 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/c/c-errors.c b/gcc/c/c-errors.c index de98958..ced12ed 100644 --- a/gcc/c/c-errors.c +++ b/gcc/c/c-errors.c @@ -1,5 +1,5 @@ /* Various diagnostic subroutines for the GNU C language. - Copyright (C) 2000-2021 Free Software Foundation, Inc. + Copyright (C) 2000-2022 Free Software Foundation, Inc. Contributed by Gabriel Dos Reis This file is part of GCC. diff --git a/gcc/c/c-fold.c b/gcc/c/c-fold.c index 0ebcb46..fc593753 100644 --- a/gcc/c/c-fold.c +++ b/gcc/c/c-fold.c @@ -1,5 +1,5 @@ /* Support for fully folding sub-trees of an expression for C compiler. - Copyright (C) 1992-2021 Free Software Foundation, Inc. + Copyright (C) 1992-2022 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/c/c-lang.c b/gcc/c/c-lang.c index 778a6f2..eecc0a0 100644 --- a/gcc/c/c-lang.c +++ b/gcc/c/c-lang.c @@ -1,5 +1,5 @@ /* Language-specific hook definitions for C front end. - Copyright (C) 1991-2021 Free Software Foundation, Inc. + Copyright (C) 1991-2022 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/c/c-lang.h b/gcc/c/c-lang.h index 2f62ee1..7bdab47 100644 --- a/gcc/c/c-lang.h +++ b/gcc/c/c-lang.h @@ -1,5 +1,5 @@ /* Definitions for C language specific types. - Copyright (C) 2009-2021 Free Software Foundation, Inc. + Copyright (C) 2009-2022 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/c/c-objc-common.c b/gcc/c/c-objc-common.c index cdb2242..97850ad 100644 --- a/gcc/c/c-objc-common.c +++ b/gcc/c/c-objc-common.c @@ -1,5 +1,5 @@ /* Some code common to C and ObjC front ends. - Copyright (C) 2001-2021 Free Software Foundation, Inc. + Copyright (C) 2001-2022 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h index f4e8271..d23bdea 100644 --- a/gcc/c/c-objc-common.h +++ b/gcc/c/c-objc-common.h @@ -1,5 +1,5 @@ /* Language hooks common to C and ObjC front ends. - Copyright (C) 2004-2021 Free Software Foundation, Inc. + Copyright (C) 2004-2022 Free Software Foundation, Inc. Contributed by Ziemowit Laski This file is part of GCC. diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index b09ad30..6ada004 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -1,5 +1,5 @@ /* Parser for C and Objective-C. - Copyright (C) 1987-2021 Free Software Foundation, Inc. + Copyright (C) 1987-2022 Free Software Foundation, Inc. Parser actions based on the old Bison parser; structure somewhat influenced by and fragments based on the C++ parser. diff --git a/gcc/c/c-parser.h b/gcc/c/c-parser.h index 773aa43..8d5fc30 100644 --- a/gcc/c/c-parser.h +++ b/gcc/c/c-parser.h @@ -1,5 +1,5 @@ /* Declarations for the parser for C and Objective-C. - Copyright (C) 1987-2021 Free Software Foundation, Inc. + Copyright (C) 1987-2022 Free Software Foundation, Inc. Parser actions based on the old Bison parser; structure somewhat influenced by and fragments based on the C++ parser. diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index f1dbbd5..df03fd2 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -1,5 +1,5 @@ /* Definitions for C parsing and type checking. - Copyright (C) 1987-2021 Free Software Foundation, Inc. + Copyright (C) 1987-2022 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 71724be..8b492cf 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -1,5 +1,5 @@ /* Build expressions with type checking for C compiler. - Copyright (C) 1987-2021 Free Software Foundation, Inc. + Copyright (C) 1987-2022 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/c/config-lang.in b/gcc/c/config-lang.in index b9cf5f3..cb697e8 100644 --- a/gcc/c/config-lang.in +++ b/gcc/c/config-lang.in @@ -1,5 +1,5 @@ # Top level configure fragment for GNU C - C language. -# Copyright (C) 1994-2021 Free Software Foundation, Inc. +# Copyright (C) 1994-2022 Free Software Foundation, Inc. #This file is part of GCC. diff --git a/gcc/c/gccspec.c b/gcc/c/gccspec.c index db353a3..d1165dd 100644 --- a/gcc/c/gccspec.c +++ b/gcc/c/gccspec.c @@ -1,5 +1,5 @@ /* Specific flags and argument handling of the C front-end. - Copyright (C) 1999-2021 Free Software Foundation, Inc. + Copyright (C) 1999-2022 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index f594a8c..51ddd86 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -1,5 +1,5 @@ /* Parser for GIMPLE. - Copyright (C) 2016-2021 Free Software Foundation, Inc. + Copyright (C) 2016-2022 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/c/gimple-parser.h b/gcc/c/gimple-parser.h index 6501bcf..2881a65 100644 --- a/gcc/c/gimple-parser.h +++ b/gcc/c/gimple-parser.h @@ -1,5 +1,5 @@ /* Declarations for the parser for GIMPLE. - Copyright (C) 2016-2021 Free Software Foundation, Inc. + Copyright (C) 2016-2022 Free Software Foundation, Inc. This file is part of GCC. -- cgit v1.1