1 // { dg-do compile { target c++11 } }
2 
3 int a;
4 int *b = __builtin_launder ();		// { dg-error "wrong number of arguments to" }
5 int *c = __builtin_launder (&a, 2);	// { dg-error "wrong number of arguments to" }
6 int *d = __builtin_launder (&a);
7 int e = __builtin_launder (a);		// { dg-error "non-pointer argument to" }
8 int &f = a;
9 int g = __builtin_launder (f);		// { dg-error "non-pointer argument to" }
10 
f1(T x)11 template <typename T> T f1 (T x) { return __builtin_launder (x); }	// { dg-error "non-pointer argument to" }
f2(T x)12 template <typename T> T f2 (T x) { return __builtin_launder (x); }
13 
14 int h = f1 (a);
15 int *i = f2 (&a);
16 struct S { long s; int foo (); } *j;
17 S *k = f2 (j);
18 int l = __builtin_launder (j)->foo ();
19 
f3(T * x)20 template <typename T> T *f3 (T *x) { return __builtin_launder (x); }
21 
22 long *m;
23 long *n = f3 (m);
24 int *o = f3 (&a);
25 
f4(U...x)26 template <typename T, typename... U> T *f4 (U... x) { return __builtin_launder (x...); }
f5(U...x)27 template <typename T, typename... U> T *f5 (U... x) { return __builtin_launder (x...); }	// { dg-error "wrong number of arguments to" }
f6(U...x)28 template <typename T, typename... U> T *f6 (U... x) { return __builtin_launder (x...); }	// { dg-error "wrong number of arguments to" }
f7(T x,U...y)29 template <typename T, typename... U> T f7 (T x, U... y) { return __builtin_launder (x, y...); }	// { dg-error "wrong number of arguments to" }
30 
31 long *p = f4<long, long *> (m);
32 long *q = f5<long> ();
33 long *r = f6<long, long *, int> (m, 1);
34 S s;
35 int t = __builtin_launder (&s)->foo ();
36 
f8(const int * x)37 constexpr const int *f8 (const int *x) { return __builtin_launder (x); }
f9(T x)38 template <typename T> constexpr T f9 (T x) { return __builtin_launder (x); }
39 constexpr int u = 6;
40 constexpr const int *v = f8 (&u);
41 constexpr const int *w = f9 (&u);
42 static_assert (*f8 (&u) == 6 && *f9 (&u) == 6, "");
43