re PR c++/71973 (c++ handles built-in functions inconsistently)
authorBernd Edlinger <edlinger@gcc.gnu.org>
Mon, 21 Nov 2016 14:17:05 +0000 (14:17 +0000)
committerBernd Edlinger <edlinger@gcc.gnu.org>
Mon, 21 Nov 2016 14:17:05 +0000 (14:17 +0000)
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

25 files changed:
gcc/ChangeLog
gcc/builtin-types.def
gcc/builtins.def
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c.opt
gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/doc/invoke.texi
gcc/lto/ChangeLog
gcc/lto/lto-lang.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
gcc/testsuite/g++.dg/lto/pr68811_0.C
gcc/testsuite/g++.dg/pr71973-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/pr71973-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/pr71973-3.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.mike/p700.C
gcc/testsuite/g++.old-deja/g++.other/builtins10.C
gcc/testsuite/g++.old-deja/g++.other/realloc.C
gcc/tree-core.h
gcc/tree.c
gcc/tree.h

index 9fbecbd167a03b1ec413d87967302077fae1263c..53526b50154ed0291486ef2c76004aea290f6ccb 100644 (file)
@@ -1,3 +1,19 @@
+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.
+
 2016-11-21  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        PR tree-optimization/78413
index 468313c43e47a2cea416d9a67e535e6f3e684e0c..ecc6dcae8ff3cd7c55bafdbaaefa25505b1804b7 100644 (file)
@@ -103,6 +103,7 @@ DEF_PRIMITIVE_TYPE (BT_COMPLEX_LONGDOUBLE, complex_long_double_type_node)
 
 DEF_PRIMITIVE_TYPE (BT_PTR, ptr_type_node)
 DEF_PRIMITIVE_TYPE (BT_FILEPTR, fileptr_type_node)
