aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c99-complex-1.c
diff options
context:
space:
mode:
authorJoseph Myers <jsm28@cam.ac.uk>2000-09-17 20:39:56 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2000-09-17 20:39:56 +0100
commit60e9d01cf742140d4d56eb8aaf7eced14a923141 (patch)
tree334934f9502cc4e6f33fbd5069958392abed651a /gcc/testsuite/gcc.dg/c99-complex-1.c
parentbc5006c72549c530c630f8a749612ea5ec2bb9e7 (diff)
downloadgcc-60e9d01cf742140d4d56eb8aaf7eced14a923141.zip
gcc-60e9d01cf742140d4d56eb8aaf7eced14a923141.tar.gz
gcc-60e9d01cf742140d4d56eb8aaf7eced14a923141.tar.bz2
c-decl.c (grokdeclarator): Don't give a warning about defaulting to int for plain complex which defaults...
* c-decl.c (grokdeclarator): Don't give a warning about defaulting to int for plain complex which defaults to complex double. Do warn about defaulting to complex double if pedantic. Warn about complex integer types if pedantic. Warn about complex types if pedantic and not in C99 mode. * c-typeck.c (build_unary_op): If pedantic, warn about use of ~ for complex conjugation. testsuite: * gcc.dg/c90-complex-1.c, gcc.dg/c99-complex-1.c: New tests. From-SVN: r36478
Diffstat (limited to 'gcc/testsuite/gcc.dg/c99-complex-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/c99-complex-1.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/c99-complex-1.c b/gcc/testsuite/gcc.dg/c99-complex-1.c
new file mode 100644
index 0000000..2e1ba7d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-complex-1.c
@@ -0,0 +1,33 @@
+/* Test for _Complex: in C99 only. A few basic tests. */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+/* Test _Complex allowed on floating types. */
+
+float _Complex a;
+_Complex float b;
+double _Complex c;
+_Complex double d;
+long double _Complex e;
+_Complex long double f;
+
+/* Plain `_Complex' for complex double is a GNU extension. */
+_Complex g; /* { dg-bogus "warning" "warning in place of error" } */
+/* { dg-error "plain" "plain _Complex" { target *-*-* } 16 } */
+
+/* Complex integer types are GNU extensions. */
+_Complex int h; /* { dg-bogus "warning" "warning in place of error" } */
+/* { dg-error "complex integer" "_Complex int" { target *-*-* } 20 } */
+_Complex long i; /* { dg-bogus "warning" "warning in place of error" } */
+/* { dg-error "complex integer" "_Complex long" { target *-*-* } 22 } */
+
+/* Use of ~ for complex conjugation is a GNU extension, but a constraint
+ violation (6.5.3.3p1) in C99.
+*/
+_Complex double
+foo (_Complex double z)
+{
+ return ~z; /* { dg-bogus "warning" "warning in place of error" } */
+ /* { dg-error "complex conj" "~ for conjugation" { target *-*-* } 31 } */
+}