diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-06-20 07:52:11 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-06-20 07:52:11 +0000 |
commit | 5f380da06f679aea537dfebe9702f12bfa840f3a (patch) | |
tree | 6143917d17ecabce7dd61e0ff9bfc2face42ecb6 /clang/test | |
parent | 2889f0c75b9722464af18f70c79f3c160b5334c3 (diff) | |
download | bcm5719-llvm-5f380da06f679aea537dfebe9702f12bfa840f3a.tar.gz bcm5719-llvm-5f380da06f679aea537dfebe9702f12bfa840f3a.zip |
Fix a problem with the diagnostics of invalid arithmetic with function
pointers I found while working on the NULL arithmetic warning. We here
always assuming the LHS was the pointer, instead of using the selected
pointer expression.
llvm-svn: 133428
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/Sema/pointer-addition.c | 3 | ||||
-rw-r--r-- | clang/test/SemaCXX/null_in_arithmetic_ops.cpp | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/clang/test/Sema/pointer-addition.c b/clang/test/Sema/pointer-addition.c index aa425a7fd9d..01047a06849 100644 --- a/clang/test/Sema/pointer-addition.c +++ b/clang/test/Sema/pointer-addition.c @@ -14,7 +14,8 @@ void a(S* b, void* c) { /* 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--; // 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}} } diff --git a/clang/test/SemaCXX/null_in_arithmetic_ops.cpp b/clang/test/SemaCXX/null_in_arithmetic_ops.cpp index 9665c3959e7..d9cfc5f89a8 100644 --- a/clang/test/SemaCXX/null_in_arithmetic_ops.cpp +++ b/clang/test/SemaCXX/null_in_arithmetic_ops.cpp @@ -33,7 +33,7 @@ void f() { v = 0 ? NULL + d : d + NULL; // \ expected-error {{invalid operands to binary expression ('long' and 'void (X::*)()')}} \ expected-error {{invalid operands to binary expression ('void (X::*)()' and 'long')}} - v = 0 ? NULL + e : e + NULL; // expected-error 2{{arithmetic on pointer to function type}} + v = 0 ? NULL + e : e + NULL; // expected-error 2{{arithmetic on pointer to function type 'void (*)()'}} v = 0 ? NULL + f : f + NULL; // expected-warning 2{{use of NULL in arithmetic operation}} v = 0 ? NULL + "f" : "f" + NULL; // expected-warning 2{{use of NULL in arithmetic operation}} |