2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.law / cvt12.C
blobd35a996e09abf65ec52c6a28c4973b1dad5475c1
1 // { dg-do run  }
2 // GROUPS passed conversions
3 // cvt file
4 // Message-Id: <9301071708.AA03432@muresh.et.tudelft.nl>
5 // From: stravers@muresh.et.tudelft.nl (Paul Stravers)
6 // Subject: conversion method never called
7 // Date: Thu, 7 Jan 93 18:08:33 +0100
9 #include <stdio.h>
11 class test
13    double d;
14    int    i;
15 public:
16    test(double dd,int ii) {d=dd; i=ii;} // constructor
17    operator int&()        {return i;} // define a conversion from test to int&
18    int& geti()            {return i;} // same thing, but different
21 int main()
23    test t(3.14, 5);  // Create an object t of class "test"
24    int x = (int&)t;  // This should call operator int&() but it does not ...
25    int y = t.geti(); // x and y should both be 5 ...
26    if (x == 5 && y == 5)
27      printf ("PASS\n");
28    else
29      { printf ("FAIL\n"); return 1; }