aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/pointer-addition.c
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-06-27 08:02:19 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-06-27 08:02:19 +0000
commit13b21be065e9feb0759303bd51b8e8653130f0fb (patch)
tree6e64dbeff5dfe452f025e68f537b99226fdf5f9f /test/Sema/pointer-addition.c
parent2ced044c34311d8e6301f2b4566f4b612bc8b628 (diff)
Factor out (some of) the checking for invalid forms of pointer
arithmetic into a couple of common routines. Use these to make the messages more consistent in the various contexts, especially in terms of consistently diagnosing binary operators with invalid types on both the left- and right-hand side. Also, improve the grammar and wording of the messages some, handling both two pointers and two (different) types. The wording of function pointer arithmetic diagnostics still strikes me as poorly phrased, and I worry this makes them slightly more awkward if more consistent. I'm hoping to fix that with a follow-on patch and test case that will also make them more helpful when a typedef or template type parameter makes the type completely opaque. Suggestions on better wording are very welcome, thanks to Richard Smith for some initial help on that front. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133906 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/pointer-addition.c')
-rw-r--r--test/Sema/pointer-addition.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/test/Sema/pointer-addition.c b/test/Sema/pointer-addition.c
index 01047a0684..af8258a0f2 100644
--- a/test/Sema/pointer-addition.c
+++ b/test/Sema/pointer-addition.c
@@ -3,19 +3,19 @@
typedef struct S S; // expected-note 3 {{forward declaration of 'struct S'}}
void a(S* b, void* c) {
void (*fp)(int) = 0;
- b++; // expected-error {{arithmetic on pointer to incomplete type}}
- b += 1; // expected-error {{arithmetic on pointer to incomplete type}}
- c++; // expected-warning {{use of GNU void* extension}}
- c += 1; // expected-warning {{use of GNU void* extension}}
- c--; // expected-warning {{use of GNU void* extension}}
- c -= 1; // expected-warning {{use of GNU void* extension}}
- (void) c[1]; // expected-warning {{use of GNU void* extension}}
- b = 1+b; // expected-error {{arithmetic on pointer to incomplete type}}
+ b++; // expected-error {{arithmetic on a pointer to an incomplete type}}
+ b += 1; // expected-error {{arithmetic on a pointer to an incomplete type}}
+ c++; // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
+ c += 1; // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
+ c--; // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
+ c -= 1; // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
+ (void) c[1]; // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
+ b = 1+b; // expected-error {{arithmetic on a pointer to an incomplete type}}
/* The next couple tests are only pedantic warnings in gcc */
void (*d)(S*,void*) = a;
- d += 1; // expected-warning {{arithmetic on pointer to function type 'void (*)(S *, void *)' is a GNU extension}}
- d++; // expected-warning {{arithmetic on pointer to function type 'void (*)(S *, void *)' is a GNU extension}}
- d--; // expected-warning {{arithmetic on pointer to function type 'void (*)(S *, void *)' is a GNU extension}}
- d -= 1; // expected-warning {{arithmetic on pointer to function type 'void (*)(S *, void *)' is a GNU extension}}
- (void)(1 + d); // expected-warning {{arithmetic on pointer to function type 'void (*)(S *, void *)' is a GNU extension}}
+ d += 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
+ d++; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
+ d--; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
+ d -= 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
+ (void)(1 + d); // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
}