+DEF_PRIMITIVE_TYPE (BT_CONST_TM_PTR, const_tm_ptr_type_node)
 DEF_PRIMITIVE_TYPE (BT_CONST_PTR, const_ptr_type_node)
 DEF_PRIMITIVE_TYPE (BT_VOLATILE_PTR,
                    build_pointer_type
@@ -146,7 +147,12 @@ DEF_PRIMITIVE_TYPE (BT_I16, builtin_type_for_size (BITS_PER_UNIT*16, 1))
 
 DEF_PRIMITIVE_TYPE (BT_BND, pointer_bounds_type_node)
 
-DEF_POINTER_TYPE (BT_PTR_CONST_STRING, BT_CONST_STRING)
+/* The C type `char * const *'.  */
+DEF_PRIMITIVE_TYPE (BT_PTR_CONST_STRING,
+                   build_pointer_type
+                    (build_qualified_type (string_type_node,
+                                           TYPE_QUAL_CONST)))
+
 DEF_POINTER_TYPE (BT_PTR_UINT, BT_UINT)
 DEF_POINTER_TYPE (BT_PTR_LONG, BT_LONG)
 DEF_POINTER_TYPE (BT_PTR_ULONG, BT_ULONG)
@@ -511,8 +517,8 @@ DEF_FUNCTION_TYPE_4 (BT_FN_SIZE_CONST_PTR_SIZE_SIZE_FILEPTR,
                     BT_SIZE, BT_CONST_PTR, BT_SIZE, BT_SIZE, BT_FILEPTR)
 DEF_FUNCTION_TYPE_4 (BT_FN_INT_STRING_SIZE_CONST_STRING_VALIST_ARG,
                BT_INT, BT_STRING, BT_SIZE, BT_CONST_STRING, BT_VALIST_ARG)
-DEF_FUNCTION_TYPE_4 (BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_PTR,
-               BT_SIZE, BT_STRING, BT_SIZE, BT_CONST_STRING, BT_CONST_PTR)
+DEF_FUNCTION_TYPE_4 (BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_TM_PTR,
+               BT_SIZE, BT_STRING, BT_SIZE, BT_CONST_STRING, BT_CONST_TM_PTR)
 DEF_FUNCTION_TYPE_4 (BT_FN_PTR_PTR_CONST_PTR_SIZE_SIZE,
                     BT_PTR, BT_PTR, BT_CONST_PTR, BT_SIZE, BT_SIZE)
 DEF_FUNCTION_TYPE_4 (BT_FN_PTR_PTR_INT_SIZE_SIZE,
index 219feebd3aebefbd079bf37cc801453cd1965e00..e2c582880c3cc8e1444995690d778ef22de7a012 100644 (file)
@@ -212,8 +212,8 @@ along with GCC; see the file COPYING3.  If not see
    functions are mapped to the actual implementation of the STM library. */
 #undef DEF_TM_BUILTIN
 #define DEF_TM_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
-  DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE,    \
-              true, true, true, ATTRS, false, flag_tm)
+  DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, BT_LAST, \
+              false, true, true, ATTRS, false, flag_tm)
 
 /* Builtin used by the implementation of libsanitizer. These
    functions are mapped to the actual implementation of the 
@@ -866,7 +866,7 @@ DEF_GCC_BUILTIN        (BUILT_IN_RETURN_ADDRESS, "return_address", BT_FN_PTR_UIN
 DEF_GCC_BUILTIN        (BUILT_IN_SAVEREGS, "saveregs", BT_FN_PTR_VAR, ATTR_NULL)
 DEF_GCC_BUILTIN        (BUILT_IN_SETJMP, "setjmp", BT_FN_INT_PTR, ATTR_RT_NOTHROW_LEAF_LIST)
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_STRFMON, "strfmon", BT_FN_SSIZE_STRING_SIZE_CONST_STRING_VAR, ATTR_FORMAT_STRFMON_NOTHROW_3_4)
-DEF_LIB_BUILTIN        (BUILT_IN_STRFTIME, "strftime", BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_PTR, ATTR_FORMAT_STRFTIME_NOTHROW_3_0)
+DEF_LIB_BUILTIN        (BUILT_IN_STRFTIME, "strftime", BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_TM_PTR, ATTR_FORMAT_STRFTIME_NOTHROW_3_0)
 DEF_GCC_BUILTIN        (BUILT_IN_TRAP, "trap", BT_FN_VOID, ATTR_NORETURN_NOTHROW_LEAF_LIST)
 DEF_GCC_BUILTIN        (BUILT_IN_UNREACHABLE, "unreachable", BT_FN_VOID, ATTR_CONST_NORETURN_NOTHROW_LEAF_LIST)
 DEF_GCC_BUILTIN        (BUILT_IN_UNWIND_INIT, "unwind_init", BT_FN_VOID, ATTR_NULL)
index acbe46154ec73ecec0754306322c997bea5e64cd..565ff823fc326597a767edef5fde1089c362fb2c 100644 (file)
@@ -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
index 3eb7f45aba4e80d143141401b9f71c85711f0ac5..cc18f295e00c3d2a377f8bce64e21fc3dc21009c 100644 (file)
@@ -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);
 
index 722d3800cf0b9303a6eebbb1d88818f4fc7710e9..10a87936107f50bc050abd47a2e0f7bb6105b76b 100644 (file)
@@ -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.
index 98bb93851d99f2898ee4a2df5311b54df6090a8d..dec9c9d44172f4ba2d37611db4653804ca5d416e 100644 (file)
@@ -1,6 +1,12 @@
+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.
+
 2016-11-18  Richard Sandiford  <richard.sandiford@arm.com>
-           Alan Hayward  <alan.hayward@arm.com>
-           David Sherwood  <david.sherwood@arm.com>
+           Alan Hayward  <alan.hayward@arm.com>
+           David Sherwood  <david.sherwood@arm.com>
 
        * c-decl.c (merge_decls): Use SET_DECL_MODE.
        (make_label, finish_struct): Likewise.
index 23581447a35069956012b0a4865b168f042f846a..db293fe60d14460cd5bbf97dc33c67e872938a6a 100644 (file)
@@ -1867,7 +1867,8 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
              /* If types don't match for a built-in, throw away the
                 built-in.  No point in calling locate_old_decl here, it
                 won't print anything.  */
-             warning (0, "conflicting types for built-in function %q+D",
+             warning (OPT_Wbuiltin_declaration_mismatch,
+                      "conflicting types for built-in function %q+D",
                       newdecl);
              return false;
            }
index ea07438cd2fdc27c1ef9e97cccb6379e8c7cc20d..f5475ae75b1ef02a1d31c823a972249a2b0f5b2d 100644 (file)
@@ -1,3 +1,11 @@
+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.
+
 2016-11-18  Jason Merrill  <jason@redhat.com>
 
        PR objc++/78418 - ICE in string tests on darwin
