aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Also check statement of label statement.Bernhard Schommer2018-04-271-1/+2
|
* Detect duplicate 'case' or 'default' statements within a 'switch'Xavier Leroy2018-04-271-0/+41
| | | | Report an error in this case.
* Record value of constant expression in C.Scase constructorXavier Leroy2018-04-276-10/+10
| | | | | | | | | | | | The Elab pass checks that the argument of 'case' is a compile-time constant expression. This commit records the value of this expression in the C.Scase AST generated by Elab, so that it can be used for further diagnostics, i.e. checking (in Elab) for duplicate cases. Note that C2C ignores the recorded value and recomputes the value of the expression using Ceval.integer_expr. This is intentional: Ceval.integer_expr is more trustworthy, as it is formally verified against the CompCert C semantics.
* Detect 'case' and 'default' outside a 'switch' statementXavier Leroy2018-04-271-1/+7
| | | | Report an error in this case.
* Additional checks on typedefs (#101)Bernhard Schommer2018-04-261-0/+4
| | | | Typedefs should have a name and also should not contain _Noreturn. Bug 23381
* Earlier, more comprehensive check for constant initializers (#88)Xavier Leroy2018-04-263-4/+99
| | | | | | | | | | | | | | | This commit checks *during elaboration* that initializers for global variables or local static variables are compile-time constants. Before this commit, some non-constant initializers were detected later in the C2C pass, but others were eliminated by the Cleanup pass before being checked, and yet others could cause the Rename pass to abort. To determine which variables are constant l-values, we leverage the recent addition of the Storage_auto storage class and base the determination on the storage class of the identifier: 'auto' or 'register' is not constant, the others are constant.
* Check for enums that have the same tag as composites (#100)Bernhard Schommer2018-04-251-1/+8
| | | | | Enum tags, struct tags and union tags share a common namespace, thus having an enum with the same tag as a struct or union is not allowed. Bug 23548
* Add diagnostic for illegal use of void (Bug 23342)Michael Schmidt2018-04-251-0/+2
|
* Initialization of anonymous bit-fields in structsXavier Leroy2018-04-252-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | For anonymous bit-fields in structs, carrier fields may be introduced which are not initialized since no default initializer are generated earlier. This cause the translation in C2C to throw an error since too few initializers are available. Example: struct s2 { int : 10; int a; int : 10; char b; int : 10; short c; int : 10; } s2 = { 42, 'a', 43 }; To work around this issue we need to generate a default inializer for every new member that does not have a translated member. Based on P#80, with more efficient algorithms. Bug 23362
* Bitfields transformation: record the fields after transformationXavier Leroy2018-04-251-4/+20
| | | | | | | | | | | | | | For each struct or union that contains bitfields, we record the list of members after transformation, where bit fields were replaced by carrier fields. Right now we do not use this information but it will come handy to fix a problem with struct initialization. Also: clear the global hash tables on entry so that multiple runs of the Bitfields transformation don't interfere with each other. There probably was no interference before because identifiers are unique enough, but this is fragile.
* Initialization of union bit fieldsXavier Leroy2018-04-253-3/+45
| | | | | | | | | | | Bit fields in unions were initialized like normal fields, causing mismatch on the name of the field. Also: added function Bitfields.carrier_field and refactored. Patch by Bernhard Schommer. Bug 23362
* Bug 23346, Bug 23406Bernhard Schommer2018-04-250-0/+0
|
* Improved handling and diagnostics for the `auto` storage class (#99)Xavier Leroy2018-04-254-26/+52
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Use "fix <name> <number>" instead of "fix <number>"Xavier Leroy2018-04-251-8/+8
| | | | The "fix <number>" tactic is deprecated in Coq 8.8.0 and triggers warnings.
* Support Coq version 8.8.0Xavier Leroy2018-04-251-3/+3
|
* Upgrade Flocq to version 2.6.1 from upstream (#71)Xavier Leroy2018-04-258-171/+423
| | | | | | | | | | | | | | | | We were previously at 2.5.2. Quoting the NEWS from upstream: Version 2.6.1: - ensured compatibility from Coq 8.4 to 8.8 Version 2.6.0: - ensured compatibility from Coq 8.4 to 8.7 - removed some hypotheses on some lemmas of Fcore_ulp - added lemmas to Fprop_plus_error - improved examples Also: in preparation for Coq 8.8, silence warning "compatibility-notation" when building Flocq, because this warning is on by default in 8.8, and Flocq triggers it a lot.
* Accept empty enum declaration after nonempty enum definition (#87)Bernhard Schommer2018-04-221-1/+1
| | | | Forward declarations of enums are not allowed in C99, however it is possible to have an empty enum declaration after the enum was defined.
* Better check for incomplete types in pointer subtraction (#92)Bernhard Schommer2018-04-201-0/+1
| | | | | | In the case of pointer subtraction both side can be pointers, for example if the difference between two array cells is calculated, so we need to check that both sides have complete types. Bug 23312
* Warn when volatile struct is assigned to a normal structBernhard Schommer2018-04-191-0/+3
| | | | | | | | | | | | | | Adds a warning when a volatile struct is assigned to another struct, that the volatile qualifier is ignored in this context. Example: ``` volatile struct S s; struct S t; t = s; // did not warn before; now it warns s = t; // did warn already ``` Bug 23489
* Function defintions: keep the attributes from previous declarations (#89)Bernhard Schommer2018-04-191-1/+3
| | | | | | | | | | | | After calling enter_or_refine for a function identifier we need to keep the combined attributes. Here is an example where it makes a difference: ``` _Noreturn void f(int x); void f(int x) { } ``` Before this commit, the `_Noreturn` on the declaration is ignored when checking the definition. Bug 23385
* Bug 23410Bernhard Schommer2018-04-110-0/+0
|
* Revert "preserve static initialized variables (#81)"Xavier Leroy2018-04-101-9/+2
| | | | | | This part of PR#81 causes problems with long double static variables in math.h. Revert to the old behavior of not including static variables unless actually referenced.
* Check for redefinition of globals and preserve static initialized variables ↵Bernhard Schommer2018-04-092-6/+33
| | | | | | | | | | | | | | | | | (#81) * Added check for redefinition of globals. Since Cleanup may remove duplicated static functions or global definitions we need to check for duplication during elaboration, not just in C2C. Bug 23410 * Do not eliminate unreferenced static variables with initializers This way all initialized variables make it to the C2C pass, where the initializers are checked for constant-ness. Bug 23410
* Reject illegal initializations of aggregates at top-level (#79)Xavier Leroy2018-04-061-1/+10
| | | | | | | Examples such as the following were accepted but are invalid ISO C: char c[4] = 42; struct S { int x, y; } = 42; This commit rejects such initializations at top-level. Bug 23372
* Define C11 conditional feature macros (#77)Bernhard Schommer2018-04-061-1/+10
| | | | | | | | These macros can be defined to indicate that variable length arrays, the _Complex type, atomics and threads are not supported. Since the _Complex type is not supported, we also need to undefine __STDC_IEC_559_COMPLEX__ Bug 23408
* Allow declaration of composites in bitfield size.Bernhard Schommer2018-04-051-11/+20
| | | | | | It is allowed to define a composite within a bitfield size expression using for example sizeof. Bug 23360
* Error for subtraction arithmetic type - pointer type (#73)Bernhard Schommer2018-04-051-3/+0
| | | | | | Substraction is only allowed for pointer - pointer, pointer - arithmetic or arithmetic - arithmetic. This also leads to a retyping error later. Bug 23357
* Bug 23327Bernhard Schommer2018-04-030-0/+0
|
* Turn delicate case of designated re-initialization into error (#70)Xavier Leroy2018-03-303-38/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider: struct P { int x, y; } struct S { struct P p; } struct P p0 = { 1,2 }; struct S s1 = { .p = p0; .p.x = 3 }; ISO C99 and recent versions of Clang initialize s1.p.y to 2, i.e. the initialization of s1.p.y to p0.y implied by ".p = p0" is kept, even though the initialization of s1.p.x to p0.x is overwritten by ".p.x = 3". GCC, old versions of Clang, and previous versions of CompCert initialize s1.p.y to the default value 0. I.e. the initialization ".p = p0" is forgotten, leaving default values for the fields of .p before ".p.x = 3" takes effect. Implementing the proper ISO C99 semantics in CompCert is difficult, owing to a mismatch between the intended semantics and the C.init representation of initializers. This commit turns the delicate case of reinitialization above (re-initializing a member of a composite that has already been initialized as a whole) into a compile-time error. We will then see if the delicate case occurs in practice and needs further attention.
* Reject casts to struct/union types (#68)Bernhard Schommer2018-03-291-3/+0
| | | | | | | | | | | The ISO C99 standard allows cast only if the type name involved is either a void type or a scalar type. For compatibility with GCC and Clang we used to support casting a struct or union to exactly the same struct or union type. That does not seem useful in practice and complicates conformance testing. This commit gets rid of this exception to the C99 rule. Bug 23310
* Don't overwrite initializer of anonymous union member. (#69)Bernhard Schommer2018-03-291-1/+1
| | | | | Instead of overwriting the initializer of the anonymous member we should just keep it. Bug 23353
* Fix 23332Bernhard Schommer2018-03-280-0/+0
|
* Change Implicit Arguments to Arguments (#225)Jasper Hugunin2018-03-285-17/+14
| | | | | | | Implicit Arguments is deprecated in Coq since 8.6 or so. Some Implicit Arguments remained in Flocq but were recently changed to Arguments. Apply the same change to our local copy of Flocq. As a positive consequence, we no longer need to suppress the deprecation warnings while compiling Flocq.
* Sizeof and _Alignof are not allowed on bit-fields (#67)Bernhard Schommer2018-03-273-1/+17
| | | | | | | Sizeof and _Alignof are not allowed on bit-fields Sizeof and _Alignof are not allowed to be applied to a expression that designates a bit-field member. Bug 23311
* Bug 23320Bernhard Schommer2018-03-270-0/+0
|
* Fix mistake in Bitfield transformation (#66)Michael Schmidt2018-03-271-2/+2
| | | Unions containing multiple bit fields were transformed incorrectly.
* Arrays should decay to pointers (#65)Bernhard Schommer2018-03-271-2/+3
| | | | | | | Arrays should decay to pointers except if they are used as operands of sizeof, _Alignof or as operand of the unary &. The "comma" sequencing operator was missing a "decay" on the type of its second argument. All other operators "decay" their operands correctly. Bug 23299 Bug 23311
* Improve error messages for anonymous bit-fields (#64)Bernhard Schommer2018-03-231-7/+10
| | | | | | If an anonymous bit-field member is declared wrong, i.e. a wrong type is used or a too large size is used the error message now prints <anonymous> instead of an empty string. Bug 23292
* Do not allow inline on main and warn for Noreturn (#63)Bernhard Schommer2018-03-231-0/+4
| | | | | | | | | | | | | | * Do not allow inline on main(). The C99 standard says that in a hosted environment inline shall not appear in a declaration of main. Bug 23274 * Added warning for _Noreturn on main(). The C11 standard does not allow any function specifier on the main function. Bug 23274
* Add newline directly on list in annot.Bernhard Schommer2018-03-132-4/+7
| | | | | | | This should avoid cluttering the assembler output with .ascii "\n" lines if the annotation ends with a string and make for a better readability. Bug 23169
* Anchor patterns to the top-level directory when appropriateXavier Leroy2018-03-131-47/+47
| | | | | | It's OK to ignore *.o in any directory, but it's safer to ignore "/ccomp" (ccomp in the top-level directory) than to ignore "ccomp" (ccomp in any directory).
* Print size argument of Init_space as Z not as int32Xavier Leroy2018-03-133-3/+3
| | | | | Init_space has an argument of type Z and it can exceed the range of a 32-bit integer. Reported by Frédéric Besson.
* Introduce more brackets for register annotation.Bernhard Schommer2018-03-121-4/+5
| | | | | | It seems necessary that the mulitplication for the high part of split registers is put into brackets. Bug 23169
* Removed deprecated lemma.Bernhard Schommer2018-03-121-1/+1
| | | | | The lemma Zquot_1_r is replaced by Z.quot_1_r in coq version > 8.3. Fix 23199
* Do not use "Require" inside sections (#224)Xavier Leroy2018-03-122-5/+2
| | | | | | This will soon be deprecated by Coq. Manual merge of pull request #224 by vbgl. Closes: #224
* Added seperator in warning msg. Bug 23179Bernhard Schommer2018-03-091-1/+1
|
* StructPassing and annotations, continuedXavier Leroy2018-03-091-9/+7
| | | | | struct/union arguments to annotations should not be transformed at top level, but the regular function calls contained within must be transformed recursively.
* Do not transfer arguments for annotations.Bernhard Schommer2018-03-091-2/+5
| | | | | | | In order to ensure that no transformation for arguments to builtin annotations are used, the original unchanged arguments are used. Bug 23179
* Add explicit interface to cparser/pre_parser_aux.mlXavier Leroy2018-03-092-5/+28
| | | | | | | This should help with parallel builds, which currently fail sometimes owing to a lack of a dependency on pre_parser_aux.cmi. Also: move documentation comments from the .ml to the .mli
* StructPassing: do not transform arguments to annotation built-insXavier Leroy2018-03-091-2/+6
| | | | | | | | | | | | Make sure struct/union arguments to __builtin_annot and related builtins are always passed by reference using the default passing mode, regardless of the ABI for passing struct/unions to "real" functions. This ensures portability of annotations across ABIs, and avoids mismatches between the annotation text and the actual number of arguments (when a struct/union argument is passed as N integer arguments). A similar special case already existed for __builtin_va_arg.