diff options
author | Geoffrey Keating <geoffk@apple.com> | 2003-04-30 01:28:39 +0000 |
---|---|---|
committer | Geoffrey Keating <geoffk@gcc.gnu.org> | 2003-04-30 01:28:39 +0000 |
commit | a6fdc0868e26ea055cd17a14bf976a805b60d6ea (patch) | |
tree | d99f4d5e6ec477f7b575ba61ababac52e26042c6 | |
parent | 9c0631a756c7409907a9302e77531a94d9cd6263 (diff) | |
download | gcc-a6fdc0868e26ea055cd17a14bf976a805b60d6ea.zip gcc-a6fdc0868e26ea055cd17a14bf976a805b60d6ea.tar.gz gcc-a6fdc0868e26ea055cd17a14bf976a805b60d6ea.tar.bz2 |
c-typeck.c (function_types_compatible_p): Ignore incompatible 'volatile' qualifiers on a function's return type in GNU mode.
2003-04-29 Geoffrey Keating <geoffk@apple.com>
* c-typeck.c (function_types_compatible_p): Ignore incompatible
'volatile' qualifiers on a function's return type in GNU mode.
Index: testsuite/ChangeLog
2003-04-29 Geoffrey Keating <geoffk@apple.com>
* gcc.dg/noreturn-5.c: New file.
* gcc.dg/noreturn-6.c: New file.
From-SVN: r66281
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-typeck.c | 20 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/noreturn-5.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/noreturn-6.c | 4 |
5 files changed, 36 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index af70aed..3b4d998 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2003-04-29 Geoffrey Keating <geoffk@apple.com> + + * c-typeck.c (function_types_compatible_p): Ignore incompatible + 'volatile' qualifiers on a function's return type in GNU mode. + 2003-04-29 Aldy Hernandez <aldyh@redhat.com> * expr.c (emit_group_load): Dump parallels of simd types to diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 33bce26..cfa2d40 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -630,9 +630,23 @@ function_types_compatible_p (f1, f2) /* 1 if no need for warning yet, 2 if warning cause has been seen. */ int val = 1; int val1; - - if (!(TREE_TYPE (f1) == TREE_TYPE (f2) - || (val = comptypes (TREE_TYPE (f1), TREE_TYPE (f2))))) + tree ret1, ret2; + + ret1 = TREE_TYPE (f1); + ret2 = TREE_TYPE (f2); + + /* 'volatile' qualifiers on a function's return type mean the function + is noreturn. */ + if (pedantic && TYPE_VOLATILE (ret1) != TYPE_VOLATILE (ret2)) + pedwarn ("function return types not compatible due to `volatile'"); + if (TYPE_VOLATILE (ret1)) + ret1 = build_qualified_type (TYPE_MAIN_VARIANT (ret1), + TYPE_QUALS (ret1) & ~TYPE_QUAL_VOLATILE); + if (TYPE_VOLATILE (ret2)) + ret2 = build_qualified_type (TYPE_MAIN_VARIANT (ret2), + TYPE_QUALS (ret2) & ~TYPE_QUAL_VOLATILE); + val = comptypes (ret1, ret2); + if (val == 0) return 0; args1 = TYPE_ARG_TYPES (f1); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1460768..5a7ddce 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2003-04-29 Geoffrey Keating <geoffk@apple.com> + * gcc.dg/noreturn-5.c: New file. + * gcc.dg/noreturn-6.c: New file. + * gcc.c-torture/compile/inline-1.c: New file. 2003-04-29 Mark Mitchell <mark@codesourcery.com> diff --git a/gcc/testsuite/gcc.dg/noreturn-5.c b/gcc/testsuite/gcc.dg/noreturn-5.c new file mode 100644 index 0000000..07381a6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/noreturn-5.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ +/* Check that 'noreturn' and 'volatile extern' are compatible. + The testsuite uses -ansi -pedantic-errors by default, so this has + to override. */ +extern void xxx (int) __attribute__((noreturn)); +__volatile extern void xxx (int); diff --git a/gcc/testsuite/gcc.dg/noreturn-6.c b/gcc/testsuite/gcc.dg/noreturn-6.c new file mode 100644 index 0000000..eb1fd24 --- /dev/null +++ b/gcc/testsuite/gcc.dg/noreturn-6.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* Check for volatile behaviour. */ +extern int xxx (void); +volatile extern int xxx (void); /* { dg-error "not compatible" } */ |