-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathattributes.cpp
32 lines (23 loc) · 851 Bytes
/
attributes.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
# Attributes
C++11 introduces a generalized attribute syntax.
Similar syntaxes have been rmplemented as extensions for a long time in GCC via `__attribtes__`
and in Microsoft with `#pragma`. Now some have been standardized!
Intended only for functions which don't change behaviour: only to help
compilers optimize or geneate better error messages.
http://www.stroustrup.com/C++11FAQ.html#attributes
Attributes can be defined for various objects, and there are 2 standard ones:
`noreturn` and `carries_dependency`
C11 also has some attributes like `_Noreturn`, but no generalized syntax.
*/
#include "common.hpp"
#if __cplusplus >= 201103L
void noreturn_func [[ noreturn ]] () { throw 1; }
#endif
int main() {
#if __cplusplus >= 201103L
try {
noreturn_func();
} catch (int i) {}
#endif
}