// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify -Wc++20-extensions %s
// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify -Wc++17-extensions %s
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify -DEXT -Wc++17-extensions -Wc++20-extensions %s
;
S ;
S& ;
;
E ;
int ;
volatile int &;
void
volatile char &; // expected-warning {{'nodiscard' attribute only applies to functions, classes, or enumerations}}
void
// namespace PR31526
;
;
;
ReasonStruct ;
LaterReason ;
int ;
int ;
int ;
void
}
;
;
; // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute: Don't throw me away either!}}
S s;
ConvertTo; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute: Don't throw me away!}}
// AST is different in C++20 mode, pre-2017 a move ctor for ConvertTo is there
// as well, hense the constructor warning.
// expected-warning@+4 {{ignoring return value of function declared with 'nodiscard' attribute: Don't throw me away!}}
// expected-warning@+2 {{ignoring temporary created by a constructor declared with 'nodiscard' attribute: Don't throw me away!}}
s;
s; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
'c'; // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute: Don't let that S-Char go!}}
// expected-warning@+4 {{ignoring return value of function declared with 'nodiscard' attribute: Don't throw me away!}}
// expected-warning@+2 {{ignoring temporary created by a constructor declared with 'nodiscard' attribute: Don't throw me away!}}
static_cast<ConvertTo>;
static_cast<int>; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
static_cast<double>; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute: Don't throw away as a double}}
}
}; // namespace p1771
// expected-warning@5 {{use of the 'nodiscard' attribute is a C++17 extension}}
// expected-warning@9 {{use of the 'nodiscard' attribute is a C++17 extension}}
// expected-warning@12 {{use of the 'nodiscard' attribute is a C++17 extension}}
// expected-warning@13 {{use of the 'nodiscard' attribute is a C++17 extension}}
// expected-warning@29 {{use of the 'nodiscard' attribute is a C++17 extension}}
// expected-warning@65 {{use of the 'nodiscard' attribute is a C++20 extension}}
// expected-warning@67 {{use of the 'nodiscard' attribute is a C++20 extension}}
// expected-warning@71 {{use of the 'nodiscard' attribute is a C++20 extension}}
// expected-warning@73 {{use of the 'nodiscard' attribute is a C++20 extension}}
// expected-warning@74 {{use of the 'nodiscard' attribute is a C++20 extension}}
// expected-warning@84 {{use of the 'nodiscard' attribute is a C++20 extension}}
// expected-warning@86 {{use of the 'nodiscard' attribute is a C++17 extension}}
// expected-warning@87 {{use of the 'nodiscard' attribute is a C++20 extension}}
// expected-warning@91 {{use of the 'nodiscard' attribute is a C++17 extension}}
// expected-warning@92 {{use of the 'nodiscard' attribute is a C++20 extension}}
// expected-warning@95 {{use of the 'nodiscard' attribute is a C++20 extension}}