Skip to content

Commit cc0372e

Browse files
committed
M14-6-1: Identify non-compilable cases
To take a pointer to a member function we need to provide a qualifier to the name. The cases in the COMPLIANT classes are therefore non-compilable. The reason some cases were not previously causing EDG to crash was that the templates weren't instantiated. We now instantiate all templates, and add explanatory comments.
1 parent a80c8b0 commit cc0372e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

cpp/autosar/test/rules/M14-6-1/test.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ class C : D {
6363
g(); // COMPLIANT - does not apply to non-class templates
6464
sg(); // COMPLIANT - does not apply to non-class templates
6565
TYPE t1 = 0; // COMPLIANT - does not apply to non-class templates
66-
// void (*p)() = &g; // NON_COMPILABLE
66+
// void (*p)() = &g; // NON_COMPILABLE - not valid to take address of member
67+
// function without qualifier
6768
}
6869
};
6970

@@ -73,6 +74,14 @@ template <typename T> class E : D {
7374
m = 0; // COMPLIANT - does not apply to non dependent base types
7475
g(); // COMPLIANT - does not apply to non dependent base types
7576
TYPE t1 = 0; // COMPLIANT - does not apply to non dependent base types
76-
// void (*p)() = &g; // NON_COMPILABLE - clang does not accept this
77+
// void (*p)() = &g; // NON_COMPILABLE - not valid to take address of member
78+
// function without qualifier
7779
}
78-
};
80+
};
81+
82+
void f2() {
83+
C c;
84+
c.m1();
85+
E<int> e;
86+
e.m1();
87+
}

0 commit comments

Comments
 (0)