diff options
author | Patrick Palka <ppalka@gcc.gnu.org> | 2014-08-19 14:14:15 +0000 |
---|---|---|
committer | Patrick Palka <ppalka@gcc.gnu.org> | 2014-08-19 14:14:15 +0000 |
commit | c77935ee29336399ab6318e912baa174e243654a (patch) | |
tree | aa8358e5df2689d3a6cc449f8540ceb1d095a0c6 /gcc | |
parent | d20770308827d407c4fc2b25413bbf5e716971f9 (diff) | |
download | gcc-c77935ee29336399ab6318e912baa174e243654a.zip gcc-c77935ee29336399ab6318e912baa174e243654a.tar.gz gcc-c77935ee29336399ab6318e912baa174e243654a.tar.bz2 |
re PR c/45584 (typeof with casting from const to non-const does not work properly)
2014-08-19 Patrick Palka <ppalka@gcc.gnu.org>
PR c/45584
* c-typeck.c (build_c_cast): Do a conversion even when the
TYPE_MAIN_VARIANTs are the same.
2014-08-19 Patrick Palka <ppalka@gcc.gnu.org>
PR c/45584
* gcc.dg/pr13519-1.c: Adjust.
From-SVN: r214151
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr13519-1.c | 6 |
4 files changed, 18 insertions, 4 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 27f865e..391cfed 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2014-08-19 Patrick Palka <ppalka@gcc.gnu.org> + + PR c/45584 + * c-typeck.c (build_c_cast): Do a conversion even when the + TYPE_MAIN_VARIANTs are the same. + 2014-08-19 Marek Polacek <polacek@redhat.com> * c-decl.c (diagnose_mismatched_decls): Unconditionally call diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index b1eac34..3210f1a 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -4947,6 +4947,9 @@ build_c_cast (location_t loc, tree type, tree expr) || TREE_CODE (type) == UNION_TYPE) pedwarn (loc, OPT_Wpedantic, "ISO C forbids casting nonscalar to the same type"); + + /* Convert to remove any qualifiers from VALUE's type. */ + value = convert (type, value); } else if (TREE_CODE (type) == UNION_TYPE) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5433c91..a783217 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-08-19 Patrick Palka <ppalka@gcc.gnu.org> + + PR c/45584 + * gcc.dg/pr13519-1.c: Adjust. + 2014-08-19 Mark Wielaard <mjw@redhat.com> * gcc.dg/guality/const-volatile.c: Add `used' attribute to pi. @@ -7,7 +12,7 @@ PR debug/59051 * gcc.dg/guality/restrict.c: New test. -2014-07-03 Mark Wielaard <mjw@redhat.com> +2014-08-19 Mark Wielaard <mjw@redhat.com> * lib/gcc-gdb-test.exp (gdb-test): Handle type:var for gdb ptype matching. Catch '<unknown type in ' to recognize older gdb versions. diff --git a/gcc/testsuite/gcc.dg/pr13519-1.c b/gcc/testsuite/gcc.dg/pr13519-1.c index 907165f..1117a0e 100644 --- a/gcc/testsuite/gcc.dg/pr13519-1.c +++ b/gcc/testsuite/gcc.dg/pr13519-1.c @@ -14,9 +14,9 @@ void fn(void) { __typeof__(n) a1; a1=0; } { __typeof__(c) a2; a2=0; } /* { dg-error "read-only" "correct error" } */ { __typeof__((int)n) a3; a3=0; } - { __typeof__((int)c) a4; a4=0; } /* { dg-bogus "read-only" "bogus error" { xfail *-*-* } } */ - { __typeof__((const int)n) a5; a5=0; } /* { dg-error "read-only" "correct error" { xfail *-*-* } } */ - { __typeof__((const int)c) a6; a6=0; } /* { dg-error "read-only" "correct error" } */ + { __typeof__((int)c) a4; a4=0; } /* { dg-bogus "read-only" "bogus error" } */ + { __typeof__((const int)n) a5; a5=0; } + { __typeof__((const int)c) a6; a6=0; } { __typeof__(0) a7; a7=0; } { __typeof__(1) a8; a8=0; } |