diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/expr/unary2.C')
-rw-r--r-- | gcc/testsuite/g++.dg/expr/unary2.C | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/expr/unary2.C b/gcc/testsuite/g++.dg/expr/unary2.C new file mode 100644 index 00000000000..9d6acc84488 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/unary2.C @@ -0,0 +1,20 @@ +// { dg-do compile } +// Unary plus/minus are not lvalues. + +// In templates we require an instantiation to emit the diagnostic. This +// is wrong and it is PR 18474. + +int n; + +void f(void) +{ + -n = 0; // { dg-error "non-lvalue" } + +n = 0; // { dg-error "non-lvalue" } +} + +template <int> +void g(void) +{ + -n = 0; // { dg-error "non-lvalue" "" { xfail *-*-* } } + +n = 0; // { dg-error "non-lvalue" "" { xfail *-*-* } } +} |