Merge branch 'master' into cpp340a

This commit is contained in:
Ziemowit Laski
2019-04-03 17:52:46 -07:00
76 changed files with 745 additions and 308 deletions

View File

@@ -81,3 +81,29 @@ void test7(int x, int cond) {
}
end:
}
#define CONFIG_DEFINE
void test8() {
int x = 0;
#ifdef CONFIG_DEFINE
goto skip; // GOOD (the `x++` is still reachable in some configurations)
#endif
x++;
skip:
}
void test9() {
int x = 0;
#ifdef CONFIG_NOTDEFINED
goto mid;
#endif
goto end; // GOOD (the `x++` is still reachable in some configurations)
mid:
x++;
end:
}

View File

@@ -10,7 +10,8 @@
| printf1.h:44:18:44:20 | ull | This argument should be of type 'int' but is of type 'unsigned long long' |
| printf1.h:45:18:45:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:46:18:46:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:47:19:47:21 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:113:17:113:17 | d | This argument should be of type 'long double' but is of type 'double' |
| printf1.h:114:18:114:18 | d | This argument should be of type 'long double' but is of type 'double' |
| real_world.h:61:21:61:22 | & ... | This argument should be of type 'int *' but is of type 'short *' |
| real_world.h:62:22:62:23 | & ... | This argument should be of type 'short *' but is of type 'int *' |
| real_world.h:63:22:63:24 | & ... | This argument should be of type 'short *' but is of type 'unsigned int *' |

View File

@@ -44,7 +44,7 @@ void f(char *s, int i, unsigned char *us, const char *cs, signed char *ss, char
printf("%d", ull); // not ok (unsigned long long -> int)
printf("%u", ull); // not ok (unsigned long long -> unsigned int)
printf("%x", ull); // not ok (unsigned long long -> unsigned int)
printf("%Lx", ull); // not ok (unsigned long long -> unsigned int)
printf("%Lx", ull); // ok
printf("%llx", ull); // ok
}
@@ -101,3 +101,36 @@ void fun1(unsigned char* a, unsigned char* b) {
printf("%td\n", pdt); // GOOD
printf("%td\n", a-b); // GOOD
}
void extensions()
{
{
long double ld;
double d;
printf("%Lg", ld); // GOOD
printf("%llg", ld); // GOOD (nonstandard equivalent to %Lg)
printf("%Lg", d); // BAD (should be %g)
printf("%llg", d); // BAD (should be %g)
}
{
long long int lli;
long int li;
printf("%lld", lli); // GOOD
printf("%Ld", lli); // GOOD (nonstandard equivalent to %lld)
printf("%Ld", li); // BAD (should be %ld) [NOT DETECTED]
printf("%lld", li); // BAD (should be %ld) [NOT DETECTED]
}
{
unsigned long long int ulli;
unsigned long int uli;
printf("%llu", ulli); // GOOD
printf("%Lu", ulli); // GOOD (nonstandard equivalent to %llu)
printf("%Lu", uli); // BAD (should be %lu) [NOT DETECTED]
printf("%llu", uli); // BAD (should be %lu) [NOT DETECTED]
}
}

View File

@@ -10,7 +10,6 @@
| printf1.h:44:18:44:20 | ull | This argument should be of type 'int' but is of type 'unsigned long long' |
| printf1.h:45:18:45:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:46:18:46:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:47:19:47:21 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:126:18:126:19 | wc | This argument should be of type 'char *' but is of type 'wchar_t *' |
| printf1.h:127:18:127:18 | c | This argument should be of type 'wchar_t *' but is of type 'char *' |
| real_world.h:61:21:61:22 | & ... | This argument should be of type 'int *' but is of type 'short *' |

View File

@@ -44,7 +44,7 @@ void f(char *s, int i, unsigned char *us, const char *cs, signed char *ss, char
printf("%d", ull); // not ok (unsigned long long -> int)
printf("%u", ull); // not ok (unsigned long long -> unsigned int)
printf("%x", ull); // not ok (unsigned long long -> unsigned int)
printf("%Lx", ull); // not ok (unsigned long long -> unsigned int)
printf("%Lx", ull); // ok
printf("%llx", ull); // ok
}

View File

@@ -10,7 +10,6 @@
| printf1.h:44:18:44:20 | ull | This argument should be of type 'int' but is of type 'unsigned long long' |
| printf1.h:45:18:45:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:46:18:46:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:47:19:47:21 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:71:19:71:20 | st | This argument should be of type 'ssize_t' but is of type 'unsigned long long' |
| printf1.h:72:19:72:20 | ST | This argument should be of type 'ssize_t' but is of type 'unsigned long long' |
| printf1.h:73:19:73:22 | c_st | This argument should be of type 'ssize_t' but is of type 'unsigned long long' |

View File

@@ -44,7 +44,7 @@ void f(char *s, int i, unsigned char *us, const char *cs, signed char *ss, char
printf("%d", ull); // not ok (unsigned long long -> int)
printf("%u", ull); // not ok (unsigned long long -> unsigned int)
printf("%x", ull); // not ok (unsigned long long -> unsigned int)
printf("%Lx", ull); // not ok (unsigned long long -> unsigned int)
printf("%Lx", ull); // ok
printf("%llx", ull); // ok
}

View File

@@ -10,7 +10,6 @@
| printf1.h:44:18:44:20 | ull | This argument should be of type 'int' but is of type 'unsigned long long' |
| printf1.h:45:18:45:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:46:18:46:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:47:19:47:21 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:71:19:71:20 | st | This argument should be of type 'ssize_t' but is of type 'unsigned long long' |
| printf1.h:72:19:72:20 | ST | This argument should be of type 'ssize_t' but is of type 'unsigned long long' |
| printf1.h:73:19:73:22 | c_st | This argument should be of type 'ssize_t' but is of type 'unsigned long long' |

View File

@@ -44,7 +44,7 @@ void f(char *s, int i, unsigned char *us, const char *cs, signed char *ss, char
printf("%d", ull); // not ok (unsigned long long -> int)
printf("%u", ull); // not ok (unsigned long long -> unsigned int)
printf("%x", ull); // not ok (unsigned long long -> unsigned int)
printf("%Lx", ull); // not ok (unsigned long long -> unsigned int)
printf("%Lx", ull); // ok
printf("%llx", ull); // ok
}