@@ -20,6 +20,11 @@ import cpp
2020import codingstandards.cpp.autosar
2121import codingstandards.cpp.Typehelpers
2222
23+ predicate isNonTemplateObjectVariable ( GlobalOrNamespaceVariable gv ) {
24+ not gv .isFromTemplateInstantiation ( _) and
25+ not gv .isFromUninstantiatedTemplate ( _)
26+ }
27+
2328from VariableDeclarationEntry decl1 , VariableDeclarationEntry decl2
2429where
2530 not isExcluded ( decl1 , DeclarationsPackage:: declarationsOfAnObjectShallHaveCompatibleTypesQuery ( ) ) and
2833 // Note that normally `VariableDeclarationEntry` includes parameters, which are not covered
2934 // by this query. We implicitly exclude them with the `getQualifiedName()` predicate.
3035 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 ( ) )
4139select decl1 ,
4240 "The object $@ of type " + decl1 .getType ( ) .toString ( ) +
4341 " is not compatible with re-declaration $@ of type " + decl2 .getType ( ) .toString ( ) , decl1 ,
0 commit comments