@@ -56,71 +56,17 @@ class MemberConstExpr {
5656int m3 =0 ;// COMPLIANT - can be set by constructor
5757};
5858
59- int h1 (int x,int y) {// NON_COMPLIANT
60- return x + y;
61- }
62-
63- constexpr int h1_correct (int x,int y) {// COMPLIANT
64- return x + y;
65- }
66-
67- int h2 (int x) {return h1 (x,1 ) +1 ; }// NON_COMPLIANT
68- constexpr int h2_correct (int x) {return h1_correct (x,1 ) +1 ; }// COMPLIANT
69-
70- int h3 (int x) {// COMPLIANT - uses goto, so can't be constexpr
71- if (x) {
72- goto l1;
73- }else {
74- return 10 ;
75- }
76- l1:
77- return 1 ;
78- }
79-
80- int h4 (int x) {// COMPLIANT - uses try, so can't be constexpr
81- try {
82- return 1 ;
83- }catch (...) {
84- }
85- }
86-
87- int h5 (int x) {// COMPLIANT - declares non literal local var
88- NonLiteralClass nlc;
89- }
90-
91- int h6 (int x) {// COMPLIANT - declares static variable
92- static int i = x;
93- return x;
94- }
95-
96- int h7 (int x) {// COMPLIANT - declares no init variable
97- int i;
98- }
59+ int h1 (int x,int y) {return x + y; }
9960
100- int h8 (int x) {// NON_COMPLIANT - could be constexpr
101- int i = x;
102- return i;
103- }
61+ constexpr int h1_const (int x,int y) {return x + y; }
10462
105- constexpr int h8_correct (int x) {// COMPLIANT
106- int i = x;
107- return i;
63+ int h2 () {
64+ int x1 =h1 (1 ,1 );// COMPLIANT
65+ int x2 =h1_const (1 ,1 );// NON_COMPLIANT
66+ const int x3 =h1_const (1 ,1 );// NON_COMPLIANT
67+ constexpr int x4 =h1_const (1 ,1 );// COMPLIANT
10868}
10969
110- int h9 (int x) {// COMPLIANT - declares thread local variable
111- thread_local int i = x;
112- return x;
113- }
114-
115- class ConstexprFunctionClass {
116- public:
117- int mf1 (int x) {return m1 + x; }// NON_COMPLIANT
118- constexpr int mf1_correct (int x) {return m1 + x; }// COMPLIANT
119-
120- private:
121- int m1;
122- };
123-
12470class MissingConstexprClass {
12571public:
12672MissingConstexprClass () =default ;// NON_COMPLIANT
@@ -130,82 +76,6 @@ class MissingConstexprClass {
13076int m1 =0 ;// NON_COMPLIANT
13177};
13278
133- class VirtualBaseClass {};
134-
135- class DerivedClass :public virtual VirtualBaseClass {
136- public:
137- DerivedClass () =default ;// COMPLIANT
138- DerivedClass (int i) =delete ;// COMPLIANT
139- DerivedClass (int i, LiteralClass lc) {}// COMPLIANT
140- private:
141- int m1 =0 ;// NON_COMPLIANT
142- };
143-
144- class NotAllMembersInitializedClass {
145- public:
146- NotAllMembersInitializedClass () =default ;// COMPLIANT
147- NotAllMembersInitializedClass (int i) =delete ;// COMPLIANT
148- NotAllMembersInitializedClass (int i, LiteralClass lc) {}// COMPLIANT
149- private:
150- int m1;
151- };
152-
153- class NonLiteralParamsClass {
154- public:
155- NonLiteralParamsClass (int i, NonLiteralClass lc) {}// COMPLIANT
156- };
157-
158- // Variant members are always initialized, so this can be marked constexpr
159- class VariantMemberInitialized {
160- public:
161- VariantMemberInitialized () =default ;// NON_COMPLIANT
162- VariantMemberInitialized (int i) =delete ;// NON_COMPLIANT
163- VariantMemberInitialized (int i, LiteralClass lc) {}// NON_COMPLIANT
164- private:
165- union {
166- int i =0 ;
167- short s;
168- };
169- };
170-
171- class VariantMemberInitConstexpr {
172- public:
173- constexpr VariantMemberInitConstexpr () = default;// COMPLIANT
174- constexpr VariantMemberInitConstexpr (int i) = delete;// COMPLIANT
175- constexpr VariantMemberInitConstexpr (int i, LiteralClass lc) {}// COMPLIANT
176- private:
177- union {
178- int i =0 ;
179- short s;
180- };
181- };
182-
183- // Variant members are not initialized at declaration, so we can only mark the
184- // constructors as constexpr if we explicitly initialize the variant member
185- class VariantMemberNotInit {
186- public:
187- VariantMemberNotInit () =default ;// COMPLIANT
188- VariantMemberNotInit (int pi) =delete ;// COMPLIANT
189- VariantMemberNotInit (int pi, LiteralClass lc) {}// COMPLIANT
190- VariantMemberNotInit (LiteralClass lc,int pi) : i(pi) {}// NON_COMPLIANT
191- constexpr VariantMemberNotInit (LiteralClass lc,short pi)// COMPLIANT
192- : i(pi) {}
193-
194- private:
195- union {
196- int i;
197- short s;
198- };
199- };
200-
201- class ExcludedCases {
202- public:
203- ~ExcludedCases () {}// COMPLIANT
204-
205- void operator =(ExcludedCases &) {}// COMPLIANT
206- void operator =(ExcludedCases &&) {}// COMPLIANT
207- };
208-
20979extern int random ();
21080constexpr int add (int x,int y) {return x + y; }
21181// Example with compile time constant literal value as default argument