xref: /llvm-project/clang/test/Parser/stmt-attributes.cpp (revision 06eee734c1ea9de754c1e7e8c79c0897b9e01350)
1 // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
2 
3 #if !__has_extension(statement_attributes_with_gnu_syntax)
4 #error "We should have statement attributes with GNU syntax support"
5 #endif
6 
7 template <typename T = void>
8 class __attribute__((nomerge)) A {
9   // expected-error@-1 {{'nomerge' attribute only applies to functions, statements and variables}}
10 };
11 
12 class B : public A<> {
13 public:
14   void bar();
15 };
16 
17 void bar();
18 
foo(A<> * obj)19 void foo(A<> *obj) {
20   __attribute__((nomerge)) static_cast<B *>(obj)->bar();
21   __attribute__((nomerge))[obj]() { static_cast<B *>(obj)->bar(); }
22   ();
23   __attribute__(()) try {
24     bar();
25   } catch (...) {
26   }
27 }
28