summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2010-06-04 15:15:38 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2010-06-04 15:15:38 +0000
commit49706e39a2b65519ef173e55637c41c899e0b968 (patch)
tree2537a481171fe231924d117a943f8cd28aebff61 /gcc/testsuite/gcc.dg
parentb13ea8bd6dc138446ad640d934fc22498d915e82 (diff)
downloadgcc-49706e39a2b65519ef173e55637c41c899e0b968.tar.gz
re PR c/25880 (improve message of warning for discarding qualifiers)
2010-06-04 Manuel López-Ibáñez <manu@gcc.gnu.org> PR c/25880 * c-objc-common.c (c_tree_printer): Handle %V, %v and %#v. * c-format.c (gcc_diag_flag_specs): Add hash. (gcc_cxxdiag_flag_specs): Use gcc_diag_flag_specs directly. (gcc_tdiag_char_table,gcc_cdiag_char_table): Handle %V and %v. * c-pretty-print.c (pp_c_cv_qualifier): Rename as pp_c_cv_qualifiers. Handle qualifiers spelling here. (pp_c_type_qualifier_list): Call the function above. * c-pretty-print.h (pp_c_cv_qualifiers): Declare. * c-typeck.c (handle_warn_cast_qual): Print qualifiers. (WARN_FOR_QUALIFIERS): New macro. (convert_for_assignment): Use it. testsuite/ * gcc.dg/assign-warn-2.c: Update. * gcc.dg/cpp/line3.c: Update. * gcc.dg/c99-array-lval-8.c: Update. * gcc.dg/cast-qual-2.c: Update. * gcc.dg/c99-arraydecl-3.c: Update. * gcc.dg/assign-warn-1.c: Update. * gcc.dg/format/gcc_diag-1.c: Update. From-SVN: r160274
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r--gcc/testsuite/gcc.dg/assign-warn-1.c20
-rw-r--r--gcc/testsuite/gcc.dg/assign-warn-2.c20
-rw-r--r--gcc/testsuite/gcc.dg/c99-array-lval-8.c6
-rw-r--r--gcc/testsuite/gcc.dg/c99-arraydecl-3.c4
-rw-r--r--gcc/testsuite/gcc.dg/cast-qual-2.c8
-rw-r--r--gcc/testsuite/gcc.dg/cpp/line3.c8
-rw-r--r--gcc/testsuite/gcc.dg/format/gcc_diag-1.c24
7 files changed, 51 insertions, 39 deletions
diff --git a/gcc/testsuite/gcc.dg/assign-warn-1.c b/gcc/testsuite/gcc.dg/assign-warn-1.c
index a0cfd890f10..ae70242edd4 100644
--- a/gcc/testsuite/gcc.dg/assign-warn-1.c
+++ b/gcc/testsuite/gcc.dg/assign-warn-1.c
@@ -12,11 +12,11 @@
typedef void (*fp)(void);
typedef void (*nrfp)(void) __attribute__((noreturn));
-TESTARG(fqa, nrfp, fp); /* { dg-warning "passing argument 1 of 'fqaF' makes qualified function pointer from unqualified" } */
-TESTARP(fqb, nrfp, fp); /* { dg-warning "passing argument 1 of 'fqbFp.x' makes qualified function pointer from unqualified" } */
-TESTASS(fqc, nrfp, fp); /* { dg-warning "assignment makes qualified function pointer from unqualified" } */
-TESTINI(fqd, nrfp, fp); /* { dg-warning "initialization makes qualified function pointer from unqualified" } */
-TESTRET(fqe, nrfp, fp); /* { dg-warning "return makes qualified function pointer from unqualified" } */
+TESTARG(fqa, nrfp, fp); /* { dg-warning "passing argument 1 of 'fqaF' makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */
+TESTARP(fqb, nrfp, fp); /* { dg-warning "passing argument 1 of 'fqbFp.x' makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */
+TESTASS(fqc, nrfp, fp); /* { dg-warning "assignment makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */
+TESTINI(fqd, nrfp, fp); /* { dg-warning "initialization makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */
+TESTRET(fqe, nrfp, fp); /* { dg-warning "return makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */
TESTARG(ofqa, fp, nrfp);
TESTARP(ofqb, fp, nrfp);
@@ -24,11 +24,11 @@ TESTASS(ofqc, fp, nrfp);
TESTINI(ofqd, fp, nrfp);
TESTRET(ofqe, fp, nrfp);
-TESTARG(qa, char *, const char *); /* { dg-warning "passing argument 1 of 'qaF' discards qualifiers from pointer target type" } */
-TESTARP(qb, char *, const char *); /* { dg-warning "passing argument 1 of 'qbFp.x' discards qualifiers from pointer target type" } */
-TESTASS(qc, char *, const char *); /* { dg-warning "assignment discards qualifiers from pointer target type" } */
-TESTINI(qd, char *, const char *); /* { dg-warning "initialization discards qualifiers from pointer target type" } */
-TESTRET(qe, char *, const char *); /* { dg-warning "return discards qualifiers from pointer target type" } */
+TESTARG(qa, char *, const char *); /* { dg-warning "passing argument 1 of 'qaF' discards 'const' qualifier from pointer target type" } */
+TESTARP(qb, char *, const char *); /* { dg-warning "passing argument 1 of 'qbFp.x' discards 'const' qualifier from pointer target type" } */
+TESTASS(qc, char *, const char *); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+TESTINI(qd, char *, const char *); /* { dg-warning "initialization discards 'const' qualifier from pointer target type" } */
+TESTRET(qe, char *, const char *); /* { dg-warning "return discards 'const' qualifier from pointer target type" } */
TESTARG(oqa, const char *, char *);
TESTARP(oqb, const char *, char *);
diff --git a/gcc/testsuite/gcc.dg/assign-warn-2.c b/gcc/testsuite/gcc.dg/assign-warn-2.c
index f3d861d7405..7813b72869d 100644
--- a/gcc/testsuite/gcc.dg/assign-warn-2.c
+++ b/gcc/testsuite/gcc.dg/assign-warn-2.c
@@ -13,11 +13,11 @@
typedef void (*fp)(void);
typedef void (*nrfp)(void) __attribute__((noreturn));
-TESTARG(fqa, nrfp, fp); /* { dg-error "passing argument 1 of 'fqaF' makes qualified function pointer from unqualified" } */
-TESTARP(fqb, nrfp, fp); /* { dg-error "passing argument 1 of 'fqbFp.x' makes qualified function pointer from unqualified" } */
-TESTASS(fqc, nrfp, fp); /* { dg-error "assignment makes qualified function pointer from unqualified" } */
-TESTINI(fqd, nrfp, fp); /* { dg-error "initialization makes qualified function pointer from unqualified" } */
-TESTRET(fqe, nrfp, fp); /* { dg-error "return makes qualified function pointer from unqualified" } */
+TESTARG(fqa, nrfp, fp); /* { dg-error "passing argument 1 of 'fqaF' makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */
+TESTARP(fqb, nrfp, fp); /* { dg-error "passing argument 1 of 'fqbFp.x' makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */
+TESTASS(fqc, nrfp, fp); /* { dg-error "assignment makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */
+TESTINI(fqd, nrfp, fp); /* { dg-error "initialization makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */
+TESTRET(fqe, nrfp, fp); /* { dg-error "return makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */
TESTARG(ofqa, fp, nrfp);
TESTARP(ofqb, fp, nrfp);
@@ -25,11 +25,11 @@ TESTASS(ofqc, fp, nrfp);
TESTINI(ofqd, fp, nrfp);
TESTRET(ofqe, fp, nrfp);
-TESTARG(qa, char *, const char *); /* { dg-error "passing argument 1 of 'qaF' discards qualifiers from pointer target type" } */
-TESTARP(qb, char *, const char *); /* { dg-error "passing argument 1 of 'qbFp.x' discards qualifiers from pointer target type" } */
-TESTASS(qc, char *, const char *); /* { dg-error "assignment discards qualifiers from pointer target type" } */
-TESTINI(qd, char *, const char *); /* { dg-error "initialization discards qualifiers from pointer target type" } */
-TESTRET(qe, char *, const char *); /* { dg-error "return discards qualifiers from pointer target type" } */
+TESTARG(qa, char *, const char *); /* { dg-error "passing argument 1 of 'qaF' discards 'const' qualifier from pointer target type" } */
+TESTARP(qb, char *, const char *); /* { dg-error "passing argument 1 of 'qbFp.x' discards 'const' qualifier from pointer target type" } */
+TESTASS(qc, char *, const char *); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+TESTINI(qd, char *, const char *); /* { dg-error "initialization discards 'const' qualifier from pointer target type" } */
+TESTRET(qe, char *, const char *); /* { dg-error "return discards 'const' qualifier from pointer target type" } */
TESTARG(oqa, const char *, char *);
TESTARP(oqb, const char *, char *);
diff --git a/gcc/testsuite/gcc.dg/c99-array-lval-8.c b/gcc/testsuite/gcc.dg/c99-array-lval-8.c
index b5048b66a77..c4e202ef301 100644
--- a/gcc/testsuite/gcc.dg/c99-array-lval-8.c
+++ b/gcc/testsuite/gcc.dg/c99-array-lval-8.c
@@ -12,15 +12,15 @@ f (void)
const struct {
int a[1];
} s;
- int *p1 = s.a; /* { dg-error "qualifiers" } */
+ int *p1 = s.a; /* { dg-error "qualifier" } */
int *p2 = (a ? s : s).a;
/* In this case, the qualifier is properly on the array element type
not on the rvalue structure and so is not discarded. */
struct {
const int a[1];
} t;
- int *p3 = t.a; /* { dg-error "qualifiers" } */
- int *p4 = (a ? t : t).a; /* { dg-error "qualifiers" } */
+ int *p3 = t.a; /* { dg-error "qualifier" } */
+ int *p4 = (a ? t : t).a; /* { dg-error "qualifier" } */
/* The issue could also lead to code being wrongly accepted. */
const struct {
int a[1][1];
diff --git a/gcc/testsuite/gcc.dg/c99-arraydecl-3.c b/gcc/testsuite/gcc.dg/c99-arraydecl-3.c
index 2ab927d6ab2..9f383b9c3bb 100644
--- a/gcc/testsuite/gcc.dg/c99-arraydecl-3.c
+++ b/gcc/testsuite/gcc.dg/c99-arraydecl-3.c
@@ -7,7 +7,7 @@
void
f0 (int a[restrict])
{
- int **b = &a; /* { dg-error "discards qualifiers" } */
+ int **b = &a; /* { dg-error "discards 'restrict' qualifier" } */
int *restrict *c = &a;
}
@@ -15,6 +15,6 @@ void
f1 (a)
int a[restrict];
{
- int **b = &a; /* { dg-error "discards qualifiers" } */
+ int **b = &a; /* { dg-error "discards 'restrict' qualifier" } */
int *restrict *c = &a;
}
diff --git a/gcc/testsuite/gcc.dg/cast-qual-2.c b/gcc/testsuite/gcc.dg/cast-qual-2.c
index 0be1d617176..5fd2b854d61 100644
--- a/gcc/testsuite/gcc.dg/cast-qual-2.c
+++ b/gcc/testsuite/gcc.dg/cast-qual-2.c
@@ -18,8 +18,8 @@ intfn_t *i2 = (intfn_t *) intfn;
intfn_t *i3 = constfn;
intfn_t *i4 = (intfn_t *) constfn; /* { dg-bogus "discards qualifier" } */
-constfn_t p1 = intfn; /* { dg-warning "makes qualified function" } */
-constfn_t p2 = (constfn_t) intfn; /* { dg-warning "new qualifier" } */
+constfn_t p1 = intfn; /* { dg-warning "makes '__attribute__..const..' qualified function" } */
+constfn_t p2 = (constfn_t) intfn; /* { dg-warning "adds '__attribute__..const..' qualifier" } */
constfn_t p3 = constfn;
constfn_t p4 = (constfn_t) constfn;
@@ -28,7 +28,7 @@ voidfn_t *v2 = (voidfn_t *) voidfn;
voidfn_t *v3 = noreturnfn;
voidfn_t *v4 = (voidfn_t *) noreturnfn; /* { dg-bogus "discards qualifier" } */
-noreturnfn_t n1 = voidfn; /* { dg-warning "makes qualified function" } */
-noreturnfn_t n2 = (noreturnfn_t) voidfn; /* { dg-warning "new qualifier" } */
+noreturnfn_t n1 = voidfn; /* { dg-warning "makes '__attribute__..noreturn..' qualified function" } */
+noreturnfn_t n2 = (noreturnfn_t) voidfn; /* { dg-warning "adds '__attribute__..noreturn..' qualifier" } */
noreturnfn_t n3 = noreturnfn;
noreturnfn_t n4 = (noreturnfn_t) noreturnfn;
diff --git a/gcc/testsuite/gcc.dg/cpp/line3.c b/gcc/testsuite/gcc.dg/cpp/line3.c
index 7a1061478d4..4b40e4a6a95 100644
--- a/gcc/testsuite/gcc.dg/cpp/line3.c
+++ b/gcc/testsuite/gcc.dg/cpp/line3.c
@@ -13,14 +13,14 @@ main(void)
{
char *A;
- A = "text"; /* { dg-warning "discards qualifiers" "case zero" } */
- A = one("text" /* { dg-warning "discards qualifiers" "case one" } */
+ A = "text"; /* { dg-warning "discards 'const' qualifier" "case zero" } */
+ A = one("text" /* { dg-warning "discards 'const' qualifier" "case one" } */
"text")
;
- A = two("text" /* { dg-warning "discards qualifiers" "case two" } */
+ A = two("text" /* { dg-warning "discards 'const' qualifier" "case two" } */
"text")
;
- A = four("text" /* { dg-warning "discards qualifiers" "case four" } */
+ A = four("text" /* { dg-warning "discards 'const' qualifier" "case four" } */
"text")
;
diff --git a/gcc/testsuite/gcc.dg/format/gcc_diag-1.c b/gcc/testsuite/gcc.dg/format/gcc_diag-1.c
index 46013c8699e..f88965fe659 100644
--- a/gcc/testsuite/gcc.dg/format/gcc_diag-1.c
+++ b/gcc/testsuite/gcc.dg/format/gcc_diag-1.c
@@ -70,13 +70,13 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p,
cdiag ("%m");
cxxdiag ("%m");
- tdiag ("%D%F%T", t1, t1, t1);
- tdiag ("%+D%+F%+T", t1, t1, t1);
- tdiag ("%q+D%q+F%q+T", t1, t1, t1);
+ tdiag ("%D%F%T%V", t1, t1, t1, t1);
+ tdiag ("%+D%+F%+T%+V", t1, t1, t1, t1);
+ tdiag ("%q+D%q+F%q+T%q+V", t1, t1, t1, t1);
tdiag ("%D%D%D%D", t1, t2, *t3, t4[5]);
- cdiag ("%D%F%T", t1, t1, t1);
- cdiag ("%+D%+F%+T", t1, t1, t1);
- cdiag ("%q+D%q+F%q+T", t1, t1, t1);
+ cdiag ("%D%F%T%V", t1, t1, t1, t1);
+ cdiag ("%+D%+F%+T%+V", t1, t1, t1, t1);
+ cdiag ("%q+D%q+F%q+T%q+V", t1, t1, t1, t1);
cdiag ("%D%D%D%D", t1, t2, *t3, t4[5]);
cdiag ("%E", t1);
cxxdiag ("%A%D%E%F%T%V", t1, t1, t1, t1, t1, t1);
@@ -86,6 +86,10 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p,
cxxdiag ("%+#A%+#D%+#E%+#F%+#T%+#V", t1, t1, t1, t1, t1, t1);
cxxdiag ("%C%L%O%P%Q", i, i, i, i, i);
+ tdiag ("%v%qv%#v", i, i, i);
+ cdiag ("%v%qv%#v", i, i, i);
+ cxxdiag ("%v%qv%#v", i, i, i);
+
/* Bad stuff with extensions. */
diag ("%m", i); /* { dg-warning "format" "extra arg" } */
tdiag ("%m", i); /* { dg-warning "format" "extra arg" } */
@@ -121,6 +125,14 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p,
cdiag ("%D", t1, t1); /* { dg-warning "format" "extra arg" } */
cxxdiag ("%D", t1, t1); /* { dg-warning "format" "extra arg" } */
+ tdiag ("%V", i); /* { dg-warning "format" "wrong arg" } */
+ cdiag ("%V", i); /* { dg-warning "format" "wrong arg" } */
+ cxxdiag ("%V", i); /* { dg-warning "format" "wrong arg" } */
+
+ tdiag ("%v", t1); /* { dg-warning "format" "wrong arg" } */
+ cdiag ("%v", t1); /* { dg-warning "format" "wrong arg" } */
+ cxxdiag ("%v", t1); /* { dg-warning "format" "wrong arg" } */
+
/* Standard specifiers not accepted in the diagnostic framework. */
diag ("%X\n", u); /* { dg-warning "format" "HEX" } */
diag ("%f\n", d); /* { dg-warning "format" "float" } */