diff options
| author | Joseph Myers <joseph@codesourcery.com> | 2009-04-08 15:11:46 +0100 |
|---|---|---|
| committer | Joseph Myers <jsm28@gcc.gnu.org> | 2009-04-08 15:11:46 +0100 |
| commit | 4d84fe7ceeda4dfa363b4cfe273db99003b87abe (patch) | |
| tree | 725240e973ffe286fcab43b5d65f6b5ee8e4b5c2 /gcc/testsuite | |
| parent | 2db15b1d05e7c42b11a0a7cdff27266189187ea3 (diff) | |
| download | gcc-4d84fe7ceeda4dfa363b4cfe273db99003b87abe.zip gcc-4d84fe7ceeda4dfa363b4cfe273db99003b87abe.tar.gz gcc-4d84fe7ceeda4dfa363b4cfe273db99003b87abe.tar.bz2 | |
re PR middle-end/39614 (Internal error compiling CSiBE)
PR c/39614
PR c/39673
* c-common.h (C_MAYBE_CONST_EXPR_PRE, C_MAYBE_CONST_EXPR_EXPR,
C_MAYBE_CONST_EXPR_INT_OPERANDS, C_MAYBE_CONST_EXPR_NON_CONST,
EXPR_INT_CONST_OPERANDS): Remove duplicate definitions.
* c-convert.c (convert): Do not call fold on results of conversion
functions when the result is a C_MAYBE_CONST_EXPR.
* c-parser.c (c_parser_postfix_expression): Do not fold condition
of __builtin_choose_expr.
* c-typeck.c (remove_c_maybe_const_expr): New.
(build_unary_op, build_conditional_expr, build_compound_expr,
build_binary_op, c_objc_common_truthvalue_conversion): Call
remove_c_maybe_const_expr on any input C_MAYBE_CONST_EXPR with
integer operands.
testsuite:
* gcc.c-torture/compile/pr39614-1.c,
gcc.c-torture/compile/pr39614-2.c,
gcc.c-torture/compile/pr39614-3.c,
gcc.c-torture/compile/pr39614-4.c,
gcc.c-torture/compile/pr39614-5.c,
gcc.c-torture/compile/pr39673-1.c,
gcc.c-torture/compile/pr39673-2.c: New tests.
* gcc.dg/gnu89-const-expr-2.c, gcc.dg/gnu99-const-expr-2.c: Test
more cases.
* gcc.dg/overflow-warn-1.c, gcc.dg/overflow-warn-2.c,
gcc.dg/overflow-warn-3.c, gcc.dg/overflow-warn-4.c: Update
expected errors.
From-SVN: r145737
Diffstat (limited to 'gcc/testsuite')
| -rw-r--r-- | gcc/testsuite/ChangeLog | 17 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr39614-1.c | 7 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr39614-2.c | 6 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr39614-3.c | 6 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr39614-4.c | 6 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr39614-5.c | 8 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr39673-1.c | 6 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr39673-2.c | 6 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.dg/gnu89-const-expr-2.c | 3 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.dg/gnu99-const-expr-2.c | 3 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.dg/overflow-warn-1.c | 2 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.dg/overflow-warn-2.c | 2 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.dg/overflow-warn-3.c | 2 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.dg/overflow-warn-4.c | 2 |
14 files changed, 72 insertions, 4 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 23564bd..48269e9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,20 @@ +2009-04-08 Joseph Myers <joseph@codesourcery.com> + + PR c/39614 + PR c/39673 + * gcc.c-torture/compile/pr39614-1.c, + gcc.c-torture/compile/pr39614-2.c, + gcc.c-torture/compile/pr39614-3.c, + gcc.c-torture/compile/pr39614-4.c, + gcc.c-torture/compile/pr39614-5.c, + gcc.c-torture/compile/pr39673-1.c, + gcc.c-torture/compile/pr39673-2.c: New tests. + * gcc.dg/gnu89-const-expr-2.c, gcc.dg/gnu99-const-expr-2.c: Test + more cases. + * gcc.dg/overflow-warn-1.c, gcc.dg/overflow-warn-2.c, + gcc.dg/overflow-warn-3.c, gcc.dg/overflow-warn-4.c: Update + expected errors. + 2009-04-08 Dodji Seketeli <dodji@redhat.com> PRc++/39637 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39614-1.c b/gcc/testsuite/gcc.c-torture/compile/pr39614-1.c new file mode 100644 index 0000000..a9559c73 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr39614-1.c @@ -0,0 +1,7 @@ +typedef struct page { + unsigned long flags; +} mem_map_t; +static inline void set_page_zone(struct page *page, unsigned long zone_num) +{ + page->flags &= ~(~0UL << (64 - 8)); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39614-2.c b/gcc/testsuite/gcc.c-torture/compile/pr39614-2.c new file mode 100644 index 0000000..e3cefb7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr39614-2.c @@ -0,0 +1,6 @@ +int i; +void +f (void) +{ + i = (1 / 0) / 0; +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39614-3.c b/gcc/testsuite/gcc.c-torture/compile/pr39614-3.c new file mode 100644 index 0000000..f9fa3b9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr39614-3.c @@ -0,0 +1,6 @@ +int i; +void +f (void) +{ + i = (1 ? 1 / 0 : 1 / 0); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39614-4.c b/gcc/testsuite/gcc.c-torture/compile/pr39614-4.c new file mode 100644 index 0000000..2426ee2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr39614-4.c @@ -0,0 +1,6 @@ +int i; +void +f (void) +{ + i = (1 / 0 ? 1 : 0); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39614-5.c b/gcc/testsuite/gcc.c-torture/compile/pr39614-5.c new file mode 100644 index 0000000..0cae4de --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr39614-5.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-w -std=c99" } */ +int i; +void +f (void) +{ + i = (1 / 0, 1 / 0); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39673-1.c b/gcc/testsuite/gcc.c-torture/compile/pr39673-1.c new file mode 100644 index 0000000..d2e0387 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr39673-1.c @@ -0,0 +1,6 @@ +unsigned long f1(); +int f2(); + +int store_aff_word(int x) { + return (int) (x ? f1() : f2()); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39673-2.c b/gcc/testsuite/gcc.c-torture/compile/pr39673-2.c new file mode 100644 index 0000000..68407a4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr39673-2.c @@ -0,0 +1,6 @@ +unsigned long long f1(); +int f2(); + +int store_aff_word(int x) { + return (int) (x ? f1() : f2()); +} diff --git a/gcc/testsuite/gcc.dg/gnu89-const-expr-2.c b/gcc/testsuite/gcc.dg/gnu89-const-expr-2.c index 3395b55..fd4d18e 100644 --- a/gcc/testsuite/gcc.dg/gnu89-const-expr-2.c +++ b/gcc/testsuite/gcc.dg/gnu89-const-expr-2.c @@ -20,4 +20,7 @@ f (void) a = __builtin_choose_expr ((void *)0, b, c); /* { dg-error "constant" } */ a = __builtin_choose_expr (0 * (INT_MAX + 1), b, c); /* { dg-warning "integer overflow in expression" } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 21 } */ + a = __builtin_choose_expr (1 / 0, 0, 0); /* { dg-warning "division by zero" } */ + /* { dg-error "not a constant" "error" { target *-*-* } 23 } */ + a = __builtin_choose_expr ((1 ? 1 : a), b, c); /* { dg-error "constant" } */ } diff --git a/gcc/testsuite/gcc.dg/gnu99-const-expr-2.c b/gcc/testsuite/gcc.dg/gnu99-const-expr-2.c index f868c53..f9acef8 100644 --- a/gcc/testsuite/gcc.dg/gnu99-const-expr-2.c +++ b/gcc/testsuite/gcc.dg/gnu99-const-expr-2.c @@ -20,4 +20,7 @@ f (void) a = __builtin_choose_expr ((void *)0, b, c); /* { dg-error "constant" } */ a = __builtin_choose_expr (0 * (INT_MAX + 1), b, c); /* { dg-warning "integer overflow in expression" } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 21 } */ + a = __builtin_choose_expr (1 / 0, 0, 0); /* { dg-warning "division by zero" } */ + /* { dg-error "not a constant" "error" { target *-*-* } 23 } */ + a = __builtin_choose_expr ((1 ? 1 : a), b, c); /* { dg-error "constant" } */ } diff --git a/gcc/testsuite/gcc.dg/overflow-warn-1.c b/gcc/testsuite/gcc.dg/overflow-warn-1.c index 633d70b..0cf08a3 100644 --- a/gcc/testsuite/gcc.dg/overflow-warn-1.c +++ b/gcc/testsuite/gcc.dg/overflow-warn-1.c @@ -49,7 +49,7 @@ static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ /* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } 49 } */ void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ -/* { dg-error "initializer element is not constant" "constant" { target *-*-* } 51 } */ +/* { dg-error "initializer element is not computable at load time" "constant" { target *-*-* } 51 } */ /* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } 51 } */ void *r = (1 ? 0 : INT_MAX+1); diff --git a/gcc/testsuite/gcc.dg/overflow-warn-2.c b/gcc/testsuite/gcc.dg/overflow-warn-2.c index e8bbd24..f6595d5 100644 --- a/gcc/testsuite/gcc.dg/overflow-warn-2.c +++ b/gcc/testsuite/gcc.dg/overflow-warn-2.c @@ -49,7 +49,7 @@ static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ /* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } 49 } */ void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ -/* { dg-error "initializer element is not constant" "constant" { target *-*-* } 51 } */ +/* { dg-error "initializer element is not computable at load time" "constant" { target *-*-* } 51 } */ /* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } 51 } */ void *r = (1 ? 0 : INT_MAX+1); diff --git a/gcc/testsuite/gcc.dg/overflow-warn-3.c b/gcc/testsuite/gcc.dg/overflow-warn-3.c index d9a3ae4..fae26d4 100644 --- a/gcc/testsuite/gcc.dg/overflow-warn-3.c +++ b/gcc/testsuite/gcc.dg/overflow-warn-3.c @@ -55,7 +55,7 @@ void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 54 } */ /* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } 54 } */ void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ -/* { dg-error "initializer element is not constant" "constant" { target *-*-* } 57 } */ +/* { dg-error "initializer element is not computable at load time" "constant" { target *-*-* } 57 } */ /* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } 57 } */ void *r = (1 ? 0 : INT_MAX+1); diff --git a/gcc/testsuite/gcc.dg/overflow-warn-4.c b/gcc/testsuite/gcc.dg/overflow-warn-4.c index 7b7e23c..464533a 100644 --- a/gcc/testsuite/gcc.dg/overflow-warn-4.c +++ b/gcc/testsuite/gcc.dg/overflow-warn-4.c @@ -55,7 +55,7 @@ void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 54 } */ /* { dg-error "initialization makes pointer from integer without a cast" "null" { target *-*-* } 54 } */ void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ -/* { dg-error "initializer element is not constant" "constant" { target *-*-* } 57 } */ +/* { dg-error "initializer element is not computable at load time" "constant" { target *-*-* } 57 } */ /* { dg-error "initialization makes pointer from integer without a cast" "null" { target *-*-* } 57 } */ void *r = (1 ? 0 : INT_MAX+1); |
