@@ -20,6 +20,11 @@ import cpp
20
20
import codingstandards.cpp.autosar
21
21
import codingstandards.cpp.Typehelpers
22
22
23
+ predicate isNonTemplateObjectVariable ( GlobalOrNamespaceVariable gv ) {
24
+ not gv .isFromTemplateInstantiation ( _) and
25
+ not gv .isFromUninstantiatedTemplate ( _)
26
+ }
27
+
23
28
from VariableDeclarationEntry decl1 , VariableDeclarationEntry decl2
24
29
where
25
30
not isExcluded ( decl1 , DeclarationsPackage:: declarationsOfAnObjectShallHaveCompatibleTypesQuery ( ) ) and
28
33
// Note that normally `VariableDeclarationEntry` includes parameters, which are not covered
29
34
// by this query. We implicitly exclude them with the `getQualifiedName()` predicate.
30
35
decl1 .getVariable ( ) .getQualifiedName ( ) = decl2 .getVariable ( ) .getQualifiedName ( ) and
31
- // The underlying Variable shouldn't be from a TemplateVariable or a template instantiation
32
- not exists ( Variable v |
33
- v = decl1 .getVariable ( )
34
- or
35
- v = decl2 .getVariable ( )
36
- |
37
- v instanceof TemplateVariable
38
- or
39
- v .isFromTemplateInstantiation ( _)
40
- )
36
+ // Only consider global/namespace variables which aren't templated
37
+ isNonTemplateObjectVariable ( decl1 .getVariable ( ) ) and
38
+ isNonTemplateObjectVariable ( decl2 .getVariable ( ) )
41
39
select decl1 ,
42
40
"The object $@ of type " + decl1 .getType ( ) .toString ( ) +
43
41
" is not compatible with re-declaration $@ of type " + decl2 .getType ( ) .toString ( ) , decl1 ,
0 commit comments