aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Cprint.ml
diff options
context:
space:
mode:
authorXavier Leroy <xavierleroy@users.noreply.github.com>2018-04-25 10:58:56 +0200
committerGitHub <noreply@github.com>2018-04-25 10:58:56 +0200
commit760e4226be66e84ac538461f76e12fb925cb204c (patch)
tree2e81d00017ed23b0a8a5d6393829d1eb35a25ac8 /cparser/Cprint.ml
parente34dc31ee4058c8df3ca92acb33fad153634792c (diff)
downloadcompcert-kvx-760e4226be66e84ac538461f76e12fb925cb204c.tar.gz
compcert-kvx-760e4226be66e84ac538461f76e12fb925cb204c.zip
Improved handling and diagnostics for the `auto` storage class (#99)
Previously, CompCert would just ignore the `auto` keyword, thus accepting incorrect top-level definitions such as ``` auto int x; auto void f(auto int x) { } ``` This commit introduces `auto` as a proper storage class (Storage_auto constructor in the C AST). It adds diagnostics for misuses of `auto`, often patterned after the existing diagnostics for misuses of `register`. Some error messages were corrected ("storage-class" -> "storage class") or made closer to those of clang. Finally, in the generated C AST and in C typing environments, block-scoped variables without an explicit storage class are recorded as Storage_auto instead of Storage_default. This is semantically correct (block-scoped variables default to `auto` behavior) and will help us distinguishing block-scoped variables from file-scoped variables in later developments.
Diffstat (limited to 'cparser/Cprint.ml')
-rw-r--r--cparser/Cprint.ml1
1 files changed, 1 insertions, 0 deletions
diff --git a/cparser/Cprint.ml b/cparser/Cprint.ml
index d623ab96..c2253c8f 100644
--- a/cparser/Cprint.ml
+++ b/cparser/Cprint.ml
@@ -361,6 +361,7 @@ let storage pp = function
| Storage_default -> ()
| Storage_extern -> fprintf pp "extern "
| Storage_static -> fprintf pp "static "
+ | Storage_auto -> () (* used only in blocks, where it can be omitted *)
| Storage_register -> fprintf pp "register "
let full_decl pp (sto, id, ty, int) =