public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-7570] c: Revert C2x changes to function type compatibility
@ 2022-03-09 22:52 Joseph Myers
  0 siblings, 0 replies; only message in thread
From: Joseph Myers @ 2022-03-09 22:52 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4ea128d5c740e4e8c2e7b70de3a90435035eb863

commit r12-7570-g4ea128d5c740e4e8c2e7b70de3a90435035eb863
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Wed Mar 9 22:51:23 2022 +0000

    c: Revert C2x changes to function type compatibility
    
    In commit cc806126215c3f4dc187eff3bf923458d8cc6b4f, I implemented
    changes that C2x had made to compatibility of unprototyped and
    prototyped function types.
    
    C2x has since completely removed unprototyped function types, making
    () in a function declaration mean (void) as in C++.  While that change
    isn't appropriate at the current development stage for GCC 12, it does
    mean that it doesn't make sense for GCC 12 to have different rules for
    unprototyped functions in C2x mode than in other modes or previous and
    subsequent GCC versions.  Thus, revert the previous change to avoid it
    getting into a GCC release, and update the corresponding tests to
    expect the same behavior with -std=c2x as with -std=c11 (they will of
    course need to change again after implementing () as meaning (void)).
    
    Bootstrapped with no regressions for x86_64-pc-linux-gnu.
    
    gcc/c/
            * c-typeck.cc (function_types_compatible_p): Do not handle C2X
            differently from earlier standards for unprototyped function type
            compatibility.
    
    gcc/testsuite/
            * gcc.dg/c11-unproto-1.c, gcc.dg/c11-unproto-2.c: Update comments.
            * gcc.dg/c2x-unproto-1.c, gcc.dg/c2x-unproto-2.c: Expect same
            results as in C11 mode.  Update comments.

