File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed
common/src/codingstandards/cpp Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 13
13
14
14
import cpp
15
15
import codingstandards.cpp.autosar
16
+ import codingstandards.cpp.Operator
16
17
17
- from Operator o
18
- where
19
- not isExcluded ( o , OperatorsPackage:: unaryOperatorOverloadedQuery ( ) ) and
20
- o .hasName ( "operator&" ) and
21
- (
22
- if o instanceof MemberFunction
23
- then o .getNumberOfParameters ( ) = 0
24
- else o .getNumberOfParameters ( ) = 1
25
- )
18
+ from UnaryAddressOfOperator o
19
+ where not isExcluded ( o , OperatorsPackage:: unaryOperatorOverloadedQuery ( ) )
26
20
select o , "The unary & operator overloaded."
Original file line number Diff line number Diff line change @@ -264,3 +264,19 @@ class UserOverloadedOperator extends Function {
264
264
not this .isCompilerGenerated ( )
265
265
}
266
266
}
267
+
268
+ /** A user defined operator address of operator (`&`). */
269
+ class UnaryAddressOfOperator extends Operator {
270
+ UnaryAddressOfOperator ( ) {
271
+ hasName ( "operator&" ) and
272
+ (
273
+ // If this is a member function, it needs to have zero arguments to be the unary addressof
274
+ // operator
275
+ if this instanceof MemberFunction
276
+ then getNumberOfParameters ( ) = 0
277
+ else
278
+ // Otherwise it needs one argument to be unary
279
+ getNumberOfParameters ( ) = 1
280
+ )
281
+ }
282
+ }
You can’t perform that action at this time.
0 commit comments