OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [other/] [abstract1.C] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// { dg-do compile }
2
// Contributed by ,
3
//                ,
4
//                
5
// c++/9256: Make sure that a pointer to an array of abstract elements
6
//  cannot be created, not even during template substitution (DR337).
7
 
8
struct Abstract { virtual void f() = 0; };  // { dg-message "note" }
9
struct Complete { void f(); };
10
 
11
 
12
/*
13
 * TEST 1
14
 * Arrays of abstract elements cannot be declared.
15
 */
16
 
17
Abstract a0[2];        // { dg-error "" }
18
Abstract (*a1)[2];     // { dg-error "" }
19
Abstract (**a2)[2];    // { dg-error "" }
20
Abstract (***a3)[2];   // { dg-error "" }
21
Abstract *a4;
22
Abstract *a5[2];
23
Abstract (*a6[2])[2];  // { dg-error "" }
24
Abstract **a7[2];
25
Abstract *(*a8[2])[2];
26
Abstract (**a9[2])[2]; // { dg-error "" }
27
 
28
/*
29
 * TEST 2
30
 * If a pointer to an array of abstract elements is created during template
31
 *  instantiation, an error should occur.
32
 */
33
 
34
template  struct K {
35
  T (*a)[2];   // { dg-error "abstract class type" }
36
};
37
 
38
template struct K;  // { dg-message "required" }
39
 
40
 
41
 
42
/*
43
 * TEST 3
44
 * Deducing an array of abstract elements during type deduction is a silent
45
 *  failure (rejects overload).
46
 */
47
 
48
template  struct StaticAssert;
49
template <> struct StaticAssert {};
50
 
51
typedef char Yes;
52
typedef struct { char x[2]; } No;
53
 
54
template No  is_abstract(U (*k)[1]);
55
template Yes is_abstract(...);
56
 
57
StaticAssert(0)) == sizeof(Yes)> b1;
58
StaticAssert(0)) == sizeof(No)> b2;
59
StaticAssert(0)) == sizeof(No)> b3;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.