re PR c/29467 (-ansi -pedantic accepts _Bool without diagnostic)

PR c/29467
	* c-decl.c (declspecs_add_type): Pedwarn if boolean types are used
	in C89 mode.

	* 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.

From-SVN: r209971
This commit is contained in:
Marek Polacek 2014-05-01 07:21:07 +00:00 committed by Marek Polacek
parent d00887e899
commit c9379ce2a9
7 changed files with 56 additions and 13 deletions

View File

@ -1,3 +1,9 @@
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

View File

@ -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 "

View File

@ -1,3 +1,13 @@
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

View File

@ -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" } */

View File

@ -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" } */
}

View File

@ -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)

View File

@ -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);