Diff:
---
 gcc/c/c-typeck.cc                    |  4 ++--
 gcc/testsuite/gcc.dg/c11-unproto-1.c |  7 ++++---
 gcc/testsuite/gcc.dg/c11-unproto-2.c |  7 ++++---
 gcc/testsuite/gcc.dg/c2x-unproto-1.c | 29 +++++++++++++++++------------
 gcc/testsuite/gcc.dg/c2x-unproto-2.c |  7 ++++---
 5 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index b37f3cfcd8b..54b0b0d369b 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -1693,7 +1693,7 @@ function_types_compatible_p (const_tree f1, const_tree f2,
 
   if (args1 == NULL_TREE)
     {
-      if (flag_isoc2x ? stdarg_p (f2) : !self_promoting_args_p (args2))
+      if (!self_promoting_args_p (args2))
 	return 0;
       /* If one of these types comes from a non-prototype fn definition,
 	 compare that with the other type's arglist.
@@ -1706,7 +1706,7 @@ function_types_compatible_p (const_tree f1, const_tree f2,
     }
   if (args2 == NULL_TREE)
     {
-      if (flag_isoc2x ? stdarg_p (f1) : !self_promoting_args_p (args1))
+      if (!self_promoting_args_p (args1))
 	return 0;
       if (TYPE_ACTUAL_ARG_TYPES (f2)
 	  && type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2),
diff --git a/gcc/testsuite/gcc.dg/c11-unproto-1.c b/gcc/testsuite/gcc.dg/c11-unproto-1.c
index ea9e807a68e..0949c7bc90c 100644
--- a/gcc/testsuite/gcc.dg/c11-unproto-1.c
+++ b/gcc/testsuite/gcc.dg/c11-unproto-1.c
@@ -1,6 +1,7 @@
-/* Test compatibility of unprototyped and prototyped function types (C2x makes
-   the case of types affected by default argument promotions compatible).  Test
-   valid-in-C2x usages are not accepted for C11.  */
+/* Test compatibility of unprototyped and prototyped function types (C2x made
+   the case of types affected by default argument promotions compatible, before
+   removing unprototyped functions completely).  Test affected usages are not
+   accepted for C11.  */
 /* { dg-do compile } */
 /* { dg-options "-std=c11 -pedantic-errors" } */
 
diff --git a/gcc/testsuite/gcc.dg/c11-unproto-2.c b/gcc/testsuite/gcc.dg/c11-unproto-2.c
index 0557ae3f5cb..06da935336e 100644
--- a/gcc/testsuite/gcc.dg/c11-unproto-2.c
+++ b/gcc/testsuite/gcc.dg/c11-unproto-2.c
@@ -1,6 +1,7 @@
-/* Test compatibility of unprototyped and prototyped function types (C2x makes
-   the case of types affected by default argument promotions compatible).  Test
-   invalid-in-C2x usages, in C11 mode.  */
+/* Test compatibility of unprototyped and prototyped function types (C2x made
+   the case of types affected by default argument promotions compatible, before
+   removing unprototyped functions completely).  Test always-invalid-in-C2x
+   usages, in C11 mode.  */
 /* { dg-do compile } */
 /* { dg-options "-std=c11 -pedantic-errors" } */
 
diff --git a/gcc/testsuite/gcc.dg/c2x-unproto-1.c b/gcc/testsuite/gcc.dg/c2x-unproto-1.c
index 45d68f2c292..aa87d78610e 100644
--- a/gcc/testsuite/gcc.dg/c2x-unproto-1.c
+++ b/gcc/testsuite/gcc.dg/c2x-unproto-1.c
@@ -1,20 +1,25 @@
-/* Test compatibility of unprototyped and prototyped function types (C2x makes
-   the case of types affected by default argument promotions compatible).  Test
-   valid-in-C2x usages.  */
+/* Test compatibility of unprototyped and prototyped function types (C2x made
+   the case of types affected by default argument promotions compatible, before
+   removing unprototyped functions completely).  Test affected usages are not
+   accepted for C2x.  */
 /* { dg-do compile } */
 /* { dg-options "-std=c2x -pedantic-errors" } */
 
-void f1 ();
-void f1 (float);
+void f1 (); /* { dg-message "previous declaration" } */
+void f1 (float); /* { dg-error "conflicting types" } */
+/* { dg-message "default promotion" "" { target *-*-* } .-1 } */
 
-void f2 (float);
-void f2 ();
+void f2 (float); /* { dg-message "previous declaration" } */
+void f2 (); /* { dg-error "conflicting types" } */
+/* { dg-message "default promotion" "" { target *-*-* } .-1 } */
 
-void f3 ();
-void f3 (char);
+void f3 (); /* { dg-message "previous declaration" } */
+void f3 (char); /* { dg-error "conflicting types" } */
+/* { dg-message "default promotion" "" { target *-*-* } .-1 } */
 
-void f4 (char);
-void f4 ();
+void f4 (char); /* { dg-message "previous declaration" } */
+void f4 (); /* { dg-error "conflicting types" } */
+/* { dg-message "default promotion" "" { target *-*-* } .-1 } */
 
 /* Built-in function case.  */
-float sqrtf ();
+float sqrtf (); /* { dg-warning "conflicting types for built-in function" } */
diff --git a/gcc/testsuite/gcc.dg/c2x-unproto-2.c b/gcc/testsuite/gcc.dg/c2x-unproto-2.c
index f826b7c3ac8..3d5ae9d8460 100644
--- a/gcc/testsuite/gcc.dg/c2x-unproto-2.c
+++ b/gcc/testsuite/gcc.dg/c2x-unproto-2.c
@@ -1,6 +1,7 @@
-/* Test compatibility of unprototyped and prototyped function types (C2x makes
-   the case of types affected by default argument promotions compatible).  Test
-   invalid-in-C2x usages.  */
+/* Test compatibility of unprototyped and prototyped function types (C2x made
+   the case of types affected by default argument promotions compatible, before
+   removing unprototyped functions completely).  Test always-invalid-in-C2x
+   usages, in C2X mode.  */
 /* { dg-do compile } */
 /* { dg-options "-std=c2x -pedantic-errors" } */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-09 22:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-09 22:52 [gcc r12-7570] c: Revert C2x changes to function type compatibility Joseph Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).