summaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>1999-09-09 12:11:22 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>1999-09-09 12:11:22 +0000
commit520c81f4019bb1abf6c4941d37f0fbcfdb6f0c32 (patch)
tree8439a942994ee25c0a38c06155df4a4ae039a556 /gcc/testsuite
parentb1a8d4ce4e42efe59d1f80b8ef14967727333070 (diff)
downloadgcc-520c81f4019bb1abf6c4941d37f0fbcfdb6f0c32.tar.gz
* g++.old-deja/g++.other/lookup11.C: New test.
* g++.old-deja/g++.bugs/900428_01.C: Rework now we understand what is permitted and what we want. * g++.old-deja/g++.jason/rfg4.C: Rework to remove ill-formed overload use. * g++.old-deja/g++.jason/rfg5.C: Likewise git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@29234 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/g++.old-deja/g++.bugs/900428_01.C165
-rw-r--r--gcc/testsuite/g++.old-deja/g++.jason/rfg4.C3
-rw-r--r--gcc/testsuite/g++.old-deja/g++.jason/rfg5.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/overload11.C93
5 files changed, 244 insertions, 28 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ff307f8827f..c8844e50b13 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+Thu Sep 9 12:32:57 BST 1999 Nathan Sidwell <nathan@acm.org>
+
+ * g++.old-deja/g++.other/lookup11.C: New test.
+ * g++.old-deja/g++.bugs/900428_01.C: Rework now we understand
+ what is permitted and what we want.
+ * g++.old-deja/g++.jason/rfg4.C: Rework to remove ill-formed
+ overload use.
+ * g++.old-deja/g++.jason/rfg5.C: Likewise
+
Wed Sep 8 09:39:56 BST 1999 Nathan Sidwell <nathan@acm.org>
* g++.old-deja/g++.other/sizeof3.C: New test.
diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900428_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900428_01.C
index c2eb3071352..ecbda0c5167 100644
--- a/gcc/testsuite/g++.old-deja/g++.bugs/900428_01.C
+++ b/gcc/testsuite/g++.old-deja/g++.bugs/900428_01.C
@@ -10,42 +10,155 @@
// because the abstract semantics seem to require the evaluation of such
// values whether they are volatile or not.
+// [expr.static.cast/4, stmt.expr/1, expr.comma/1] show that expressions do
+// not under go lvalue to rvalue decay, unless the value is actually used.
+// This can be surprising when the object is volatile. We interpret a
+// dereference of pointer to volatile to be a read.
+
// keywords: incomplete types, evaluation, volatile qualifier
// Build don't link:
-int i;
+int *ip_fn ();
+int &ir_fn ();
+volatile int *vip_fn ();
+volatile int &vir_fn ();
+
+void int_test (int i, int *p, volatile int *vp, int &r, volatile int &vr)
+{
+ int j;
+ volatile int vj;
+
+ *p; // ok, no warning
+ (void)*p; // ok, no warning
+ (void)(i ? j : *p); // ok, no warning
+ (void)(i ? *p : j); // ok, no warning
+ (void)((void)1, *p); // ok, no warning
+
+ *vp; // ok, no warning
+ (void)*vp; // ok, no warning
+ (void)(i ? vj : *vp); // ok, no warning
+ (void)(i ? *vp : vj); // ok, no warning
+ (void)((void)1, *vp); // ok, no warning
+
+ r; // ok, no warning
+ (void)r; // ok, no warning
+ (void)(i ? j : r); // ok, no warning
+ (void)(i ? r : j); // ok, no warning
+ (void)((void)1, r); // ok, no warning
+
+ vr; // WARNING - reference not accessed
+ (void)vr; // WARNING - reference not accessed
+ (void)(i ? vj : vr); // WARNING - reference not accessed
+ (void)(i ? vr : vj); // WARNING - reference not accessed
+ (void)((void)1, vr); // WARNING - reference not accessed
+
+ *ip_fn (); // ok, no warning
+ *vip_fn (); // ok, no warning
+ ir_fn (); // ok, no warning
+ vir_fn (); // WARNING - reference not accessed
+}
-void *pv;
-volatile void *pvv;
-struct s; // ERROR - forward declaration
-extern struct s es, *ps; // ERROR - defined here
-extern volatile struct s evs, *pvs; // ERROR - defined here
+struct S;
+S *sp_fn ();
+S &sr_fn ();
+volatile S *vsp_fn ();
+volatile S &vsr_fn ();
-void pv_test ()
+void incomplete_test (int i, S *p, volatile S *vp, S &r, volatile S &vr)
{
- *pv; // ERROR - invalid void
- (i ? *pv : *pv); // ERROR - invalid void
- *pv, *pv; // ERROR - invalid void
+ extern S j;
+ extern volatile S vj;
+
+ *p; // ok, no warning
+ (void)*p; // ok, no warning
+ (void)(i ? j : *p); // ok, no warning
+ (void)(i ? *p : j); // ok, no warning
+ (void)((void)1, *p); // ok, no warning
- *pvv; // ERROR - invalid void
- (i ? *pvv : *pvv); // ERROR - invalid void
- *pvv, *pvv; // ERROR - invalid void
+ *vp; // WARNING - incomplete not accessed
+ (void)*vp; // WARNING - incomplete not accessed
+ (void)(i ? vj : *vp); // WARNING - incomplete not accessed
+ (void)(i ? *vp : vj); // WARNING - incomplete not accessed
+ (void)((void)1, *vp); // WARNING - incomplete not accessed
- es; // ERROR - incomplete
- (i ? es : es); // ERROR - undefined type
- es, es; // ERROR - incomplete
+ r; // ok, no warning
+ (void)r; // ok, no warning
+ (void)(i ? j : r); // ok, no warning
+ (void)(i ? r : j); // ok, no warning
+ (void)((void)1, r); // ok, no warning
- evs; // ERROR - incomplete
- (i ? evs : evs); // ERROR - undefined type
- evs, evs; // ERROR - incomplete
+ vr; // WARNING - reference not accessed
+ (void)vr; // WARNING - reference not accessed
+ (void)(i ? vj : vr); // WARNING - reference not accessed
+ (void)(i ? vr : vj); // WARNING - reference not accessed
+ (void)((void)1, vr); // WARNING - reference not accessed
+
+ *sp_fn (); // ok, no warning
+ *vsp_fn (); // WARNING - incomplete not accessed
+ sr_fn (); // ok, no warning
+ vsr_fn (); // WARNING - reference not accessed
+}
+
+struct T {int m;};
+T *tp_fn ();
+T &tr_fn ();
+volatile T *vtp_fn ();
+volatile T &vtr_fn ();
+
+void complete_test (int i, T *p, volatile T *vp, T &r, volatile T &vr)
+{
+ T j;
+ volatile T vj;
+
+ *p; // ok, no warning
+ (void)*p; // ok, no warning
+ (void)(i ? j : *p); // ok, no warning
+ (void)(i ? *p : j); // ok, no warning
+ (void)((void)1, *p); // ok, no warning
- *ps; // ERROR - undefined type
- (i ? *ps : *ps); // ERROR - undefined type
- *ps, *ps; // ERROR - undefined type
+ *vp; // ok, no warning
+ (void)*vp; // ok, no warning
+ (void)(i ? vj : *vp); // ok, no warning
+ (void)(i ? *vp : vj); // ok, no warning
+ (void)((void)1, *vp); // ok, no warning
- *pvs; // ERROR - undefined type
- (i ? *pvs : *pvs); // ERROR - undefined type
- *pvs, *pvs; // ERROR - undefined type
+ r; // ok, no warning
+ (void)r; // ok, no warning
+ (void)(i ? j : r); // ok, no warning
+ (void)(i ? r : j); // ok, no warning
+ (void)((void)1, r); // ok, no warning
+
+ vr; // WARNING - reference not accessed
+ (void)vr; // WARNING - reference not accessed
+ (void)(i ? vj : vr); // WARNING - reference not accessed
+ (void)(i ? vr : vj); // WARNING - reference not accessed
+ (void)((void)1, vr); // WARNING - reference not accessed
+
+ *tp_fn (); // ok, no warning
+ *vtp_fn (); // ok, no warning
+ tr_fn (); // ok, no warning
+ vtr_fn (); // ok, no warningWARNING - reference not accessed
}
-int main () { return 0; }
+void extern_test ()
+{
+ extern S es;
+ extern volatile S ves;
+ extern T et;
+ extern volatile T vet;
+
+ extern S &esr;
+ extern volatile S &vesr;
+ extern T &etr;
+ extern volatile T &vetr;
+
+ es; // ok, no warning
+ ves; // WARNING - incomplete not accessed
+ et; // ok, no warning
+ vet; // ok, no warning
+
+ esr; // ok, no warning
+ vesr; // WARNING - incomplete not accessed
+ etr; // ok, no warning
+ vetr; // WARNING - reference not accessed
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg4.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg4.C
index 978b3634aab..1f5805531bb 100644
--- a/gcc/testsuite/g++.old-deja/g++.jason/rfg4.C
+++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg4.C
@@ -8,5 +8,6 @@ void f2(double) { }
void
test ()
{
- i ? f1 : f2; // gets bogus error - improper overloading
+ void (*ptr) (double);
+ ptr = i ? f1 : f2; // gets bogus error - improper overloading
}
diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg5.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg5.C
index 700fae36294..ca3539ba955 100644
--- a/gcc/testsuite/g++.old-deja/g++.jason/rfg5.C
+++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg5.C
@@ -6,5 +6,5 @@ int *func () { return 0; }
void
test ()
{
- *func; // gets bogus error - improper overloading
+ int *(*p)() = *func; // gets bogus error - improper overloading
}
diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload11.C b/gcc/testsuite/g++.old-deja/g++.other/overload11.C
new file mode 100644
index 00000000000..fdd83ae2207
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/overload11.C
@@ -0,0 +1,93 @@
+// Build don't link:
+
+// Copyright (C) 1999 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 5 Sep 1999 <nathan@acm.org>
+
+// [over.match] 13.3 tells us where overload resolution occurs.
+// [over.match.call] 13.3.1.1 says that in
+// (...( postfix-expression )...) (expression-list)
+// the postfix-expression must be the name of a function (amongst some other
+// choices). This means comma and conditional exprs cannot be placed there.
+// This clause is the only one I can find which bans
+// (cond ? fna : fnb) (arglist)
+// which would be a major headache to have to implement.
+// [over.over] 13.4 tells us when the use of a function name w/o arguments is
+// resolved to the address of a particular function. These are determined by
+// the context of the function name, and it does allow more complicated primary
+// expressions.
+
+// Using a naked function name is rather strange, we used to warn about it
+// (rather inconsistently), but subsequent changes broke the warning. Make
+// sure that doesn't happen again.
+
+// excess errors test - XFAIL
+
+void ovl (int); // ERROR - candidate
+void ovl (float); // ERROR - candidate
+void fn (int);
+void fna (int);
+
+int main (int argc, char **argv)
+{
+ void (*ptr) (int);
+ void (*vptr) ();
+
+ (ovl) (1); // ok
+ (&ovl) (1); // ERROR - not suitable for overload resolution
+ (ovl) (); // ERROR - no matching candidates
+ (&ovl) (); // ERROR - not suitable for overload resolution
+
+ // 13.3.1.1 indicates that the following are errors -- the primary expression
+ // is not the name of a function.
+ (0, ovl) (1); // ERROR - not suitable for overload resolution
+ (0, &ovl) (1); // ERROR - not suitable for overload resolution
+ (argc ? ovl : ovl) (1); // ERROR - not suitable for overload resolution
+ (argc ? &ovl : &ovl) (1); // ERROR - not suitable for overload resolution
+
+ (fn) (1); // ok
+ (&fn) (1); // ok (no overload resolution)
+ (0, fn) (1); // ok (no overload resolution)
+ (0, &fn) (1); // ok (no overload resolution)
+ (argc ? fna : fn) (1); // ok (no overload resolution)
+ (argc ? &fna : &fn) (1); // ok (no overload resolution)
+
+ ptr = (ovl); // ok
+ ptr = (&ovl); // ok
+ // 13.4 indicates these are ok.
+ ptr = (0, ovl); // ok
+ ptr = (0, &ovl); // ok
+ ptr = (argc ? ovl : ovl); // ok
+ ptr = (argc ? &ovl : &ovl);// ok
+
+ vptr = (ovl); // ERROR - no matching candidates
+ vptr = (&ovl); // ERROR - no matching candidates
+ vptr = (0, ovl); // ERROR - no matching candidates
+ vptr = (0, &ovl); // ERROR - no matching candidates
+ vptr = (argc ? ovl : ovl); // ERROR - no matching candidates
+ vptr = (argc ? &ovl : &ovl);// ERROR - no matching candidates
+
+ ptr = (fn);
+ ptr = (&fn);
+ ptr = (0, fn);
+ ptr = (0, &fn);
+ ptr = (argc ? fna : fn);
+ ptr = (argc ? &fna : &fn);
+
+ f; // WARNING - not a call
+ ovl; // ERROR - not suitable for overload
+ &ovl; // ERROR - not suitable for overload
+ (void)f; // ok
+ (void)ovl; // ERROR - not suitable for overload
+ (void)&ovl; // ERROR - not suitable for overload
+ static_cast<void>(f); // ok
+ static_cast<void>(ovl); // ERROR - not suitable for overload
+ static_cast<void>(&ovl); // ERROR - not suitable for overload
+ ((void)1, f); // WARNING - not a call XFAIL
+ ((void)1, ovl); // ERROR - not suitable for overload
+ ((void)1, &ovl); // ERROR - not suitable for overload
+ (void)((void)1, f); // ok
+ (void)((void)1, ovl); // ERROR - not suitable for overload
+ (void)((void)1, &ovl); // ERROR - not suitable for overload
+
+ return 0;
+}