aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2012-08-21 00:03:32 -0400
committerPeter Eisentraut <peter_e@gmx.net>2012-08-21 00:03:32 -0400
commit71450d7fd6c7cf7b3e38ac56e363bff6a681973c (patch)
tree172ff1ebc32be5c6c275da415625e43f39252ae4 /src/include
parentffdd5a0ee37c5ac38038aeff98328727e986d2da (diff)
downloadpostgresql-71450d7fd6c7cf7b3e38ac56e363bff6a681973c.tar.gz
postgresql-71450d7fd6c7cf7b3e38ac56e363bff6a681973c.zip
Teach compiler that ereport(>=ERROR) does not return
When elevel >= ERROR, we add an abort() call to the ereport() macro to give the compiler a hint that the ereport() expansion will not return, but the abort() isn't actually reached because the longjmp happens in errfinish(). Because the effect of ereport() varies with the elevel, we cannot use standard compiler attributes such as noreturn for this.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/utils/elog.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index 1bbfd2b958f..03298fbbaf0 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -100,11 +100,16 @@
* and have errstart insert the default text domain. Modules can either use
* ereport_domain() directly, or preferably they can override the TEXTDOMAIN
* macro.
+ *
+ * When elevel >= ERROR, we add an abort() call to give the compiler a hint
+ * that the ereport() expansion will not return, but the abort() isn't actually
+ * reached because the longjmp happens in errfinish().
*----------
*/
#define ereport_domain(elevel, domain, rest) \
(errstart(elevel, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain) ? \
- (errfinish rest) : (void) 0)
+ (errfinish rest) : (void) 0), \
+ ((elevel) >= ERROR ? abort() : (void) 0)
#define ereport(elevel, rest) \
ereport_domain(elevel, TEXTDOMAIN, rest)