File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 1+ - ` A7-1-2 ` - ` VariableMissingConstexpr.ql ` :
2+ - Remove false positives for compiler generated variables
3+ - Remove results in uninstantiated templates that cause false positives
Original file line number Diff line number Diff line change 6262 // Not assigned by a user in a constructor
6363 not exists ( ConstructorFieldInit cfi | cfi .getTarget ( ) = v and not cfi .isCompilerGenerated ( ) ) and
6464 // Ignore union members
65- not v .getDeclaringType ( ) instanceof Union
65+ not v .getDeclaringType ( ) instanceof Union and
66+ // Exclude variables in uninstantiated templates, as they may be incomplete
67+ not v .isFromUninstantiatedTemplate ( _) and
68+ // Exclude compiler generated variables, which are not user controllable
69+ not v .isCompilerGenerated ( )
6670select v , "Variable " + v .getName ( ) + " could be marked 'constexpr'."
Original file line number Diff line number Diff line change @@ -264,4 +264,16 @@ constexpr void fp_reported_in_466(int p) {
264264 // compile time constant
265265 int l26 =
266266 add4 (1 , l3); // COMPLIANT - l3 is not compile time constant on all paths
267+ }
268+
269+ template <typename T> T* init (T** t) { }
270+
271+ template <typename T> T* init () {
272+ T* t = nullptr ; // COMPLIANT - initialized below
273+ init (&t); // Init is ignored in uninitialized template
274+ return t;
275+ }
276+
277+ void test_template_instantiation () {
278+ int * t = init<int >();
267279}
You can’t perform that action at this time.
0 commit comments