File: constexpr-try5.C

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (40 lines) | stat: -rw-r--r-- 2,303 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// PR c++/89513
// { dg-do compile { target c++14 } }
// { dg-options "" }

constexpr int foo ()
try {			// { dg-warning "function-try-block body of 'constexpr' function only available with" "" { target c++17_down } }
  int a;		// { dg-error "uninitialized variable 'a' in 'constexpr' function" "" { target c++17_down } }
  static double b = 1.0;// { dg-error "'b' defined 'static' in 'constexpr' function only available with" "" { target c++20_down } }
  goto l;		// { dg-error "'goto' in 'constexpr' function only available with" "" { target c++20_down } }
  l:;
  return 0;
} catch (...) {
  long int c;		// { dg-error "uninitialized variable 'c' in 'constexpr' function" "" { target c++17_down } }
  static float d = 2.0f;// { dg-error "'d' defined 'static' in 'constexpr' function only available with" "" { target c++20_down } }
  goto l2;		// { dg-error "'goto' in 'constexpr' function only available with" "" { target c++20_down } }
  l2:;
  return -1;
}

constexpr int bar ()
{
  int a;		// { dg-error "uninitialized variable 'a' in 'constexpr' function" "" { target c++17_down } }
  static long double b = 3.0;// { dg-error "'b' defined 'static' in 'constexpr' function only available with" "" { target c++20_down } }
  goto l;		// { dg-error "'goto' in 'constexpr' function only available with" "" { target c++20_down } }
  l:;
  try {			// { dg-warning "'try' in 'constexpr' function only available with" "" { target c++17_down } }
    short c;		// { dg-error "uninitialized variable 'c' in 'constexpr' function" "" { target c++17_down } }
    static float d;	// { dg-error "'d' defined 'static' in 'constexpr' function only available with" "" { target c++20_down } }
			// { dg-error "uninitialized variable 'd' in 'constexpr' function" "" { target c++17_down } .-1 }
    goto l2;		// { dg-error "'goto' in 'constexpr' function only available with" "" { target c++20_down } }
    l2:;
    return 0;
  } catch (int) {
    char e;		// { dg-error "uninitialized variable 'e' in 'constexpr' function" "" { target c++17_down } }
    static int f = 5;	// { dg-error "'f' defined 'static' in 'constexpr' function only available with" "" { target c++20_down } }
    goto l3;		// { dg-error "'goto' in 'constexpr' function only available with" "" { target c++20_down } }
    l3:;
    return 1;
  }
}