mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-19 03:40:26 +08:00
re PR c/61534 (Wlogical-op should not warn when either operand comes from macro expansion)
PR c/61534 * input.h (from_macro_expansion_at): Define. * c-common.c (warn_logical_operator): Bail if either operand comes from a macro expansion. * c-c++-common/pr61534-1.c: New test. From-SVN: r222406
This commit is contained in:
parent
841e98017e
commit
b878781346
@ -1,3 +1,8 @@
|
||||
2015-04-24 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c/61534
|
||||
* input.h (from_macro_expansion_at): Define.
|
||||
|
||||
2015-04-24 Thomas Preud'homme <thomas.preudhomme@arm.com>
|
||||
|
||||
* config/arm/unknown-elf.h (ASM_OUTPUT_ALIGNED_DECL_LOCAL): fix
|
||||
|
@ -1,3 +1,9 @@
|
||||
2015-04-24 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c/61534
|
||||
* c-common.c (warn_logical_operator): Bail if either operand comes
|
||||
from a macro expansion.
|
||||
|
||||
2015-04-10 Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
|
||||
|
||||
PR target/55143
|
||||
|
@ -1697,6 +1697,13 @@ warn_logical_operator (location_t location, enum tree_code code, tree type,
|
||||
&& code != TRUTH_OR_EXPR)
|
||||
return;
|
||||
|
||||
/* We don't want to warn if either operand comes from a macro
|
||||
expansion. ??? This doesn't work with e.g. NEGATE_EXPR yet;
|
||||
see PR61534. */
|
||||
if (from_macro_expansion_at (EXPR_LOCATION (op_left))
|
||||
|| from_macro_expansion_at (EXPR_LOCATION (op_right)))
|
||||
return;
|
||||
|
||||
/* Warn if &&/|| are being used in a context where it is
|
||||
likely that the bitwise equivalent was intended by the
|
||||
programmer. That is, an expression such as op && MASK
|
||||
|
@ -70,6 +70,10 @@ extern location_t input_location;
|
||||
header, but expanded in a non-system file. */
|
||||
#define in_system_header_at(LOC) \
|
||||
(linemap_location_in_system_header_p (line_table, LOC))
|
||||
/* Return a positive value if LOCATION is the locus of a token that
|
||||
comes from a macro expansion, O otherwise. */
|
||||
#define from_macro_expansion_at(LOC) \
|
||||
((linemap_location_from_macro_expansion_p (line_table, LOC)))
|
||||
|
||||
void dump_line_table_statistics (void);
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
2015-04-24 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c/61534
|
||||
* c-c++-common/pr61534-1.c: New test.
|
||||
|
||||
2015-04-24 Thomas Preud'homme <thomas.preudhomme@arm.com>
|
||||
Steven Bosscher <steven@gcc.gnu.org>
|
||||
|
||||
|
13
gcc/testsuite/c-c++-common/pr61534-1.c
Normal file
13
gcc/testsuite/c-c++-common/pr61534-1.c
Normal file
@ -0,0 +1,13 @@
|
||||
/* PR c/61534 */
|
||||
/* { dg-options "-Wlogical-op" } */
|
||||
|
||||
extern int xxx;
|
||||
#define XXX !xxx
|
||||
int
|
||||
test (void)
|
||||
{
|
||||
if (XXX && xxx) /* { dg-bogus "logical" } */
|
||||
return 4;
|
||||
else
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user