* g++.dg/expr/unary1.C, g++.dg/expr/unary2.C: New tests.
authorGiovanni Bajo <giovannibajo@gcc.gnu.org>
Sun, 14 Nov 2004 10:58:50 +0000 (10:58 +0000)
committerGiovanni Bajo <giovannibajo@gcc.gnu.org>
Sun, 14 Nov 2004 10:58:50 +0000 (10:58 +0000)
From-SVN: r90616

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/expr/unary1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/expr/unary2.C [new file with mode: 0644]

index ef48eafaf43c5289f07dde47741482ac8b2c2def..875f084d846dc8157050301241001d831eb95458 100644 (file)
@@ -1,3 +1,7 @@
+2004-11-14  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
+
+       * g++.dg/expr/unary1.C, g++.dg/expr/unary2.C: New tests.
+
 2004-11-14  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        PR c++/17344
diff --git a/gcc/testsuite/g++.dg/expr/unary1.C b/gcc/testsuite/g++.dg/expr/unary1.C
new file mode 100644 (file)
index 0000000..4ea230f
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do compile }
+// Unary plus (but not unary minus) can be applied to pointer types
+
+void *p;
+
+void f(void)
+{
+  -p;        // { dg-error "wrong type argument" }
+  +p;
+}
+
+template <int>
+void g(void)
+{
+  -p;        // { dg-error "wrong type argument" }
+  +p;
+}
diff --git a/gcc/testsuite/g++.dg/expr/unary2.C b/gcc/testsuite/g++.dg/expr/unary2.C
new file mode 100644 (file)
index 0000000..9d6acc8
--- /dev/null
@@ -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 *-*-* } }
+}