1 // RUN: %clang_cc1 -fsyntax-only -Wno-dangling-gsl -Wreturn-stack-address -verify %s 2 3 struct [[gsl::Owner(int)]] MyIntOwner { 4 MyIntOwner(); 5 int &operator*(); 6 }; 7 8 struct [[gsl::Pointer(int)]] MyIntPointer { 9 MyIntPointer(int *p = nullptr); 10 MyIntPointer(const MyIntOwner &); 11 int &operator*(); 12 MyIntOwner toOwner(); 13 }; 14 f()15int &f() { 16 int i; 17 return i; // expected-warning {{reference to stack memory associated with local variable 'i' returned}} 18 } 19 g()20MyIntPointer g() { 21 MyIntOwner o; 22 return o; // No warning, it is disabled. 23 } 24