diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-02 02:14:45 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-02 02:14:45 +0000 |
commit | c084bd2888153084cf8bc8c0337a88cf2ab53e8c (patch) | |
tree | 7a0da883040e315449c4c1c6c25f5d26b0dc660d /clang/test/Sema/expr-address-of.c | |
parent | 4be2c3692112a841f1baf606bf4fcfaff163c2cb (diff) | |
download | bcm5719-llvm-c084bd2888153084cf8bc8c0337a88cf2ab53e8c.tar.gz bcm5719-llvm-c084bd2888153084cf8bc8c0337a88cf2ab53e8c.zip |
PR15132: Replace "address expression must be an lvalue or a function
designator" diagnostic with more correct and more human-friendly "cannot take
address of rvalue of type 'T'".
For the case of & &T::f, provide a custom diagnostic, rather than unhelpfully
saying "cannot take address of rvalue of type '<overloaded function type>'".
For the case of &array_temporary, treat it just like a class temporary
(including allowing it as an extension); the existing diagnostic wording
for the class temporary case works fine.
llvm-svn: 174262
Diffstat (limited to 'clang/test/Sema/expr-address-of.c')
-rw-r--r-- | clang/test/Sema/expr-address-of.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/clang/test/Sema/expr-address-of.c b/clang/test/Sema/expr-address-of.c index 2b8cfbfa68f..32bd0dfdd5b 100644 --- a/clang/test/Sema/expr-address-of.c +++ b/clang/test/Sema/expr-address-of.c @@ -90,8 +90,8 @@ void f5() { lvalue we would need to give a warning. Note that gcc warns about this as a register before it warns about it as an invalid lvalue. */ - int *_dummy0 = &(int*) arr; // expected-error {{address expression must be an lvalue or a function designator}} - int *_dummy1 = &(arr + 1); // expected-error {{address expression must be an lvalue or a function designator}} + int *_dummy0 = &(int*) arr; // expected-error {{cannot take the address of an rvalue}} + int *_dummy1 = &(arr + 1); // expected-error {{cannot take the address of an rvalue}} } void f6(register int x) { @@ -109,12 +109,12 @@ char* f7() { } void f8() { - void *dummy0 = &f8(); // expected-error {{address expression must be an lvalue or a function designator}} + void *dummy0 = &f8(); // expected-error {{cannot take the address of an rvalue of type 'void'}} extern void v; - void *dummy1 = &(1 ? v : f8()); // expected-error {{address expression must be an lvalue or a function designator}} + void *dummy1 = &(1 ? v : f8()); // expected-error {{cannot take the address of an rvalue of type 'void'}} - void *dummy2 = &(f8(), v); // expected-error {{address expression must be an lvalue or a function designator}} + void *dummy2 = &(f8(), v); // expected-error {{cannot take the address of an rvalue of type 'void'}} - void *dummy3 = &({ ; }); // expected-error {{address expression must be an lvalue or a function designator}} + void *dummy3 = &({ ; }); // expected-error {{cannot take the address of an rvalue of type 'void'}} } |