aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorBernd Edlinger <edlinger@gcc.gnu.org>2016-11-21 14:17:05 +0000
committerBernd Edlinger <edlinger@gcc.gnu.org>2016-11-21 14:17:05 +0000
commit48330c9355e32a41f18556fc0ebccdfe2cc51044 (patch)
tree2aa8fba617d40e3e606b3bdf3e74fb9eda06ff81 /gcc/c-family
parenteeeaf7199a10b61c188785e7a86cd3cdecba07c3 (diff)
downloadgcc-48330c9355e32a41f18556fc0ebccdfe2cc51044.zip
gcc-48330c9355e32a41f18556fc0ebccdfe2cc51044.tar.gz
gcc-48330c9355e32a41f18556fc0ebccdfe2cc51044.tar.bz2
re PR c++/71973 (c++ handles built-in functions inconsistently)
gcc: 2016-11-21 Bernd Edlinger <bernd.edlinger@hotmail.de> PR c++/71973 * doc/invoke.texi (-Wno-builtin-declaration-mismatch): Document the new default-enabled warning.. * builtin-types.def (BT_CONST_TM_PTR): New primitive type. (BT_PTR_CONST_STRING): Updated. (BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_PTR): Removed. (BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_TM_PTR): New function type. * builtins.def (DEF_TM_BUILTIN): Disable BOTH_P for TM builtins. (strftime): Update builtin function. * tree-core.h (TI_CONST_TM_PTR_TYPE): New enum value. * tree.h (const_tm_ptr_type_node): New type node. * tree.c (free_lang_data, build_common_tree_nodes): Initialize const_tm_ptr_type_node. c-family: 2016-11-21 Bernd Edlinger <bernd.edlinger@hotmail.de> PR c++/71973 * c.opt (-Wbuiltin-declaration-mismatch): New warning. * c-common.c (c_common_nodes_and_builtins): Initialize const_tm_ptr_type_node. c: 2016-11-21 Bernd Edlinger <bernd.edlinger@hotmail.de> PR c++/71973 * c-decl.c (diagnose_mismatched_decls): Use OPT_Wbuiltin_declaration_mismatch here too. cp: 2016-11-21 Bernd Edlinger <bernd.edlinger@hotmail.de> PR c++/71973 * decl.c (duplicate_decls): Warn when a built-in function is redefined. Don't overload builtin functions with C++ functions. Handle const_tm_ptr_type_node like file_ptr_node. Copy the TREE_NOTHROW flag unmodified to the old decl. lto: 2016-11-21 Bernd Edlinger <bernd.edlinger@hotmail.de> PR c++/71973 * lto-lang.c (lto_init): Assert const_tm_ptr_type_node is sane. testsuite: 2016-11-21 Bernd Edlinger <bernd.edlinger@hotmail.de> PR c++/71973 * g++.dg/pr71973-1.C: New test. * g++.dg/pr71973-2.C: New test. * g++.dg/pr71973-3.C: New test. * g++.dg/lto/pr68811_0.C: Add -w to first lto-options. * g++.dg/lookup/extern-c-redecl4.C: Adjust test expectations. * g++.old-deja/g++.mike/p700.C: Add -Wno-builtin-declaration-mismatch to dg-options. * g++.old-deja/g++.other/realloc.C: Likewise. * g++.old-deja/g++.other/builtins10.C: Adjust test expectations. From-SVN: r242662
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/ChangeLog7
-rw-r--r--gcc/c-family/c-common.c10
-rw-r--r--gcc/c-family/c.opt4
3 files changed, 18 insertions, 3 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index acbe461..565ff82 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,10 @@
+2016-11-21 Bernd Edlinger <bernd.edlinger@hotmail.de>
+
+ PR c++/71973
+ * c.opt (-Wbuiltin-declaration-mismatch): New warning.
+ * c-common.c (c_common_nodes_and_builtins): Initialize
+ const_tm_ptr_type_node.
+
2016-11-16 Marek Polacek <polacek@redhat.com>
PR c/78285
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 3eb7f45..cc18f29 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -4293,9 +4293,13 @@ c_common_nodes_and_builtins (void)
}
if (c_dialect_cxx ())
- /* For C++, make fileptr_type_node a distinct void * type until
- FILE type is defined. */
- fileptr_type_node = build_variant_type_copy (ptr_type_node);
+ {
+ /* For C++, make fileptr_type_node a distinct void * type until
+ FILE type is defined. */
+ fileptr_type_node = build_variant_type_copy (ptr_type_node);
+ /* Likewise for const struct tm*. */
+ const_tm_ptr_type_node = build_variant_type_copy (const_ptr_type_node);
+ }
record_builtin_type (RID_VOID, NULL, void_type_node);
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 722d380..10a8793 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -337,6 +337,10 @@ Wframe-address
C ObjC C++ ObjC++ Var(warn_frame_address) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
Warn when __builtin_frame_address or __builtin_return_address is used unsafely.
+Wbuiltin-declaration-mismatch
+C ObjC C++ ObjC++ Var(warn_builtin_declaraion_mismatch) Init(1) Warning
+Warn when a built-in function is declared with the wrong signature.
+
Wbuiltin-macro-redefined
C ObjC C++ ObjC++ CPP(warn_builtin_macro_redefined) CppReason(CPP_W_BUILTIN_MACRO_REDEFINED) Var(cpp_warn_builtin_macro_redefined) Init(1) Warning
Warn when a built-in preprocessor macro is undefined or redefined.