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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [constexpr-neg1.C] - Blame information for rev 715

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

Line No. Rev Author Line
1 693 jeremybenn
// Negative examples from N3092 (FCD)
2
// { dg-options -std=c++0x }
3
 
4
// OK: declaration
5
constexpr int square(int x);    // { dg-message "never defined" }
6
 
7
// error: pixel is a type
8
constexpr struct pixel {
9
  int x;
10
  int y;
11
  // OK: declaration
12
  constexpr pixel(int);
13
};                              // { dg-error "constexpr" }
14
constexpr pixel::pixel(int a)
15
// OK: definition
16
  : x(square(a)), y(square(a))  // { dg-error "square" }
17
{ }
18
 
19
// error: square not defined, so small(2) not constant (5.19), so constexpr
20
// not satisfied
21
constexpr pixel small(2);       // { dg-message "in constexpr expansion" }
22
 
23
// error: not for parameters
24
int next(constexpr int x) {     // { dg-error "parameter" }
25
  return x + 1;
26
}
27
 
28
// error: not a definition
29
extern constexpr int memsz;     // { dg-error "definition" }
30
 
31
// error: return type is void
32
constexpr void f(int x)         // { dg-error "void" }
33
{ /* ... */ }
34
// error: use of decrement
35
constexpr int prev(int x)
36
{ return --x; }                 // { dg-error "-- x" }
37
 
38
// error: body not just return expr
39
constexpr int g(int x, int n) {
40
  int r = 1;
41
  while (--n > 0) r *= x;
42
  return r;
43
} // { dg-error "body of constexpr function" }
44
 
45
class debug_flag {
46
public:
47
  explicit debug_flag(bool);
48
  constexpr bool is_on();       // { dg-error "not a literal type" } debug_flag not literal type
49
private:
50
  bool flag;
51
};
52
// OK
53
constexpr int bar(int x, int y) // { dg-error "previously defined here" }
54
{ return x + y + x*y; }
55
// ...
56
// error: redefinition of bar
57
int bar(int x, int y)           // { dg-error "redefinition" }
58
{ return x * 2 + 3 * y; }
59
 
60
struct pixel2 {    // { dg-message "no user-provided default constructor" }
61
  int x, y;
62
};
63
constexpr pixel2 ur = { 1294, 1024 };// OK
64
constexpr pixel2 origin;             // { dg-error "uninitialized const" }
65
 
66
constexpr const int* addr(const int& ir) { return &ir; } // OK
67
 
68
// error, initializer for constexpr variable not a constant
69
extern constexpr const int* tp = addr(5); // { dg-error "" }

powered by: WebSVN 2.1.0

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