Commit cdb88468 by Ian Lance Taylor Committed by Ian Lance Taylor

dwarf2.h (enum dwarf_location_atom): Add INTERNAL_DW_OP_tls_addr.

./:	* dwarf2.h (enum dwarf_location_atom): Add
	INTERNAL_DW_OP_tls_addr.
	* dwarf2out.c (INTERNAL_DW_OP_tls_addr): Don't #define.

	* c-common.c (c_do_switch_warnings): Don't exit early for -Wswitch
	with no default node.  Change warning with %H to warning_at.
	Don't clear warn_switch around case checking.
	* doc/invoke.texi (Warning Options): Clarify distinction between
	-Wswitch and -Wswitch-enum.
java/:
	* jcf-parse.c (handle_constant): Change local variable 'kind' to
	unsigned int.
testsuite/:
	* g++.dg/warn/Wswitch-3.C: New testcase.
	* gcc.dg/Wswitch.c: Adjust for -Wswitch change.
	* gcc.dg/Wswitch-enum-error.c: Likewise.
	* gcc.dg/Wswitch-error.c: Likewise.

From-SVN: r148270
parent 36b31e07
2009-06-07 Ian Lance Taylor <iant@google.com>
* dwarf2.h (enum dwarf_location_atom): Add
INTERNAL_DW_OP_tls_addr.
* dwarf2out.c (INTERNAL_DW_OP_tls_addr): Don't #define.
* c-common.c (c_do_switch_warnings): Don't exit early for -Wswitch
with no default node. Change warning with %H to warning_at.
Don't clear warn_switch around case checking.
* doc/invoke.texi (Warning Options): Clarify distinction between
-Wswitch and -Wswitch-enum.
2009-06-07 Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
* tree-pass.h (TODO_update_ssa_any): Document internal use only.
......
......@@ -5425,7 +5425,6 @@ c_do_switch_warnings (splay_tree cases, location_t switch_location,
splay_tree_node default_node;
splay_tree_node node;
tree chain;
int saved_warn_switch;
if (!warn_switch && !warn_switch_enum && !warn_switch_default)
return;
......@@ -5439,15 +5438,15 @@ c_do_switch_warnings (splay_tree cases, location_t switch_location,
if (!type || TREE_CODE (type) != ENUMERAL_TYPE)
return;
/* If the switch expression was an enumerated type, check that
exactly all enumeration literals are covered by the cases.
The check is made when -Wswitch was specified and there is no
default case, or when -Wswitch-enum was specified. */
if (!warn_switch_enum
&& !(warn_switch && !default_node))
/* From here on, we only care about -Wswitch and -Wswitch-enum. */
if (!warn_switch_enum && !warn_switch)
return;
/* Check the cases. Warn about case values which are not members of
the enumerated type. For -Wswitch-enum, or for -Wswitch when
there is no default case, check that exactly all enumeration
literals are covered by the cases. */
/* Clearing COND if it is not an integer constant simplifies
the tests inside the loop below. */
if (TREE_CODE (cond) != INTEGER_CST)
......@@ -5498,13 +5497,15 @@ c_do_switch_warnings (splay_tree cases, location_t switch_location,
continue;
/* If there is a default_node, the only relevant option is
Wswitch-enum. Otherwise, if both are enabled then we prefer
Wswitch-enum. Otherwise, if both are enabled then we prefer
to warn using -Wswitch because -Wswitch is enabled by -Wall
while -Wswitch-enum is explicit. */
warning ((default_node || !warn_switch)
? OPT_Wswitch_enum : OPT_Wswitch,
"%Henumeration value %qE not handled in switch",
&switch_location, TREE_PURPOSE (chain));
warning_at (switch_location,
(default_node || !warn_switch
? OPT_Wswitch_enum
: OPT_Wswitch),
"enumeration value %qE not handled in switch",
TREE_PURPOSE (chain));
}
/* Warn if there are case expressions that don't correspond to
......@@ -5516,16 +5517,7 @@ c_do_switch_warnings (splay_tree cases, location_t switch_location,
every disjoint case label, with CASE_LOW_SEEN and CASE_HIGH_SEEN
above. This scan also resets those fields. */
/* If there is a default_node, the only relevant option is
Wswitch-enum. Otherwise, if both are enabled then we prefer
to warn using -Wswitch because -Wswitch is enabled by -Wall
while -Wswitch-enum is explicit. */
saved_warn_switch = warn_switch;
if (default_node)
warn_switch = 0;
splay_tree_foreach (cases, match_case_to_enum, type);
warn_switch = saved_warn_switch;
}
/* Finish an expression taking the address of LABEL (an
......
......@@ -3174,7 +3174,8 @@ Warn whenever a @code{switch} statement has an index of enumerated type
and lacks a @code{case} for one or more of the named codes of that
enumeration. (The presence of a @code{default} label prevents this
warning.) @code{case} labels outside the enumeration range also
provoke warnings when this option is used.
provoke warnings when this option is used (even if there is a
@code{default} label).
This warning is enabled by @option{-Wall}.
@item -Wswitch-default
......@@ -3189,7 +3190,10 @@ case.
Warn whenever a @code{switch} statement has an index of enumerated 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.
provoke warnings when this option is used. The only difference
between @option{-Wswitch} and this option is that this option gives a
warning about an omitted enumeration code even if there is a
@code{default} label.
@item -Wsync-nand @r{(C and C++ only)}
@opindex Wsync-nand
......
......@@ -562,7 +562,13 @@ enum dwarf_location_atom
DW_OP_HP_fltconst8 = 0xe3,
DW_OP_HP_mod_range = 0xe4,
DW_OP_HP_unmod_range = 0xe5,
DW_OP_HP_tls = 0xe6
DW_OP_HP_tls = 0xe6,
/* Used internally in dwarf2out.c to distinguish DW_OP_addr with a
direct symbol relocation from DW_OP_addr with a dtp-relative
symbol relocation. */
INTERNAL_DW_OP_tls_addr = 0x103
};
/* Type encodings. */
......
......@@ -3758,11 +3758,6 @@ struct GTY(()) dwarf_file_data {
int emitted_number;
};
/* We need some way to distinguish DW_OP_addr with a direct symbol
relocation from DW_OP_addr with a dtp-relative symbol relocation. */
#define INTERNAL_DW_OP_tls_addr (0x100 + DW_OP_addr)
typedef struct dw_val_struct *dw_val_ref;
typedef struct die_struct *dw_die_ref;
typedef const struct die_struct *const_dw_die_ref;
......
2009-06-07 Ian Lance Taylor <iant@google.com>
* jcf-parse.c (handle_constant): Change local variable 'kind' to
unsigned int.
2009-06-01 Ian Lance Taylor <iant@google.com>
* jcf-io.c (find_class): Use CONST_CAST.
......
......@@ -498,7 +498,7 @@ handle_long_constant (JCF *jcf, CPool *cpool, enum cpool_tag kind,
static uint16
handle_constant (JCF *jcf, int index, enum cpool_tag purpose)
{
enum cpool_tag kind;
unsigned int kind;
CPool *cpool = cpool_for_class (output_class);
if (index == 0)
......@@ -507,7 +507,7 @@ handle_constant (JCF *jcf, int index, enum cpool_tag purpose)
if (! CPOOL_INDEX_IN_RANGE (&jcf->cpool, index))
error ("<constant pool index %d not in range>", index);
kind = (enum cpool_tag) JPOOL_TAG (jcf, index);
kind = JPOOL_TAG (jcf, index);
if ((kind & ~CONSTANT_ResolvedFlag) != purpose)
{
......@@ -555,12 +555,12 @@ handle_constant (JCF *jcf, int index, enum cpool_tag purpose)
break;
case CONSTANT_Long:
index = handle_long_constant (jcf, cpool, kind, index,
index = handle_long_constant (jcf, cpool, CONSTANT_Long, index,
WORDS_BIG_ENDIAN);
break;
case CONSTANT_Double:
index = handle_long_constant (jcf, cpool, kind, index,
index = handle_long_constant (jcf, cpool, CONSTANT_Double, index,
FLOAT_WORDS_BIG_ENDIAN);
break;
......
2009-06-07 Ian Lance Taylor <iant@google.com>
* g++.dg/warn/Wswitch-3.C: New testcase.
* gcc.dg/Wswitch.c: Adjust for -Wswitch change.
* gcc.dg/Wswitch-enum-error.c: Likewise.
* gcc.dg/Wswitch-error.c: Likewise.
2009-06-07 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/40008
......
/* { dg-do compile } */
/* { dg-options "-Wswitch" } */
enum E { A, B, C, D, E, F };
int
f1 (enum E e)
{
switch (e)
{
case A: return 1;
case B: return 2;
case C: return 3;
case D: return 4;
case E: return 5;
case F: return 6;
case 7: return 7; /* { dg-warning "not in enumerated type" } */
}
return 0;
}
int
f2 (enum E e)
{
switch (e)
{
case A: return 1;
case B: return 2;
case C: return 3;
case D: return 4;
case E: return 5;
case F: return 6;
case 7: return 7; /* { dg-warning "not in enumerated type" } */
default: return 8;
}
return 0;
}
......@@ -56,7 +56,7 @@ foo (int i, int j, enum e ei, enum e ej, enum e ek, enum e el,
{
case e1: return 1;
case e2: return 2;
case 3: return 3; /* { dg-error "case value '3' not in enumerated type 'enum e'" "excess 3" } */
case 3: return 3; /* { dg-warning "case value '3' not in enumerated type 'enum e'" "excess 3" } */
default: break;
}
return 0;
......
......@@ -56,7 +56,7 @@ foo (int i, int j, enum e ei, enum e ej, enum e ek, enum e el,
{
case e1: return 1;
case e2: return 2;
case 3: return 3; /* { dg-warning "case value '3' not in enumerated type 'enum e'" "excess 3" } */
case 3: return 3; /* { dg-error "case value '3' not in enumerated type 'enum e'" "excess 3" } */
default: break;
}
return 0;
......
......@@ -56,8 +56,8 @@ foo (int i, int j, enum e ei, enum e ej, enum e ek, enum e el,
{
case e1: return 1;
case e2: return 2;
case 3: return 3;
case 3: return 3; /* { dg-warning "case value '3' not in enumerated type 'enum e'" "excess 3" } */
default: break;
} /* Since there is a default, no warning about ``case 3'' */
}
return 0;
}
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