diff options
| author | Nicolai Stange <nicstange@gmail.com> | 2016-02-01 03:31:47 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-03-31 02:14:10 +0200 |
| commit | 1b62f0f61f38d8f6881c6ee14da2f9137bd68fc7 (patch) | |
| tree | 2f2596bbdfd95512d57ae0da2dc3c7acc51f9f73 /validation | |
| parent | 2919ca4cd57c4633bccf26b01cb2b8c00271446d (diff) | |
| download | sparse-dev-1b62f0f61f38d8f6881c6ee14da2f9137bd68fc7.tar.gz | |
constexpr: examine constness of casts at evaluation only
Move the whole calculation of cast expressions' constness flags to the
evaluation phase such that expressions like
(int)__builtin_choose_expr(0, 0, 0)
can now be recognized as qualifying as integer constant expressions.
Signed-off-by: Nicolai Stange <nicstange@gmail.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/constexpr-cast.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/validation/constexpr-cast.c b/validation/constexpr-cast.c new file mode 100644 index 00000000..27069614 --- /dev/null +++ b/validation/constexpr-cast.c @@ -0,0 +1,25 @@ +static int a[] = { + [(int)0] = 0, // OK + [(int)(int)0] = 0, // OK + [(int)0.] = 0, // OK + [(int)(int)0.] = 0, // OK + [(int)__builtin_choose_expr(0, 0, 0)] = 0, // OK + [(int)__builtin_choose_expr(0, 0, 0.)] = 0, // OK + + [(int)(float)0] = 0, // KO + [(int)(float)0.] = 0, // KO + + [(int)(void*)0] = 0, // KO + [(int)(void*)0.] = 0, // KO + +}; +/* + * check-name: Expression constness propagation in casts + * + * check-error-start +constexpr-cast.c:9:11: error: bad integer constant expression +constexpr-cast.c:10:11: error: bad integer constant expression +constexpr-cast.c:12:11: error: bad integer constant expression +constexpr-cast.c:13:11: error: bad integer constant expression + * check-error-end + */ |
