1 // PR c++/89513
2 // { dg-do compile { target c++14 } }
3 // { dg-options "" }
4
foo()5 constexpr int foo ()
6 try { // { dg-warning "function-try-block body of 'constexpr' function only available with" "" { target c++17_down } }
7 int a; // { dg-error "uninitialized variable 'a' in 'constexpr' function" "" { target c++17_down } }
8 static double b = 1.0;// { dg-error "'b' declared 'static' in 'constexpr' function" }
9 goto l; // { dg-error "'goto' in 'constexpr' function" }
10 l:;
11 return 0;
12 } catch (...) {
13 long int c; // { dg-error "uninitialized variable 'c' in 'constexpr' function" "" { target c++17_down } }
14 static float d = 2.0f;// { dg-error "'d' declared 'static' in 'constexpr' function" }
15 goto l2; // { dg-error "'goto' in 'constexpr' function" }
16 l2:;
17 return -1;
18 }
19
bar()20 constexpr int bar ()
21 {
22 int a; // { dg-error "uninitialized variable 'a' in 'constexpr' function" "" { target c++17_down } }
23 static long double b = 3.0;// { dg-error "'b' declared 'static' in 'constexpr' function" }
24 goto l; // { dg-error "'goto' in 'constexpr' function" }
25 l:;
26 try { // { dg-warning "'try' in 'constexpr' function only available with" "" { target c++17_down } }
27 short c; // { dg-error "uninitialized variable 'c' in 'constexpr' function" "" { target c++17_down } }
28 static float d; // { dg-error "'d' declared 'static' in 'constexpr' function" }
29 // { dg-error "uninitialized variable 'd' in 'constexpr' function" "" { target c++17_down } .-1 }
30 goto l2; // { dg-error "'goto' in 'constexpr' function" }
31 l2:;
32 return 0;
33 } catch (int) {
34 char e; // { dg-error "uninitialized variable 'e' in 'constexpr' function" "" { target c++17_down } }
35 static int f = 5; // { dg-error "'f' declared 'static' in 'constexpr' function" }
36 goto l3; // { dg-error "'goto' in 'constexpr' function" }
37 l3:;
38 return 1;
39 }
40 }
41