aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorMartin Uecker <muecker@gwdg.de>2020-11-20 07:21:40 +0100
committerMartin Uecker <muecker@gwdg.de>2020-11-20 07:34:11 +0100
commit32934a4f45a72144cdcd0712cc294fe88c36f13d (patch)
tree022f80ca6020cfb841771515910a9f920abf6829 /gcc/testsuite
parentd62586ee567bbbdab9fe8bb5829f032431d57098 (diff)
downloadgcc-32934a4f45a72144cdcd0712cc294fe88c36f13d.zip
gcc-32934a4f45a72144cdcd0712cc294fe88c36f13d.tar.gz
gcc-32934a4f45a72144cdcd0712cc294fe88c36f13d.tar.bz2
C: Drop qualifiers during lvalue conversion [PR97702]
2020-11-20 Martin Uecker <muecker@gwdg.de> gcc/ * gimplify.c (gimplify_modify_expr_rhs): Optimizie NOP_EXPRs that contain compound literals. gcc/c/ * c-typeck.c (convert_lvalue_to_rvalue): Drop qualifiers. gcc/testsuite/ * gcc.dg/cond-constqual-1.c: Adapt test. * gcc.dg/lvalue-11.c: New test. * gcc.dg/pr60195.c: Add warning.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/gcc.dg/cond-constqual-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/lvalue-11.c40
-rw-r--r--gcc/testsuite/gcc.dg/pr60195.c2
3 files changed, 42 insertions, 2 deletions
diff --git a/gcc/testsuite/gcc.dg/cond-constqual-1.c b/gcc/testsuite/gcc.dg/cond-constqual-1.c
index 3354c72..b5a09cb 100644
--- a/gcc/testsuite/gcc.dg/cond-constqual-1.c
+++ b/gcc/testsuite/gcc.dg/cond-constqual-1.c
@@ -11,5 +11,5 @@ test (void)
__typeof__ (1 ? foo (0) : 0) texpr;
__typeof__ (1 ? i : 0) texpr2;
texpr = 0; /* { dg-bogus "read-only variable" "conditional expression with call to const function" } */
- texpr2 = 0; /* { dg-error "read-only variable" "conditional expression with const variable" } */
+ texpr2 = 0; /* { dg-bogus "read-only variable" "conditional expression with const variable" } */
}
diff --git a/gcc/testsuite/gcc.dg/lvalue-11.c b/gcc/testsuite/gcc.dg/lvalue-11.c
new file mode 100644
index 0000000..d8b5a60c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lvalue-11.c
@@ -0,0 +1,40 @@
+/* test that lvalue conversions drops qualifiers, Bug 97702 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+
+const int jc;
+extern int j;
+extern typeof(0,jc) j;
+extern typeof(+jc) j;
+extern typeof(-jc) j;
+extern typeof(1?jc:0) j;
+extern typeof((int)jc) j;
+extern typeof((const int)jc) j;
+
+volatile int kv;
+extern int k;
+extern typeof(0,kv) k;
+extern typeof(+kv) k;
+extern typeof(-kv) k;
+extern typeof(1?kv:0) k;
+extern typeof((int)kv) k;
+extern typeof((volatile int)kv) k;
+
+_Atomic int la;
+extern int l;
+extern typeof(0,la) l;
+extern typeof(+la) l;
+extern typeof(-la) l;
+extern typeof(1?la:0) l;
+extern typeof((int)la) l;
+extern typeof((_Atomic int)la) l;
+
+int * restrict mr;
+extern int *m;
+extern typeof(0,mr) m;
+extern typeof(1?mr:0) m;
+extern typeof((int *)mr) m;
+extern typeof((int * restrict)mr) m;
+
+
diff --git a/gcc/testsuite/gcc.dg/pr60195.c b/gcc/testsuite/gcc.dg/pr60195.c
index 0a50a30..8eccf7f 100644
--- a/gcc/testsuite/gcc.dg/pr60195.c
+++ b/gcc/testsuite/gcc.dg/pr60195.c
@@ -15,7 +15,7 @@ atomic_int
fn2 (void)
{
atomic_int y = 0;
- y;
+ y; /* { dg-warning "statement with no effect" } */
return y;
}