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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.dg/] [tc1/] [dr147.C] - Blame information for rev 301

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 301 jeremybenn
// { dg-do compile }
2
// Origin: Giovanni Bajo 
3
// DR147: Naming the constructor (PR 11764)
4
 
5
namespace N1 {
6
 
7
struct A { A(); void f(); };
8
struct B: public A { B(); };
9
 
10
A::A() { }
11
B::B() { }
12
 
13
B::A ba;
14
A::A a; // { dg-error "constructor" "the injected-class-name can never be found through qualified lookup" }
15
 
16
void A::f()
17
{
18
  A::A();                       // { dg-message "::A" "c++/42415" }
19
}
20
 
21
void f()
22
{
23
  A::A a; // { dg-error "constructor" }
24
} // { dg-error "" "" { target *-*-* } 23 } error cascade
25
}
26
 
27
namespace N2 {
28
 
29
// This is nasty: if we allowed the injected-class-name to be looked as a
30
//  qualified type, then the following code would be well-formed. Basically
31
//  the last line is defining the static member (with redundant parenthesis).
32
// Instead, it should be rejected as a malformed constructor declaration.
33
 
34
template  struct A {
35
  template  A(T2);
36
  static A x;
37
};
38
template<> template <> A::A(char);
39
template<> A::A(A::x);  // { dg-error "" "this is an invalid declaration of the constructor" }
40
 
41
}
42
 
43
// But DR 318 says that in situations where a type is syntactically
44
// required, lookup finds it.
45
 
46
struct C
47
{
48
  C();
49
  typedef int T;
50
};
51
struct C::C c;
52
C::C::T t;
53
struct D: C::C
54
{
55
  D(): C::C() { }
56
};
57
 
58
// And if lookup doesn't find the injected-class-name, we aren't naming the
59
// constructor (c++/44401).
60
 
61
struct E
62
{
63
  int E;
64
};
65
 
66
int E::*p = &E::E;

powered by: WebSVN 2.1.0

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