summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-01-04 11:26:03 +0100
committerTyge Løvset <[email protected]>2022-01-04 11:26:03 +0100
commitc8c82d3a333201010b1c0cf8aad804e721aec94e (patch)
tree97afc21ec53039a5cf6787e11d199e1494554a6d
parent50ff8efaadeaa5803ec52142409d2f830f6f6b7a (diff)
downloadSTC-modified-c8c82d3a333201010b1c0cf8aad804e721aec94e.tar.gz
STC-modified-c8c82d3a333201010b1c0cf8aad804e721aec94e.zip
Removed two more false positive gcc -O2 warnings. Improved c_forpair macro. Updated checkauto.ll.
-rw-r--r--checkauto.ll4
-rw-r--r--include/stc/ccommon.h6
-rw-r--r--include/stc/cdeq.h6
-rw-r--r--include/stc/cvec.h6
4 files changed, 14 insertions, 8 deletions
diff --git a/checkauto.ll b/checkauto.ll
index 1a108076..5b4a9c68 100644
--- a/checkauto.ll
+++ b/checkauto.ll
@@ -27,11 +27,12 @@ STR \"([^"\\]|\\.)*\"
<cmt>. ;
^[ \t]*#.*\\\n { ++yylineno; BEGIN(prep); }
<prep>.*\\\n ++yylineno;
-<prep>.*\n { ++yylineno; BEGIN(INITIAL); }
+<prep>.* BEGIN(INITIAL);
^[ \t]*#.* ;
{STR} ;
'\\?.' ;
c_foreach |
+c_forpair |
c_forrange |
for |
while |
@@ -129,6 +130,7 @@ int main(int argc, char **argv)
fclose(yyin);
}
+
if (errors + warnings)
printf("%d error%s, %d warning%s.\n", errors, errors == 1? "":"s",
warnings, warnings == 1? "":"s");
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index e21589ea..dd2401a9 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -148,9 +148,9 @@ STC_INLINE uint64_t c_hash64(const void* key, size_t len) {
; it.ref != it##_end_.ref; C##_next(&it))
#define c_forpair(key, val, C, cnt) /* structured binding */ \
- for (struct {C##_iter _it, _end; C##_key key; C##_mapped val;} \
- _ = {C##_begin(&cnt), C##_end(&cnt)} \
- ; _._it.ref != _._end.ref && (_.key = _._it.ref->first, _.val = _._it.ref->second, true) \
+ for (struct {C##_iter _it; C##_value* _endref; C##_key key; C##_mapped val;} \
+ _ = {C##_begin(&cnt), C##_end(&cnt).ref} \
+ ; _._it.ref != _._endref && (_.key = _._it.ref->first, _.val = _._it.ref->second, true) \
; C##_next(&_._it))
#define c_forrange(...) c_MACRO_OVERLOAD(c_forrange, __VA_ARGS__)
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h
index 74662043..fb4f4ffb 100644
--- a/include/stc/cdeq.h
+++ b/include/stc/cdeq.h
@@ -249,9 +249,11 @@ _cx_memb(_shrink_to_fit)(_cx_self *self) {
STC_DEF void
_cx_memb(_drop)(_cx_self* self) {
+ struct cdeq_rep* rep = cdeq_rep_(self);
+ // second test to supress gcc -O2 warn: -Wfree-nonheap-object
+ if (rep->cap == 0 || rep == &_cdeq_sentinel) return;
_cx_memb(_clear)(self);
- if (cdeq_rep_(self)->cap)
- c_free(cdeq_rep_(self));
+ c_free(rep);
}
STC_DEF size_t
diff --git a/include/stc/cvec.h b/include/stc/cvec.h
index ec2db626..9da2ba56 100644
--- a/include/stc/cvec.h
+++ b/include/stc/cvec.h
@@ -254,9 +254,11 @@ _cx_memb(_clear)(_cx_self* self) {
STC_DEF void
_cx_memb(_drop)(_cx_self* self) {
- if (!cvec_rep_(self)->cap) return;
+ struct cvec_rep* rep = cvec_rep_(self);
+ // second test to supress gcc -O2 warn: -Wfree-nonheap-object
+ if (rep->cap == 0 || rep == &_cvec_sentinel) return;
_cx_memb(_clear)(self);
- c_free(cvec_rep_(self));
+ c_free(rep);
}
STC_DEF bool