brintos

brintos / llvm-project-archived public Read only

0
0
Text · 965 B · 97b2272 Raw
34 lines · cpp
1// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s2 3void h() {4  int i1 = 0;5  extern void h1(int x = i1);6  // expected-error@-1 {{default argument references local variable 'i1' of enclosing function}}7 8  const int i2 = 0;9  extern void h2a(int x = i2);     // ok, not odr-use10  extern void h2b(int x = i2 + 0); // ok, not odr-use11 12  const int i3 = 0;13  extern void h3(const int *x = &i3);14  // expected-error@-1 {{default argument references local variable 'i3' of enclosing function}}15 16  const int i4 = 0;17  extern void h4(int x = sizeof(i4));         // ok, not odr-use18  extern void h5(int x = decltype(i4 + 4)()); // ok, not odr-use19 20  union {21    int i5;22  };23 24  extern void h6(int = i5);25  // expected-error@-1 {{default argument references local variable '' of enclosing function}}26 27  struct S { int i; };28  auto [x] = S();29 30  extern void h7(int = x);31  // expected-error@-1 {{default argument references local variable 'x' of enclosing function}}32 33}34