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 1313
1414import cpp
1515import codingstandards.cpp.autosar
16+ import codingstandards.cpp.Operator
1617
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 ( ) )
2620select o , "The unary & operator overloaded."
Original file line number Diff line number Diff line change @@ -264,3 +264,19 @@ class UserOverloadedOperator extends Function {
264264 not this .isCompilerGenerated ( )
265265 }
266266}
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