index 19550f3e16e55f8b882f15ea2017645934fc5564..6893eae084a08ec472556a396438900e2e15edc4 100644 (file)
@@ -1490,16 +1490,23 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
             explicitly declared.  */
          if (DECL_ANTICIPATED (olddecl))
            {
-             /* Deal with fileptr_type_node.  FILE type is not known
-                at the time we create the builtins.  */
              tree t1, t2;
 
+             /* A new declaration doesn't match a built-in one unless it
+                is also extern "C".  */
+             gcc_assert (DECL_IS_BUILTIN (olddecl));
+             gcc_assert (DECL_EXTERN_C_P (olddecl));
+             if (!DECL_EXTERN_C_P (newdecl))
+               return NULL_TREE;
+
              for (t1 = TYPE_ARG_TYPES (TREE_TYPE (newdecl)),
                   t2 = TYPE_ARG_TYPES (TREE_TYPE (olddecl));
                   t1 || t2;
                   t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
                if (!t1 || !t2)
                  break;
+               /* Deal with fileptr_type_node.  FILE type is not known
+                  at the time we create the builtins.  */
                else if (TREE_VALUE (t2) == fileptr_type_node)
                  {
                    tree t = TREE_VALUE (t1);
@@ -1511,6 +1518,27 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
                      {
                        tree oldargs = TYPE_ARG_TYPES (TREE_TYPE (olddecl));
 
+                       TYPE_ARG_TYPES (TREE_TYPE (olddecl))
+                         = TYPE_ARG_TYPES (TREE_TYPE (newdecl));
+                       types_match = decls_match (newdecl, olddecl);
+                       if (types_match)
+                         return duplicate_decls (newdecl, olddecl,
+                                                 newdecl_is_friend);
+                       TYPE_ARG_TYPES (TREE_TYPE (olddecl)) = oldargs;
+                     }
+                 }
+               /* Likewise for const struct tm*.  */
+               else if (TREE_VALUE (t2) == const_tm_ptr_type_node)
+                 {
+                   tree t = TREE_VALUE (t1);
+
+                   if (TYPE_PTR_P (t)
+                       && TYPE_IDENTIFIER (TREE_TYPE (t))
+                          == get_identifier ("tm")
+                       && compparms (TREE_CHAIN (t1), TREE_CHAIN (t2)))
+                     {
+                       tree oldargs = TYPE_ARG_TYPES (TREE_TYPE (olddecl));
+
                        TYPE_ARG_TYPES (TREE_TYPE (olddecl))
                          = TYPE_ARG_TYPES (TREE_TYPE (newdecl));
                        types_match = decls_match (newdecl, olddecl);
@@ -1522,6 +1550,11 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
                  }
                else if (! same_type_p (TREE_VALUE (t1), TREE_VALUE (t2)))
                  break;
+
+             warning_at (DECL_SOURCE_LOCATION (newdecl),
+                         OPT_Wbuiltin_declaration_mismatch,
+                         "declaration of %q+#D conflicts with built-in "
+                         "declaration %q#D", newdecl, olddecl);
            }
          else if ((DECL_EXTERN_C_P (newdecl)
                    && DECL_EXTERN_C_P (olddecl))
@@ -1531,7 +1564,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
              /* A near match; override the builtin.  */
 
              if (TREE_PUBLIC (newdecl))
-               warning_at (DECL_SOURCE_LOCATION (newdecl), 0,
+               warning_at (DECL_SOURCE_LOCATION (newdecl),
+                           OPT_Wbuiltin_declaration_mismatch,
                            "new declaration %q#D ambiguates built-in "
                            "declaration %q#D", newdecl, olddecl);
              else
@@ -2243,6 +2277,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
       TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
       TREE_READONLY (olddecl) = TREE_READONLY (newdecl);
       TREE_THIS_VOLATILE (olddecl) = TREE_THIS_VOLATILE (newdecl);
+      TREE_NOTHROW (olddecl) = TREE_NOTHROW (newdecl);
       TREE_SIDE_EFFECTS (olddecl) = TREE_SIDE_EFFECTS (newdecl);
     }
 
index e6c3dc267cff99e14b2299bc9d33e8fdeebe39d2..4dcaf10eb6aed9474fc030840c52fe06a8b0992b 100644 (file)
@@ -259,6 +259,7 @@ Objective-C and Objective-C++ Dialects}.
 -Walloca -Walloca-larger-than=@var{n} @gol
 -Wno-aggressive-loop-optimizations -Warray-bounds -Warray-bounds=@var{n} @gol
 -Wno-attributes -Wbool-compare -Wbool-operation @gol
+-Wno-builtin-declaration-mismatch @gol
 -Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat @gol
 -Wc++-compat -Wc++11-compat -Wc++14-compat -Wcast-align  -Wcast-qual  @gol
 -Wchar-subscripts -Wclobbered  -Wcomment -Wconditionally-supported  @gol
@@ -5925,6 +5926,12 @@ unrecognized attributes, function attributes applied to variables,
 etc.  This does not stop errors for incorrect use of supported
 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.
+This warning is enabled by default.
+
 @item -Wno-builtin-macro-redefined
 @opindex Wno-builtin-macro-redefined
 @opindex Wbuiltin-macro-redefined
index 447c9698c15add67f87694c96190c5e28482ee5f..732fc8a53ec2e8960ae179be2ddb9c4dfdaed386 100644 (file)
@@ -1,6 +1,11 @@
+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.
+
 2016-11-18  Richard Sandiford  <richard.sandiford@arm.com>
-           Alan Hayward  <alan.hayward@arm.com>
-           David Sherwood  <david.sherwood@arm.com>
+           Alan Hayward  <alan.hayward@arm.com>
+           David Sherwood  <david.sherwood@arm.com>
 
        * lto.c (offload_handle_link_vars): Use SET_DECL_MODE.
 
index 301cf2124a6a7a3f619219c3fc08e40d414d7181..a5f04ba8e7210e1d1fd41510a821ed11b9c0977f 100644 (file)
@@ -1266,6 +1266,10 @@ lto_init (void)
      always use the C definition here in lto1.  */
   gcc_assert (fileptr_type_node == ptr_type_node);
   gcc_assert (TYPE_MAIN_VARIANT (fileptr_type_node) == ptr_type_node);
+  /* Likewise for const struct tm*.  */
+  gcc_assert (const_tm_ptr_type_node == const_ptr_type_node);
+  gcc_assert (TYPE_MAIN_VARIANT (const_tm_ptr_type_node)
+             == const_ptr_type_node);
 
   ptrdiff_type_node = integer_type_node;
 
index 379c4f0490a28e7d24b9d5e19d215897756d3454..ef6e22cc71a812cfb21fd460c4aa27b7d036084d 100644 (file)
@@ -1,3 +1,16 @@
+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.
+
 2016-11-21  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        PR tree-optimization/78413
index c385ea701a2d6d251df4cc1025a16176f80beb77..f7fae78259c98b33bcf7fbab29fc2e8b26dbb8ab 100644 (file)
@@ -3,7 +3,6 @@
 
 // { dg-options "" }
 // { dg-do compile }
-// { dg-final { scan-assembler "call\[\t \]+\[^\$\]*?_Z4forkv" { target i?86-*-* x86_64-*-* } } }
 
 class frok
 {
@@ -14,5 +13,5 @@ class frok
 void
 foo ()
 {
-  fork ();
+  fork (); // { dg-error "was not declared in this scope" }
 }
index 2ae4eb06b5e62d4b6c16577c28cb66f43c0988b6..807c803b3473fda2f3911415a5bbde54500fef32 100644 (file)
@@ -1,5 +1,5 @@
 // { dg-lto-do link }
-/* { dg-lto-options "-O2  -w" } */
+/* { dg-lto-options { { -O2 -w } { -w } } } */
 // { dg-extra-ld-options "-r -nostdlib" }
 extern "C" char *strcpy(char *, const char *);
 char InitXPCOMGlue_lastSlash;
diff --git a/gcc/testsuite/g++.dg/pr71973-1.C b/gcc/testsuite/g++.dg/pr71973-1.C
new file mode 100644 (file)
index 0000000..7da0bb5
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-do compile }
+// { dg-options "-Wall -fdump-tree-eh" }
+
+extern "C"
+void fork () // { dg-warning "conflicts with built-in declaration" }
+__attribute__ ((__nothrow__));
+
+void foo () throw ()
+{
+  fork ();
+}
+
+// { dg-final { scan-tree-dump-not "eh_dispatch" "eh" } }
+// { dg-final { scan-tree-dump-not "resx" "eh" } }
diff --git a/gcc/testsuite/g++.dg/pr71973-2.C b/gcc/testsuite/g++.dg/pr71973-2.C
new file mode 100644 (file)
index 0000000..d8271b1
--- /dev/null
@@ -0,0 +1,18 @@
+// { dg-do compile }
+// { dg-options "-Wall -fdump-tree-eh" }
+
+typedef __SIZE_TYPE__ size_t;
+struct tm;
+
+extern "C"
+size_t strftime (char*, size_t, const char*, const struct tm*)
+__attribute__ ((__nothrow__));
+
+void foo () throw ()
+{
+  strftime (0,0,0,0); // { dg-warning "null argument where non-null required" }
+  // { dg-warning "too many arguments for format" "" { target *-*-* } .-1 }
+}
+
+// { dg-final { scan-tree-dump-not "eh_dispatch" "eh" } }
+// { dg-final { scan-tree-dump-not "resx" "eh" } }
diff --git a/gcc/testsuite/g++.dg/pr71973-3.C b/gcc/testsuite/g++.dg/pr71973-3.C
new file mode 100644 (file)
index 0000000..12fd0dc
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-do compile }
+// { dg-options "-Wall -fdump-tree-eh" }
+
+extern "C"
+int execve (const char *__path, char *const __argv[], char *const __envp[])
+__attribute__ ((__nothrow__));
+
+void foo () throw ()
+{
+  execve (0,0,0);
+}
+
+// { dg-final { scan-tree-dump-not "eh_dispatch" "eh" } }
+// { dg-final { scan-tree-dump-not "resx" "eh" } }
index 531962197df77997ccb440af4e2e5af6c82c9f40..622477917751837c474bca7da5c489bb7a4593b5 100644 (file)
@@ -1,5 +1,5 @@
 // { dg-do assemble  }
-// { dg-options "-Wno-deprecated -Wno-register" }
+// { dg-options "-Wno-deprecated -Wno-register -Wno-builtin-declaration-mismatch" }
 // { dg-error "limited range of data type" "16-bit target" { target xstormy16-*-* } 0 }
 // prms-id: 700
 
index 07f74f8f6e53b95c8c77a6d70afef8b2fa3593d3..e5ba8bf6a725af17a184448b3023b5142375ef9a 100644 (file)
@@ -1,7 +1,8 @@
 // { dg-do assemble  }
-// Test that built-in functions don't warn when prototyped without arguments.
+// Test that built-in functions do warn when prototyped without arguments.
 // Origin: PR c++/9367
 // Copyright (C) 2003 Free Software Foundation.
 
-extern "C" int snprintf();
+extern "C" int snprintf(); // { dg-warning "conflicts with built-in declaration" "" { target c++11 } }
+extern "C" int printf(); // { dg-warning "conflicts with built-in declaration" }
 
index 3e50aa80490f12cb19452a348c8d5f46ac18191e..8b9c2c60887cbf0981ffdfecb26f181c288d03d8 100644 (file)
@@ -1,4 +1,5 @@
 // { dg-do assemble  }
+// { dg-options "-Wno-builtin-declaration-mismatch" }
 
 extern "C" void realloc();
 
index 3e3f31e272649a34f70d3d121b553062e859f458..a3d220df24670066e2e3255399ecda4f79fdc9c8 100644 (file)
@@ -618,6 +618,7 @@ enum tree_index {
   TI_VA_LIST_FPR_COUNTER_FIELD,
   TI_BOOLEAN_TYPE,
   TI_FILEPTR_TYPE,
+  TI_CONST_TM_PTR_TYPE,
   TI_POINTER_SIZED_TYPE,
 
   TI_POINTER_BOUNDS_TYPE,
index adf140fe94c919e77b1bff6163c38b860a88de11..a4c5b1b968dc75a234c717838425e4b8a3081291 100644 (file)
@@ -6006,6 +6006,7 @@ free_lang_data (void)
   /* Create gimple variants for common types.  */
   ptrdiff_type_node = integer_type_node;
   fileptr_type_node = ptr_type_node;
+  const_tm_ptr_type_node = const_ptr_type_node;
 
   /* Reset some langhooks.  Do not reset types_compatible_p, it may
      still be used indirectly via the get_alias_set langhook.  */
@@ -10332,6 +10333,7 @@ build_common_tree_nodes (bool signed_char)
   const_ptr_type_node
     = build_pointer_type (build_type_variant (void_type_node, 1, 0));
   fileptr_type_node = ptr_type_node;
+  const_tm_ptr_type_node = const_ptr_type_node;
 
   pointer_sized_int_node = build_nonstandard_integer_type (POINTER_SIZE, 1);
 
index b0b3f05570c323b4aa56b1eaf2a61fc5677943bf..b4ec3fd069084bc1182f3a8c516187ee813a46b7 100644 (file)
@@ -3672,6 +3672,8 @@ tree_operand_check_code (const_tree __t, enum tree_code __code, int __i,
 #define va_list_fpr_counter_field      global_trees[TI_VA_LIST_FPR_COUNTER_FIELD]
 /* The C type `FILE *'.  */
 #define fileptr_type_node              global_trees[TI_FILEPTR_TYPE]
+/* The C type `const struct tm *'.  */
+#define const_tm_ptr_type_node         global_trees[TI_CONST_TM_PTR_TYPE]
 #define pointer_sized_int_node         global_trees[TI_POINTER_SIZED_TYPE]
 
 #define boolean_type_node              global_trees[TI_BOOLEAN_TYPE]