Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
173028e5
Commit
173028e5
authored
Mar 26, 2002
by
Andrew Cagney
Committed by
Andrew Cagney
Mar 26, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add -Wswitch-enum. Document.
Fix PR c/5044. From-SVN: r51386
parent
e14365a7
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
113 additions
and
6 deletions
+113
-6
gcc/ChangeLog
+12
-0
gcc/doc/invoke.texi
+9
-2
gcc/f/ChangeLog
+5
-0
gcc/f/invoke.texi
+3
-0
gcc/flags.h
+5
-0
gcc/stmt.c
+4
-4
gcc/testsuite/ChangeLog
+5
-0
gcc/testsuite/gcc.dg/Wswitch-enum.c
+63
-0
gcc/toplev.c
+7
-0
No files found.
gcc/ChangeLog
View file @
173028e5
2002-03-26 Andrew Cagney <ac131313@redhat.com>
* doc/invoke.texi (Option Summary): Mention -Wswitch-enum.
(Warning Options): Document -Wswitch-enum.
* toplev.c (W_options): Add -Wswitch-enum. Update comment on
-Wswitch.
(warn_switch_enum): Define variables.
* flags.h (warn_switch_enum): Declare variables.
* stmt.c (expand_end_case_type): When warn_switch_enum /
-Wswitch-enum, perform switch checks.
Fix PR c/5044.
2002-03-26 Richard Earnshaw <rearnsha@arm.com>
2002-03-26 Richard Earnshaw <rearnsha@arm.com>
* arm.md (reload_mulsi3, reload_mulsi_compare0, reload_muladdsi)
* arm.md (reload_mulsi3, reload_mulsi_compare0, reload_muladdsi)
...
...
gcc/doc/invoke.texi
View file @
173028e5
...
@@ -228,8 +228,8 @@ in the following sections.
...
@@ -228,8 +228,8 @@ in the following sections.
-
Wno
-
import
-
Wpacked
-
Wpadded
@
gol
-
Wno
-
import
-
Wpacked
-
Wpadded
@
gol
-
Wparentheses
-
Wpointer
-
arith
-
Wredundant
-
decls
@
gol
-
Wparentheses
-
Wpointer
-
arith
-
Wredundant
-
decls
@
gol
-
Wreturn
-
type
-
Wsequence
-
point
-
Wshadow
@
gol
-
Wreturn
-
type
-
Wsequence
-
point
-
Wshadow
@
gol
-
Wsign
-
compare
-
Wswitch
-
Wswitch
-
default
-
Wsystem
-
headers
@
gol
-
Wsign
-
compare
-
Wswitch
-
Wswitch
-
default
-
Wswitch
-
enum
@
gol
-
Wtrigraphs
-
Wundef
-
Wuninitialized
@
gol
-
W
system
-
headers
-
W
trigraphs
-
Wundef
-
Wuninitialized
@
gol
-
Wunknown
-
pragmas
-
Wunreachable
-
code
@
gol
-
Wunknown
-
pragmas
-
Wunreachable
-
code
@
gol
-
Wunused
-
Wunused
-
function
-
Wunused
-
label
-
Wunused
-
parameter
@
gol
-
Wunused
-
Wunused
-
function
-
Wunused
-
label
-
Wunused
-
parameter
@
gol
-
Wunused
-
value
-
Wunused
-
variable
-
Wwrite
-
strings
}
-
Wunused
-
value
-
Wunused
-
variable
-
Wwrite
-
strings
}
...
@@ -2039,6 +2039,13 @@ provoke warnings when this option is used.
...
@@ -2039,6 +2039,13 @@ provoke warnings when this option is used.
Warn
whenever
a
@
code
{
switch
}
statement
does
not
have
a
@
code
{
default
}
Warn
whenever
a
@
code
{
switch
}
statement
does
not
have
a
@
code
{
default
}
case
.
case
.
@
item
-
Wswitch
-
enum
@
opindex
Wswitch
-
enum
Warn
whenever
a
@
code
{
switch
}
statement
has
an
index
of
enumeral
type
and
lacks
a
@
code
{
case
}
for
one
or
more
of
the
named
codes
of
that
enumeration
.
@
code
{
case
}
labels
outside
the
enumeration
range
also
provoke
warnings
when
this
option
is
used
.
@
item
-
Wtrigraphs
@
item
-
Wtrigraphs
@
opindex
Wtrigraphs
@
opindex
Wtrigraphs
Warn
if
any
trigraphs
are
encountered
that
might
change
the
meaning
of
Warn
if
any
trigraphs
are
encountered
that
might
change
the
meaning
of
...
...
gcc/f/ChangeLog
View file @
173028e5
Tue
Mar
26
10
:
30
:
05
2002
Andrew
Cagney
<
ac131313
@redhat
.
com
>
*
invoke
.
texi
(
Warning
Options
)
:
Mention
-
Wswitch
-
enum
.
Fix
PR
c
/
5044
.
Tue
Mar
26
07
:
30
:
51
2002
Neil
Booth
<
neil
@daikokuya
.
demon
.
co
.
uk
>
Tue
Mar
26
07
:
30
:
51
2002
Neil
Booth
<
neil
@daikokuya
.
demon
.
co
.
uk
>
*
com
.
c
(
LANG_HOOKS_MARK_TREE
)
:
Redefine
.
*
com
.
c
(
LANG_HOOKS_MARK_TREE
)
:
Redefine
.
...
...
gcc/f/invoke.texi
View file @
173028e5
...
@@ -1359,6 +1359,9 @@ Some of these have no effect when compiling programs written in Fortran:
...
@@ -1359,6 +1359,9 @@ Some of these have no effect when compiling programs written in Fortran:
@cindex
-
Wswitch
-
default
option
@cindex
-
Wswitch
-
default
option
@cindex
options
,
-
Wswitch
-
default
@cindex
options
,
-
Wswitch
-
default
@item
-
Wswitch
-
default
@item
-
Wswitch
-
default
@cindex
-
Wswitch
-
enum
option
@cindex
options
,
-
Wswitch
-
enum
@item
-
Wswitch
-
enum
@cindex
-
Wtraditional
option
@cindex
-
Wtraditional
option
@cindex
options
,
-
Wtraditional
@cindex
options
,
-
Wtraditional
@item
-
Wtraditional
@item
-
Wtraditional
...
...
gcc/flags.h
View file @
173028e5
...
@@ -135,6 +135,11 @@ extern int warn_switch;
...
@@ -135,6 +135,11 @@ extern int warn_switch;
extern
int
warn_switch_default
;
extern
int
warn_switch_default
;
/* Warn if a switch on an enum fails to have a case for every enum
value (regardless of the presence or otherwise of a default case). */
extern
int
warn_switch_enum
;
/* Nonzero means warn about function definitions that default the return type
/* Nonzero means warn about function definitions that default the return type
or that use a null return and have a return-type other than void. */
or that use a null return and have a return-type other than void. */
...
...
gcc/stmt.c
View file @
173028e5
...
@@ -5280,10 +5280,10 @@ expand_end_case_type (orig_index, orig_type)
...
@@ -5280,10 +5280,10 @@ expand_end_case_type (orig_index, orig_type)
{
{
/* If the switch expression was an enumerated type, check that
/* If the switch expression was an enumerated type, check that
exactly all enumeration literals are covered by the cases.
exactly all enumeration literals are covered by the cases.
The check is made -Wswitch was specified and there is no
The check is made
when
-Wswitch was specified and there is no
default case. */
default case
, or when -Wswitch-enum was specified
. */
if
(((
warn_switch
&&
!
thiscase
->
data
.
case_stmt
.
default_label
)
if
((
warn_switch
&&
!
thiscase
->
data
.
case_stmt
.
default_label
)
||
warn_switch_enum
)
&&
TREE_CODE
(
orig_type
)
==
ENUMERAL_TYPE
&&
TREE_CODE
(
orig_type
)
==
ENUMERAL_TYPE
&&
TREE_CODE
(
index_expr
)
!=
INTEGER_CST
)
&&
TREE_CODE
(
index_expr
)
!=
INTEGER_CST
)
check_for_full_enumeration_handling
(
orig_type
);
check_for_full_enumeration_handling
(
orig_type
);
...
...
gcc/testsuite/ChangeLog
View file @
173028e5
2002-03-26 Andrew Cagney <ac131313@redhat.com>
* gcc.dg/Wswitch-enum.c: New test.
Fix PR c/5044.
2002-03-26 Richard Henderson <rth@redhat.com>
2002-03-26 Richard Henderson <rth@redhat.com>
* gcc.c-torture/execute/20020307-2.c (main): Pass a variable sized
* gcc.c-torture/execute/20020307-2.c (main): Pass a variable sized
...
...
gcc/testsuite/gcc.dg/Wswitch-enum.c
0 → 100644
View file @
173028e5
/* PR c/5044 */
/* { dg-do compile } */
/* { dg-options "-Wswitch-enum" } */
enum
e
{
e1
,
e2
};
int
foo
(
int
i
,
int
j
,
enum
e
ei
,
enum
e
ej
,
enum
e
ek
,
enum
e
el
,
enum
e
em
,
enum
e
en
,
enum
e
eo
,
enum
e
ep
)
{
switch
(
i
)
{
case
1
:
return
1
;
case
2
:
return
2
;
}
switch
(
j
)
{
case
3
:
return
4
;
case
4
:
return
3
;
default:
break
;
}
switch
(
ei
)
{
/* { dg-warning "enumeration value `e1' not handled in switch" "enum e1" } */
}
/* { dg-warning "enumeration value `e2' not handled in switch" "enum e2" { target *-*-* } 23 } */
switch
(
ej
)
{
/* { dg-warning "enumeration value `e1' not handled in switch" "enum e1" { target *-*-* } 28 } */
default:
break
;
}
/* { dg-warning "enumeration value `e2' not handled in switch" "enum e2" } */
switch
(
ek
)
{
case
e1
:
return
1
;
}
/* { dg-warning "enumeration value `e2' not handled in switch" "enum e2" } */
switch
(
el
)
{
case
e1
:
return
1
;
default:
break
;
}
/* { dg-warning "enumeration value `e2' not handled in switch" "enum e2" } */
switch
(
em
)
{
case
e1
:
return
1
;
case
e2
:
return
2
;
}
switch
(
en
)
{
case
e1
:
return
1
;
case
e2
:
return
2
;
default:
break
;
}
switch
(
eo
)
{
case
e1
:
return
1
;
case
e2
:
return
2
;
case
3
:
return
3
;
}
/* { dg-warning "case value `3' not in enumerated type `e'" "excess 3" } */
switch
(
ep
)
{
case
e1
:
return
1
;
case
e2
:
return
2
;
case
3
:
return
3
;
default:
break
;
}
/* { dg-warning "case value `3' not in enumerated type `e'" "excess 3" } */
return
0
;
}
gcc/toplev.c
View file @
173028e5
...
@@ -1401,6 +1401,11 @@ int warn_switch;
...
@@ -1401,6 +1401,11 @@ int warn_switch;
int
warn_switch_default
;
int
warn_switch_default
;
/* Warn if a switch on an enum fails to have a case for every enum
value (regardless of the presence or otherwise of a default case). */
int
warn_switch_enum
;
/* Nonzero means warn about function definitions that default the return type
/* Nonzero means warn about function definitions that default the return type
or that use a null return and have a return-type other than void. */
or that use a null return and have a return-type other than void. */
...
@@ -1473,6 +1478,8 @@ static const lang_independent_options W_options[] =
...
@@ -1473,6 +1478,8 @@ static const lang_independent_options W_options[] =
N_
(
"Warn about enumerated switches, with no default, missing a case"
)
},
N_
(
"Warn about enumerated switches, with no default, missing a case"
)
},
{
"switch-default"
,
&
warn_switch_default
,
1
,
{
"switch-default"
,
&
warn_switch_default
,
1
,
N_
(
"Warn about enumerated switches missing a default case"
)
},
N_
(
"Warn about enumerated switches missing a default case"
)
},
{
"switch-enum"
,
&
warn_switch_enum
,
1
,
N_
(
"Warn about all enumerated switches missing a specific case"
)
},
{
"aggregate-return"
,
&
warn_aggregate_return
,
1
,
{
"aggregate-return"
,
&
warn_aggregate_return
,
1
,
N_
(
"Warn about returning structures, unions or arrays"
)
},
N_
(
"Warn about returning structures, unions or arrays"
)
},
{
"cast-align"
,
&
warn_cast_align
,
1
,
{
"cast-align"
,
&
warn_cast_align
,
1
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment