aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-decl.c3
-rw-r--r--gcc/testsuite/ChangeLog10
-rw-r--r--gcc/testsuite/gcc.dg/declspec-13.c24
-rw-r--r--gcc/testsuite/gcc.dg/pr29467.c13
-rw-r--r--gcc/testsuite/gfortran.dg/bind_c_usage_24_c.c5
-rw-r--r--gcc/testsuite/gfortran.dg/c_f_pointer_logical_driver.c8
7 files changed, 56 insertions, 13 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index b10f6f7..e04a38d 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,5 +1,11 @@
2014-05-01 Marek Polacek <polacek@redhat.com>
+ PR c/29467
+ * c-decl.c (declspecs_add_type): Pedwarn if boolean types are used
+ in C89 mode.
+
+2014-05-01 Marek Polacek <polacek@redhat.com>
+
PR c/43245
* c-typeck.c (convert_for_assignment): Pass OPT_Wdiscarded_qualifiers
instead of 0 to WARN_FOR_QUALIFIERS.
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index e30876c..6e7c589 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -9564,6 +9564,9 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs,
}
return specs;
case RID_BOOL:
+ if (!flag_isoc99 && !in_system_header_at (loc))
+ pedwarn (loc, OPT_Wpedantic,
+ "ISO C90 does not support boolean types");
if (specs->long_p)
error_at (loc,
("both %<long%> and %<_Bool%> in "
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6190497..3be6253 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,15 @@
2014-05-01 Marek Polacek <polacek@redhat.com>
+ PR c/29467
+ * gcc.dg/pr29467.c: New test.
+ * gcc.dg/declspec-13.c: Renumber some dg-warnings. Add dg-warnings
+ about boolean types.
+ * gfortran.dg/bind_c_usage_24_c.c: Include <stdbool.h>. Change _Bool
+ to bool.
+ * gfortran.dg/c_f_pointer_logical_driver.c: Change _Bool to bool.
+
+2014-05-01 Marek Polacek <polacek@redhat.com>
+
PR c/43245
* gcc.dg/pr43245.c: New test.
diff --git a/gcc/testsuite/gcc.dg/declspec-13.c b/gcc/testsuite/gcc.dg/declspec-13.c
index a325c0d..3b4e315 100644
--- a/gcc/testsuite/gcc.dg/declspec-13.c
+++ b/gcc/testsuite/gcc.dg/declspec-13.c
@@ -36,43 +36,53 @@ long double long x3; /* { dg-error "both 'long long' and 'double' in declaration
short long x4; /* { dg-error "both 'long' and 'short' in declaration specifiers" } */
void long x5; /* { dg-error "both 'long' and 'void' in declaration specifiers" } */
_Bool long x6; /* { dg-error "both 'long' and '_Bool' in declaration specifiers" } */
+/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } 38 } */
char long x7; /* { dg-error "both 'long' and 'char' in declaration specifiers" } */
float long x8; /* { dg-error "both 'long' and 'float' in declaration specifiers" } */
long short x9; /* { dg-error "both 'long' and 'short' in declaration specifiers" } */
void short x10; /* { dg-error "both 'short' and 'void' in declaration specifiers" } */
_Bool short x11; /* { dg-error "both 'short' and '_Bool' in declaration specifiers" } */
+/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } 44 } */
char short x12; /* { dg-error "both 'short' and 'char' in declaration specifiers" } */
float short x13; /* { dg-error "both 'short' and 'float' in declaration specifiers" } */
double short x14; /* { dg-error "both 'short' and 'double' in declaration specifiers" } */
unsigned signed x15; /* { dg-error "both 'signed' and 'unsigned' in declaration specifiers" } */
void signed x16; /* { dg-error "both 'signed' and 'void' in declaration specifiers" } */
_Bool signed x17; /* { dg-error "both 'signed' and '_Bool' in declaration specifiers" } */
+/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } 51 } */
float signed x18; /* { dg-error "both 'signed' and 'float' in declaration specifiers" } */
double signed x19; /* { dg-error "both 'signed' and 'double' in declaration specifiers" } */
signed unsigned x20; /* { dg-error "both 'signed' and 'unsigned' in declaration specifiers" } */
void unsigned x21; /* { dg-error "both 'unsigned' and 'void' in declaration specifiers" } */
_Bool unsigned x22; /* { dg-error "both 'unsigned' and '_Bool' in declaration specifiers" } */
+/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } 57 } */
float unsigned x23; /* { dg-error "both 'unsigned' and 'float' in declaration specifiers" } */
double unsigned x24; /* { dg-error "both 'unsigned' and 'double' in declaration specifiers" } */
void _Complex x25; /* { dg-error "both 'complex' and 'void' in declaration specifiers" } */
-/* { dg-warning "ISO C90 does not support complex types" "C90" { target *-*-* } 57 } */
+/* { dg-warning "ISO C90 does not support complex types" "C90" { target *-*-* } 61 } */
_Bool _Complex x26; /* { dg-error "both 'complex' and '_Bool' in declaration specifiers" } */
-/* { dg-warning "ISO C90 does not support complex types" "C90" { target *-*-* } 59 } */
+/* { dg-warning "ISO C90 does not support complex types" "C90" { target *-*-* } 63 } */
+/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } 63 } */
long void x27; /* { dg-error "both 'long' and 'void' in declaration specifiers" } */
short void x28; /* { dg-error "both 'short' and 'void' in declaration specifiers" } */
signed void x29; /* { dg-error "both 'signed' and 'void' in declaration specifiers" } */
unsigned void x30; /* { dg-error "both 'unsigned' and 'void' in declaration specifiers" } */
_Complex void x31; /* { dg-error "both 'complex' and 'void' in declaration specifiers" } */
-/* { dg-warning "ISO C90 does not support complex types" "C90" { target *-*-* } 66 } */
-/* { dg-warning "ISO C does not support plain 'complex' meaning 'double complex'" "complex" { target *-*-* } 66 } */
+/* { dg-warning "ISO C90 does not support complex types" "C90" { target *-*-* } 71 } */
+/* { dg-warning "ISO C does not support plain 'complex' meaning 'double complex'" "complex" { target *-*-* } 71 } */
long _Bool x32; /* { dg-error "both 'long' and '_Bool' in declaration specifiers" } */
+/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } 74 } */
short _Bool x33; /* { dg-error "both 'short' and '_Bool' in declaration specifiers" } */
+/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } 76 } */
signed _Bool x34; /* { dg-error "both 'signed' and '_Bool' in declaration specifiers" } */
+/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } 78 } */
unsigned _Bool x35; /* { dg-error "both 'unsigned' and '_Bool' in declaration specifiers" } */
+/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } 80 } */
_Complex _Bool x36; /* { dg-error "both 'complex' and '_Bool' in declaration specifiers" } */
-/* { dg-warning "ISO C90 does not support complex types" "C90" { target *-*-* } 73 } */
-/* { dg-warning "ISO C does not support plain 'complex' meaning 'double complex'" "complex" { target *-*-* } 73 } */
+/* { dg-warning "ISO C90 does not support complex types" "C90" { target *-*-* } 82 } */
+/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } 82 } */
+/* { dg-warning "ISO C does not support plain 'complex' meaning 'double complex'" "complex" { target *-*-* } 82 } */
long char x37; /* { dg-error "both 'long' and 'char' in declaration specifiers" } */
short char x38; /* { dg-error "both 'short' and 'char' in declaration specifiers" } */
long float x39; /* { dg-error "both 'long' and 'float' in declaration specifiers" } */
@@ -80,7 +90,7 @@ short float x40; /* { dg-error "both 'short' and 'float' in declaration specifie
signed float x41; /* { dg-error "both 'signed' and 'float' in declaration specifiers" } */
unsigned float x42; /* { dg-error "both 'unsigned' and 'float' in declaration specifiers" } */
long long double x43; /* { dg-error "both 'long long' and 'double' in declaration specifiers" } */
-/* { dg-warning "ISO C90 does not support 'long long'" "C90" { target *-*-* } 82 } */
+/* { dg-warning "ISO C90 does not support 'long long'" "C90" { target *-*-* } 92 } */
short double x44; /* { dg-error "both 'short' and 'double' in declaration specifiers" } */
signed double x45; /* { dg-error "both 'signed' and 'double' in declaration specifiers" } */
unsigned double x46; /* { dg-error "both 'unsigned' and 'double' in declaration specifiers" } */
diff --git a/gcc/testsuite/gcc.dg/pr29467.c b/gcc/testsuite/gcc.dg/pr29467.c
new file mode 100644
index 0000000..eaf09c2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr29467.c
@@ -0,0 +1,13 @@
+/* PR c/29467 */
+/* { dg-do compile } */
+/* { dg-options "-std=c89 -Wpedantic" } */
+
+_Bool b; /* { dg-warning "ISO C90 does not support boolean types" } */
+typedef _Bool B; /* { dg-warning "ISO C90 does not support boolean types" } */
+static _Bool sb; /* { dg-warning "ISO C90 does not support boolean types" } */
+
+_Bool /* { dg-warning "ISO C90 does not support boolean types" } */
+foo (_Bool bp) /* { dg-warning "ISO C90 does not support boolean types" } */
+{
+ _Bool bl; /* { dg-warning "ISO C90 does not support boolean types" } */
+}
diff --git a/gcc/testsuite/gfortran.dg/bind_c_usage_24_c.c b/gcc/testsuite/gfortran.dg/bind_c_usage_24_c.c
index ffc90b7..65754f3 100644
--- a/gcc/testsuite/gfortran.dg/bind_c_usage_24_c.c
+++ b/gcc/testsuite/gfortran.dg/bind_c_usage_24_c.c
@@ -1,11 +1,12 @@
/* Compiled and linked by bind_c.f90. */
#include <stdlib.h>
+#include <stdbool.h>
-void subtest (_Bool, int *);
+void subtest (bool, int *);
void
-c_proc (_Bool present, int *val)
+c_proc (bool present, int *val)
{
int val2;
if (!present && val)
diff --git a/gcc/testsuite/gfortran.dg/c_f_pointer_logical_driver.c b/gcc/testsuite/gfortran.dg/c_f_pointer_logical_driver.c
index e3044c9..a05449d 100644
--- a/gcc/testsuite/gfortran.dg/c_f_pointer_logical_driver.c
+++ b/gcc/testsuite/gfortran.dg/c_f_pointer_logical_driver.c
@@ -4,13 +4,13 @@
#define NUM_ELEMS 10
-void test_scalar(_Bool *my_c_bool_ptr);
-void test_array(_Bool *my_bool_array, int num_elems);
+void test_scalar(bool *my_c_bool_ptr);
+void test_array(bool *my_bool_array, int num_elems);
int main(int argc, char **argv)
{
- _Bool my_bool = true;
- _Bool my_bool_array[NUM_ELEMS];
+ bool my_bool = true;
+ bool my_bool_array[NUM_ELEMS];
int i;
test_scalar(&my_bool);