diff options
author | Paolo Carlini <paolo@gcc.gnu.org> | 2017-10-24 19:01:03 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2017-10-24 19:01:03 +0000 |
commit | ff1ff960f5039cf1d2970bfe2ba965d1b994caf1 (patch) | |
tree | d7532f5e24aa854260ecf9ab34990aa58a76a622 /gcc | |
parent | f9f43fb3a83af7dc6b2f89d6691ccd33b0b90196 (diff) | |
download | gcc-ff1ff960f5039cf1d2970bfe2ba965d1b994caf1.zip gcc-ff1ff960f5039cf1d2970bfe2ba965d1b994caf1.tar.gz gcc-ff1ff960f5039cf1d2970bfe2ba965d1b994caf1.tar.bz2 |
re PR c++/82466 (Missing warning for re-declaration of built-in function as variable)
2017-10-24 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/82466
* doc/invoke.texi ([Wbuiltin-declaration-mismatch]): Extend
description.
/cp
2017-10-24 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/82466
* decl.c (duplicate_decls): Warn for built-in functions declared as
non-function, use OPT_Wbuiltin_declaration_mismatch.
* decl.c (duplicate_decls): Avoid redundant '+' in warning_at.
/c
2017-10-24 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/82466
* c-decl.c (diagnose_mismatched_decls): Use
OPT_Wbuiltin_declaration_mismatch.
/testsuite
2017-10-24 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/82466
* c-c++-common/Wbuiltin-declaration-mismatch-1.c: New.
* c-c++-common/Wno-builtin-declaration-mismatch-1.c: Likewise.
* g++.dg/warn/Wbuiltin_declaration_mismatch-1.C: Likewise.
* g++.dg/parse/builtin2.C: Adjust.
* g++.old-deja/g++.mike/p811.C: Likewise.
From-SVN: r254057
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 3 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/decl.c | 12 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/Wbuiltin-declaration-mismatch-1.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/Wno-builtin-declaration-mismatch-1.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/builtin2.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wbuiltin_declaration_mismatch-1.C | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.mike/p811.C | 2 |
12 files changed, 63 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e0ef3ed..a27df40 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-10-24 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/82466 + * doc/invoke.texi ([Wbuiltin-declaration-mismatch]): Extend + description. + 2017-10-24 Wilco Dijkstra <wdijkstr@arm.com> PR rtl-optimization/82396 @@ -55,7 +61,7 @@ * tree-outof-ssa.h (always_initialized_rtx_for_ssa_name_p): Delete. * expr.c (expand_expr_real_1) <expand_decl_rtl>: Revert latest change. * loop-iv.c (iv_get_reaching_def): Likewise. - * cfgexpand.c (expand_one_ssa_partition): Initialize the RTX if the + * cfgexpand.c (expand_one_ssa_partition): Initialize the RTX if the variable is promoted and the partition contains undefined values. 2017-10-23 Sandra Loosemore <sandra@codesourcery.com> @@ -76,7 +82,7 @@ (nios2_symbolic_constant_allowed): New. (nios2_symbolic_constant_p): New. (nios2_plus_symbolic_constant_p): New. - (nios2_valid_addr_expr_p): Recognize addresses involving + (nios2_valid_addr_expr_p): Recognize addresses involving symbolic constants. (nios2_legitimate_address_p): Likewise, also LO_SUM. (nios2_symbolic_memory_operand_p): New. @@ -157,7 +163,7 @@ * i386.h (processor_costs): Remove sse_move; add xmm_move, ymm_move and zmm_move. Increase size of sse load and store tables; add unaligned load and store tables; add ssemmx_to_integer. - * x86-tune-costs.h: Update all entries according to real + * x86-tune-costs.h: Update all entries according to real move latencies from Agner Fog's manual and chip documentation. 2017-10-23 Jakub Jelinek <jakub@redhat.com> diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 1f697f1..c260f62 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2017-10-24 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/82466 + * c-decl.c (diagnose_mismatched_decls): Use + OPT_Wbuiltin_declaration_mismatch. + 2017-10-12 David Malcolm <dmalcolm@redhat.com> * c-parser.c (c_parser_require): Add "type_is_unique" param and diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 26b34ab..5c472e6 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -1837,7 +1837,8 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, locate_old_decl (olddecl); } else if (TREE_PUBLIC (newdecl)) - warning (0, "built-in function %q+D declared as non-function", + warning (OPT_Wbuiltin_declaration_mismatch, + "built-in function %q+D declared as non-function", newdecl); else warning (OPT_Wshadow, "declaration of %q+D shadows " diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e24a194..8c587a3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,13 @@ 2017-10-24 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/82466 + * decl.c (duplicate_decls): Warn for built-in functions declared as + non-function, use OPT_Wbuiltin_declaration_mismatch. + + * decl.c (duplicate_decls): Avoid redundant '+' in warning_at. + +2017-10-24 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/80991 * pt.c (value_dependent_expression_p, [TRAIT_EXPR]): Handle a TREE_LIST as TRAIT_EXPR_TYPE2. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index a3cc80c..bb48099 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1431,7 +1431,15 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) /* Avoid warnings redeclaring built-ins which have not been explicitly declared. */ if (DECL_ANTICIPATED (olddecl)) - return NULL_TREE; + { + if (TREE_PUBLIC (newdecl) + && CP_DECL_CONTEXT (newdecl) == global_namespace) + warning_at (DECL_SOURCE_LOCATION (newdecl), + OPT_Wbuiltin_declaration_mismatch, + "built-in function %qD declared as non-function", + newdecl); + return NULL_TREE; + } /* If you declare a built-in or predefined function name as static, the old definition is overridden, but optionally warn this was a @@ -1522,7 +1530,7 @@ next_arg:; warning_at (DECL_SOURCE_LOCATION (newdecl), OPT_Wbuiltin_declaration_mismatch, - "declaration of %q+#D conflicts with built-in " + "declaration of %q#D conflicts with built-in " "declaration %q#D", newdecl, olddecl); } else if ((DECL_EXTERN_C_P (newdecl) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 3a87956..71b2445 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -6320,7 +6320,8 @@ attributes. @item -Wno-builtin-declaration-mismatch @opindex Wno-builtin-declaration-mismatch @opindex Wbuiltin-declaration-mismatch -Warn if a built-in function is declared with the wrong signature. +Warn if a built-in function is declared with the wrong signature or +as non-function. This warning is enabled by default. @item -Wno-builtin-macro-redefined diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index edf21e9..7801c03 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,14 @@ 2017-10-24 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/82466 + * c-c++-common/Wbuiltin-declaration-mismatch-1.c: New. + * c-c++-common/Wno-builtin-declaration-mismatch-1.c: Likewise. + * g++.dg/warn/Wbuiltin_declaration_mismatch-1.C: Likewise. + * g++.dg/parse/builtin2.C: Adjust. + * g++.old-deja/g++.mike/p811.C: Likewise. + +2017-10-24 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/80991 * g++.dg/ext/is_trivially_constructible5.C: New. diff --git a/gcc/testsuite/c-c++-common/Wbuiltin-declaration-mismatch-1.c b/gcc/testsuite/c-c++-common/Wbuiltin-declaration-mismatch-1.c new file mode 100644 index 0000000..63343b8 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wbuiltin-declaration-mismatch-1.c @@ -0,0 +1,4 @@ +/* PR c++/82466 */ +/* { dg-options "-Wbuiltin-declaration-mismatch" } */ + +int printf; /* { dg-warning "declared as non-function" } */ diff --git a/gcc/testsuite/c-c++-common/Wno-builtin-declaration-mismatch-1.c b/gcc/testsuite/c-c++-common/Wno-builtin-declaration-mismatch-1.c new file mode 100644 index 0000000..6409412 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wno-builtin-declaration-mismatch-1.c @@ -0,0 +1,4 @@ +/* PR c++/82466 */ +/* { dg-options "-Wno-builtin-declaration-mismatch" } */ + +int printf; diff --git a/gcc/testsuite/g++.dg/parse/builtin2.C b/gcc/testsuite/g++.dg/parse/builtin2.C index c524ea6..daa80bb 100644 --- a/gcc/testsuite/g++.dg/parse/builtin2.C +++ b/gcc/testsuite/g++.dg/parse/builtin2.C @@ -1,5 +1,5 @@ // PR c++/14432 -// { dg-options "" } +// { dg-options "-Wno-builtin-declaration-mismatch" } struct Y {}; Y y1; diff --git a/gcc/testsuite/g++.dg/warn/Wbuiltin_declaration_mismatch-1.C b/gcc/testsuite/g++.dg/warn/Wbuiltin_declaration_mismatch-1.C new file mode 100644 index 0000000..713073c --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wbuiltin_declaration_mismatch-1.C @@ -0,0 +1,7 @@ +// PR c++/82466 +// { dg-options "-Wbuiltin-declaration-mismatch" } + +namespace N +{ + int printf; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p811.C b/gcc/testsuite/g++.old-deja/g++.mike/p811.C index 5c8260a..2ca04ab 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/p811.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/p811.C @@ -1,5 +1,5 @@ // { dg-do assemble } -// { dg-options "" } +// { dg-options "-Wno-builtin-declaration-mismatch" } // This test case caused the compiler to abort at one point in time. // prms-id: 811 |