1 #include <string>
2 #include <memory>
3
4 namespace n01
5 {
6 class c01
7 {
8 };
9
10 namespace n02
11 {
12 typedef unsigned int type01;
13
14 // These declarations are required by C++ standard for the ones below to compile properly
15 auto f06(n01::c01 && f06a01) -> type01 *;
16 auto p06(n01::c01 && p06a01) -> type01 *;
17 }
18 };
19
20 // Valid function prototypes
21 int p01(int p01a01,int p01a02);
22 unsigned short int * p02(unsigned int & p02a01,...);
23 auto p03(const int & p03a01,void * p03a02) -> const int &;
24 auto p04() -> int (*)(int);
25 static std::string p05(const int *** p05a01);
26 auto n01::n02::p06(n01::c01 && p06a01) -> n01::n02::type01 *;
27 unsigned int p07(int (*p07a01)(int * x1,int x2),...);
28 void (*p08(void (*)(int *p08a01)))(int *);
29
30 // Valid function declarations
f01(int f01a01,int f01a02)31 int f01(int f01a01,int f01a02)
32 {
33 return 0;
34 }
35
f02(unsigned int & f02a01,...)36 unsigned short int * f02(unsigned int & f02a01,...)
37 {
38 return 0;
39 }
40
f03(const int & f03a01,void * f03a02)41 auto f03(const int & f03a01,void * f03a02) -> const int &
42 {
43 return 0;
44 }
45
f04()46 auto f04() -> int (*)(int)
47 {
48 return 0;
49 }
50
f05(const int *** f05a01)51 static inline std::string f05(const int *** f05a01)
52 {
53 return std::string();
54 }
55
f06(n01::c01 && f06a01)56 auto n01::n02::f06(n01::c01 && f06a01) -> n01::n02::type01 *
57 {
58 return 0;
59 }
60
f07(int (* f07a01)(int * x1,int x2),...)61 unsigned int f07(int (*f07a01)(int * x1,int x2),...)
62 {
63 return 0;
64 }
65
f08(void (*)(int * f08a01))66 void (*f08(void (*)(int *f08a01)))(int *)
67 {
68 return 0;
69 }
70
f09(char * ((* f09a01)()))71 int f09(char *((*f09a01)()))
72 {
73 return 0;
74 }
75
f10(int f10a01,int f10a02[],int f10a03[2][3],int (f10a04)[],int (f10a05)[][5])76 int f10(int f10a01,int f10a02[],int f10a03[2][3],int (f10a04)[],int (f10a05)[][5])
77 {
78 return 0;
79 }
80
81 // Valid function templates
t01(T && t01a01)82 template <typename T> std::unique_ptr<T> t01(T && t01a01)
83 {
84 return std::unique_ptr<T>(NULL);
85 }
86
87 #define MACRO_TEXT ""
88
t02(T && t02a01)89 template <typename T> auto t02(T && t02a01) -> std::unique_ptr<T>
90 {
91 // throw may look like a prototype, but it isn't
92 throw std::string(MACRO_TEXT);
93 return std::unique_ptr<T>(NULL);
94 }
95
96 // Things that might look similar to function prototypes but are NOT function prototypes (but still valid C++)
97 std::string x01("test");
98
99 #if NOTVALIDCPP
100 // This is not really valid C++ because it appears in the wrong context.
101 // However we simulate the parser being wrong about the current state (it happens).
102 // This should be NOT marked as a prototype even if found out of a function.
103 throw std::string(MACRO_TEXT);
104 #endif
105