diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-04-09 00:35:39 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-04-09 00:35:39 +0000 |
commit | d4eea8362605807327735727a9098abe1eb23b19 (patch) | |
tree | ffa33b82edfd313505b5bf83dac9fd6b6e844fa9 /test/Sema/conditional-expr.c | |
parent | 355fa3a65d2bffb2cb230e5c3d8cd14ec5570329 (diff) |
Improve diagnostics when we fail to convert from a source type to a
destination type for initialization, assignment, parameter-passing,
etc. The main issue fixed here is that we used rather confusing
wording for diagnostics such as
t.c:2:9: warning: initializing 'char const [2]' discards qualifiers,
expected 'char *' [-pedantic]
char *name = __func__;
^ ~~~~~~~~
We're not initializing a 'char const [2]', we're initializing a 'char
*' with an expression of type 'char const [2]'. Similar problems
existed for other diagnostics in this area, so I've normalized them all
with more precise descriptive text to say what we're
initializing/converting/assigning/etc. from and to. The warning for
the code above is now:
t.c:2:9: warning: initializing 'char *' from an expression of type
'char const [2]' discards qualifiers [-pedantic]
char *name = __func__;
^ ~~~~~~~~
Fixes <rdar://problem/7447179>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100832 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/conditional-expr.c')
-rw-r--r-- | test/Sema/conditional-expr.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/Sema/conditional-expr.c b/test/Sema/conditional-expr.c index 5f01374be3..5e2c1a4624 100644 --- a/test/Sema/conditional-expr.c +++ b/test/Sema/conditional-expr.c @@ -13,11 +13,11 @@ void foo() { dp = vp; vp = dp; - ip = dp; // expected-warning {{incompatible pointer types assigning 'double *', expected 'int *'}} - dp = ip; // expected-warning {{incompatible pointer types assigning 'int *', expected 'double *'}} + ip = dp; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double *'}} + dp = ip; // expected-warning {{incompatible pointer types assigning to 'double *' from 'int *'}} dp = 0 ? (double *)0 : (void *)0; vp = 0 ? (double *)0 : (void *)0; - ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning 'double *', expected 'int *'}} + ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double *'}} const int *cip; vp = (0 ? vp : cip); // expected-warning {{discards qualifiers}} @@ -66,5 +66,5 @@ extern int f1(void); int f0(int a) { // GCC considers this a warning. - return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-warning {{incompatible pointer to integer conversion returning 'void *', expected 'int'}} + return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-warning {{incompatible pointer to integer conversion returning 'void *' from a function with result type 'int'}} } |