From 2c1a24210c495aa26a6e2cf90bd2260b2ba18afe Mon Sep 17 00:00:00 2001 From: "Kaveh R. Ghazi" Date: Tue, 12 Jun 2001 12:15:46 +0000 Subject: [PATCH] c-decl.c (grokdeclarator): Use INTEGRAL_TYPE_P. * c-decl.c (grokdeclarator): Use INTEGRAL_TYPE_P. * c-typeck.c (c_start_case): Likewise. testsuite: * gcc.c-torture/compile/20010610-1.c: New test. From-SVN: r43257 --- gcc/ChangeLog | 6 ++++++ gcc/c-decl.c | 3 +-- gcc/c-typeck.c | 3 +-- gcc/testsuite/ChangeLog | 4 ++++ .../gcc.c-torture/compile/20010610-1.c | 19 +++++++++++++++++++ 5 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/20010610-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f3fff9f4ba0..9868b84b77f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2001-06-12 Kaveh R. Ghazi + + * c-decl.c (grokdeclarator): Use INTEGRAL_TYPE_P. + + * c-typeck.c (c_start_case): Likewise. + 2001-06-12 Mark Mitchell * expr.c (store_field): Don't set MEM_ALIAS_SET for a field diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 5d50394d551..2c16afb97a3 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -4357,8 +4357,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */ STRIP_TYPE_NOPS (size); - if (TREE_CODE (TREE_TYPE (size)) != INTEGER_TYPE - && TREE_CODE (TREE_TYPE (size)) != ENUMERAL_TYPE) + if (! INTEGRAL_TYPE_P (TREE_TYPE (size))) { error ("size of array `%s' has non-integer type", name); size = integer_one_node; diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 5653ae59b68..cf995334b9a 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -7077,8 +7077,7 @@ c_start_case (exp) code = TREE_CODE (TREE_TYPE (exp)); type = TREE_TYPE (exp); - if (code != INTEGER_TYPE - && code != ENUMERAL_TYPE + if (! INTEGRAL_TYPE_P (type) && code != ERROR_MARK) { error ("switch quantity not an integer"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a4dfba0301c..dfc4b53d9d6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-06-12 Kaveh R. Ghazi + + * gcc.c-torture/compile/20010610-1.c: New test. + 2001-06-12 Nathan Sidwell * g++.old-deja/g++.abi/vbase4.C: New test. diff --git a/gcc/testsuite/gcc.c-torture/compile/20010610-1.c b/gcc/testsuite/gcc.c-torture/compile/20010610-1.c new file mode 100644 index 00000000000..ee8e2431bbb --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20010610-1.c @@ -0,0 +1,19 @@ +/* Origin: Kaveh R. Ghazi + + Boolean types were not accepted as array sizes nor as switch + quantities. */ + +#include + +int +main(void) +{ + bool arr[(bool)1]; + + switch (arr[0]) + { + default:; + } + + return 0; +} -- 2.30.2