language-c 0.9.2 → 0.9.3
raw patch · 11 files changed
+376/−352 lines, 11 filesdep ~arraydep ~basedep ~bytestringnew-uploader
Dependency ranges changed: array, base, bytestring, containers, directory, filepath, mtl, process
Files
- ChangeLog +0/−173
- ChangeLog.md +192/−0
- README +0/−66
- README.md +43/−0
- language-c.cabal +120/−111
- src/Language/C/Analysis/AstAnalysis.hs +1/−0
- src/Language/C/Parser/Lexer.x +3/−1
- src/Language/C/Parser/Parser.y +5/−1
- src/Language/C/Parser/Tokens.hs +2/−0
- src/Language/C/Pretty.hs +3/−0
- src/Language/C/Syntax/AST.hs +7/−0
− ChangeLog
@@ -1,173 +0,0 @@-# Changelog--## WIP--## 0.9.2--- Add support for 128 bit builtin integer types--## 0.9.1-- - Support parsing an empty list of clobbers after a colon in `asm` statements--## 0.9.0.2-- - Correct lower bound on GHC--## 0.9.0.1-- - Scrap dependency on syb--Thanks to @vmchale--## 0.9- - Make `Trav` a monad transformer- - Add `runTravTWithTravState`- - Tests now use Cabal-3- - Implement alignment calculation and correct size calculation- - Add `Show` instance for `Type`- - Add machine descriptions for x86_64 and armv7l- - Small correction in output of prettyprinter- - Allow zeros as line numbers in preprocessed directives--Thanks to @aweinstock314, @ersran9, @expipiplus1, @jkoppel, @trofi and @visq--Changes since 0.7.0-==========================================================================--Wed May 23 07:08:02 2018 +0200- Support IEC 60559 types and literals. Closes #52.--Wed May 16 07:08:15 2018 +0200- introduce flag for optional IEC 60559 type support (see #43)--Wed May 16 06:36:04 2018 +0200- WIP: towards a complete Export (#51)--Thu Feb 22 13:22:50 2018 -0500- [syntax] GHC.Generics.Generic and Control.DeepSeq.NFData instances (#49)- (.cabal) drop splitBase flag--Tue Feb 20 08:34:39 2018 +0300- Selectively hide Prelude.<>: GHC 8.4 compat (#45)--Tue Feb 20 00:09:16 2018 -0500- (Analysis) Minimal support for __float128 (#47)--Sat Nov 25 08:59:59 2017 +0100- Consider builtin_convertvector from #34 for pretty printing--Sat Nov 25 00:46:33 2017 -0600- add support for _Float128 (#41)--Changes since 0.6.0-==========================================================================-Mon Jul 31 2017- Improve TypeCheck output (#31)--Sun Jul 30 2017- * Add `__float128` (fixes #33)--Mon Maz 22 2017- * Support clang’s __builtin_convertvector (Fixes #34)--Wed Mar 8 2017- * Move file and parent information to new datatype FilePosition for performance reasons--Changes since 0.5.0-==========================================================================-Thu Feb 23 2017- * Make gccParseCPPArgs grab the arg to -MF -MT and -MQ-Wed Feb 15 2017- * In enums, allow multiple attribute specifiers per enumerator-Tue Feb 21 2017- * Allow typedef redefinition if it denotes the same type-Tue Feb 21 2017- * Change TypeDefRef to store Type, not Maybe Type-Tue Feb 14 2017- * Parse (and ignore) Clang __attribute__((availability(id=major.minor.rev)))-Sun Sep 11 2016- * Add __builtin_bswap32/64.-Wed Jun 22 2016- * Add '_Alignof' to Lexer.x (fixes #7)-Mon Jun 27 2016- * Updates for C11 (part 1)- * _Nullable and _Nonnull support as well as Warnings/lint fixes provided by Anthony Cowley (https://github.com/acowley)-Wed Mar 16 2016- * Consider storage specifier "ThreadSpec" for global and local declarations-Tue Mar 15 2016- * Support C11 _NoReturn, genearlize is_inline to FunSpecs (Syntax) / FunAttrs (SemRep)--Changes since 0.4.3-==========================================================================-Wed Mar 2 2016- * Add direct base type BaseInt128 (complements previous __int128 patch)- ryan.gl.scott@gmail.com-Sun Feb 28 2016- * Parse gcc-specific __int128 type-Thu Dec 4 2014- * Scott Kovach <dskovach@gmail.com>: added derived Eq,Ord instances to NodeInfo--Changes since 0.4.2-==========================================================================-Sat Jan 11 2014- * Allow unicode characters in string/char literals and filenames-Mon Oct 27 2014- * macos-attributes-Tue Aug 13 2013- * Do not derive Error instances for newtypes (type parameter has non-parametric role)-Mon Aug 12 2013- * Fix bug caused by applying posFile to nopos (reported by Mikhail Sosonkin)--Changes since 0.4.1-==========================================================================-Tue Mar 19 2013- * TypeCheck: Return Left str instead of fail str (do not rely on MonadError instance of Either)- * Improve printing of SUERefs and Ident-Thu Feb 28 2013- * Fix parsing and printing of octal character escapes.-Tue Jun 12 2012- * Export Annotated type class from AST module-Wed Aug 24 2012- * Patch for alex-3.0--Changes 0.3.1 - 0.4.1-==========================================================================-Tue Aug 16 2011:- * Port to ghc-7.2-Fr April 15 2011: Alexander Bernauer <bernauer@inf.ethz.ch>- * Show instances (popular request) for AST types, DumpAst demo--Changes 0.3 - 0.3.1-==========================================================================-Thu Aug 21 benedikt.huber@gmail.com- * add aliases for exposed parsers, in order to document them--Fri Aug 15 benedikt.huber@gmail.com- * Remove NameMap from Data.Name. We will do this right when neccessary.- * Parser public API: expose parsers and the Parser Monad- * ParserMonad: Return updated name supply when executing parser- * Parser: Expose expression, statement, declaration and file parsers- * Data: Add newNameSupply ~ (namesStartingFrom 0)--Thu Aug 14 17:13:29 CEST 2008 iavor.diatchki@gmail.com- * Add a utility function to create a "blank" set of cpp arguments.- * Make that analysis traversal monad abstract.- * Export the type synonym "Register" (and bump version)--Wed Aug 13 12:00:57 CEST 2008 benedikt.huber@gmail.com- * add Data.Position: internalIdentAt---Old Changes-==========================================================================--Mon Jun 9 23:12:46 CEST 2008 benedikt.huber@gmail.com- * License switched to 3-clause BSD- $-- In accordance with the original authors, Language.C is now licensed as BSD-3.- See:- http://haskell.org/pipermail/c2hs/2008-June/000833.html- http://haskell.org/pipermail/c2hs/2008-June/000834.html- http://haskell.org/pipermail/c2hs/2008-June/000835.html-
+ ChangeLog.md view
@@ -0,0 +1,192 @@+# Changelog++## 0.9.3++- Add support for `__builtin_bit_cast` to support clang toolchain,+ enabling builds with GHC 9.4+ on Windows.++## 0.9.2++- Add support for 128 bit builtin integer types++## 0.9.1++- Support parsing an empty list of clobbers after a colon in `asm` statements++## 0.9.0.2++- Correct lower bound on GHC++## 0.9.0.1++- Scrap dependency on syb++Thanks to @vmchale++## 0.9++- Make `Trav` a monad transformer+- Add `runTravTWithTravState`+- Tests now use Cabal-3+- Implement alignment calculation and correct size calculation+- Add `Show` instance for `Type`+- Add machine descriptions for x86_64 and armv7l+- Small correction in output of prettyprinter+- Allow zeros as line numbers in preprocessed directives++Thanks to @aweinstock314, @ersran9, @expipiplus1, @jkoppel, @trofi and @visq++## Changes since 0.7.0++Wed May 23 07:08:02 2018 +0200+ * Support IEC 60559 types and literals. Closes #52.++Wed May 16 07:08:15 2018 +0200+ * introduce flag for optional IEC 60559 type support (see #43)++Wed May 16 06:36:04 2018 +0200+ * WIP: towards a complete Export (#51)++Thu Feb 22 13:22:50 2018 -0500+ * [syntax] GHC.Generics.Generic and Control.DeepSeq.NFData instances (#49)+ (.cabal) drop splitBase flag++Tue Feb 20 08:34:39 2018 +0300+ * Selectively hide Prelude.<>: GHC 8.4 compat (#45)++Tue Feb 20 00:09:16 2018 -0500+ * (Analysis) Minimal support for `__float128` (#47)++Sat Nov 25 08:59:59 2017 +0100+ * Consider builtin_convertvector from #34 for pretty printing++Sat Nov 25 00:46:33 2017 -0600+ * add support for `_Float128` (#41)++## Changes since 0.6.0++Mon Jul 31 2017+ * Improve TypeCheck output (#31)++Sun Jul 30 2017+ * Add `__float128` (fixes #33)++Mon Maz 22 2017+ * Support clang’s `__builtin_convertvector` (Fixes #34)++Wed Mar 8 2017+ * Move file and parent information to new datatype FilePosition for performance reasons++## Changes since 0.5.0++Thu Feb 23 2017+ * Make gccParseCPPArgs grab the arg to -MF -MT and -MQ++Wed Feb 15 2017+ * In enums, allow multiple attribute specifiers per enumerator++Tue Feb 21 2017+ * Allow typedef redefinition if it denotes the same type++Tue Feb 21 2017+ * Change TypeDefRef to store Type, not Maybe Type++Tue Feb 14 2017+ * Parse (and ignore) Clang __attribute__((availability(id=major.minor.rev)))++Sun Sep 11 2016+ * Add `__builtin_bswap32/64`.++Wed Jun 22 2016+ * Add `_Alignof` to Lexer.x (fixes #7)++Mon Jun 27 2016+ * Updates for C11 (part 1)+ * `_Nullable` and `_Nonnull` support as well as Warnings/lint fixes provided by Anthony Cowley (https://github.com/acowley)++Wed Mar 16 2016+ * Consider storage specifier "ThreadSpec" for global and local declarations++Tue Mar 15 2016+ * Support C11 `_NoReturn`, genearlize is_inline to FunSpecs (Syntax) / FunAttrs (SemRep)++## Changes since 0.4.3++Wed Mar 2 2016+ * Add direct base type BaseInt128 (complements previous `__int128` patch)+ ryan.gl.scott@gmail.com++Sun Feb 28 2016+ * Parse gcc-specific `__int128` type++Thu Dec 4 2014+ * Scott Kovach <dskovach@gmail.com>: added derived Eq,Ord instances to NodeInfo++## Changes since 0.4.2++Sat Jan 11 2014+ * Allow unicode characters in string/char literals and filenames++Mon Oct 27 2014+ * macos-attributes++Tue Aug 13 2013+ * Do not derive Error instances for newtypes (type parameter has non-parametric role)++Mon Aug 12 2013+ * Fix bug caused by applying posFile to nopos (reported by Mikhail Sosonkin)++## Changes since 0.4.1++Tue Mar 19 2013+ * TypeCheck: Return Left str instead of fail str (do not rely on MonadError instance of Either)+ * Improve printing of SUERefs and Ident++Thu Feb 28 2013+ * Fix parsing and printing of octal character escapes.++Tue Jun 12 2012+ * Export Annotated type class from AST module++Wed Aug 24 2012+ * Patch for alex-3.0++## Changes 0.3.1 - 0.4.1++Tue Aug 16 2011:+ * Port to ghc-7.2++Fri Apr 15 2011: Alexander Bernauer <bernauer@inf.ethz.ch>+ * Show instances (popular request) for AST types, DumpAst demo++## Changes 0.3 - 0.3.1++Thu Aug 21 benedikt.huber@gmail.com+ * add aliases for exposed parsers, in order to document them++Fri Aug 15 benedikt.huber@gmail.com+ * Remove NameMap from Data.Name. We will do this right when neccessary.+ * Parser public API: expose parsers and the Parser Monad+ * ParserMonad: Return updated name supply when executing parser+ * Parser: Expose expression, statement, declaration and file parsers+ * Data: Add newNameSupply ~ (namesStartingFrom 0)++Thu Aug 14 17:13:29 CEST 2008 iavor.diatchki@gmail.com+ * Add a utility function to create a "blank" set of cpp arguments.+ * Make that analysis traversal monad abstract.+ * Export the type synonym "Register" (and bump version)++Wed Aug 13 12:00:57 CEST 2008 benedikt.huber@gmail.com+ * add Data.Position: internalIdentAt++## Old Changes++Mon Jun 9 23:12:46 CEST 2008 benedikt.huber@gmail.com+ * License switched to 3-clause BSD+ $+- In accordance with the original authors, Language.C is now licensed as BSD-3.+ See:+ http://haskell.org/pipermail/c2hs/2008-June/000833.html+ http://haskell.org/pipermail/c2hs/2008-June/000834.html+ http://haskell.org/pipermail/c2hs/2008-June/000835.html+
− README
@@ -1,66 +0,0 @@-= Language.C =--Language.C is a parser and pretty-printer framework for C11 and the extensions of gcc.--See http://visq.github.io/language-c/--== Build and Install ==--cabal install---- or ----runhaskell Setup.hs configure FLAGS-runhaskell Setup.hs build-runhaskell Setup.hs install--Provide the set of flags passing- --flags="<flags-seperated-by-space>"-to configure.--== Compatibility ==--Tested with GHC 8.0, 8.2, 8.4, 8.6, 8.8 and 8.10--It is recommended to use the most recent platform release: http://hackage.haskell.org/platform/.--== C Language Compatibility ==--Currently unsupported C11 constructs:- - static assertion 6.7.10 (_Static_assert)- - generic selection 6.5.1.1 (_Generic)- - _Atomic, _Alignas, _Thread_local- - Universal character names--Currently unsupported GNU C extensions:- - __auto_type- - __builtin_offsetof- char a[__builtin_offsetof (struct S, sa->f)- - _Decimal32- - Extended assembler- __asm__ __volatile__ ("" : : : );- __asm__ goto ("" : : : : label);- - __attribute__((packed)): types featuring this attribute may have an- incorrect size or alignment calculated.--IEC 60559:- Since language-c-0.8, extended floating point types are supported (gcc 7 feature). Package maintainers may decide to disable these types (flag iecFpExtension) to work around the fact that the _Float128 type is redefined by glibc >= 2.26 if gcc < 7 is used for preprocessing:- /* The type _Float128 exists only since GCC 7.0. */- # if !__GNUC_PREREQ (7, 0) || defined __cplusplus- typedef __float128 _Float128;- # endif--== Sources ==--see src/README--== Examples ==--A couple of small examples are available in /examples--== Testing ==--A couple of regression tests can be run via-> cd test/harness; make--For more tests, see test/README.
+ README.md view
@@ -0,0 +1,43 @@+# Language.C++Language.C is a parser and pretty-printer framework for C11 and the extensions of gcc.++See http://visq.github.io/language-c/++## C Language Compatibility++Currently unsupported C11 constructs:+ - static assertion 6.7.10 (`_Static_assert`)+ - generic selection 6.5.1.1 (`_Generic`)+ - `_Atomic`, `_Alignas`, `_Thread_local`+ - Universal character names++Currently unsupported GNU C extensions:+ - `__auto_type`+ - `__builtin_offsetof`+ `char a[__builtin_offsetof (struct S, sa->f)`+ - `_Decimal32`+ - Extended assembler+ `__asm__ __volatile__ ("" : : : )`;+ `__asm__ goto ("" : : : : label)`;+ - `__attribute__((packed))`: types featuring this attribute may have an+ incorrect size or alignment calculated.++### IEC 60559:++Since `language-c-0.8`, extended floating point types are supported (gcc 7 feature). Package maintainers may decide to disable these types (flag `iecFpExtension`) to work around the fact that the `_Float128` type is redefined by glibc >= 2.26 if gcc < 7 is used for preprocessing:++```+ /* The type _Float128 exists only since GCC 7.0. */+ # if !__GNUC_PREREQ (7, 0) || defined __cplusplus+ typedef __float128 _Float128;+ # endif+```++## Examples++A couple of small examples are available in `examples`.++## Testing++See `test/README`.
language-c.cabal view
@@ -1,123 +1,132 @@-Name: language-c-Version: 0.9.2-Cabal-Version: >= 1.10-Build-Type: Simple-License: BSD3-License-File: LICENSE-Copyright: LICENSE-Author: AUTHORS-Maintainer: language.c@monoid.al-Stability: experimental-Homepage: http://visq.github.io/language-c/-Bug-reports: https://github.com/visq/language-c/issues/+cabal-version: 2.2+name: language-c+version: 0.9.3+license: BSD-3-Clause+license-file: LICENSE+copyright: LICENSE+maintainer: language.c@monoid.al+author: AUTHORS+tested-with:+ ghc ==9.8.1 ghc ==9.6.4 ghc ==9.4.8 ghc ==9.2.8 ghc ==9.0.2+ ghc ==8.10.7 ghc ==8.8.4 ghc ==8.6.5 ghc ==8.4.4 ghc ==8.2.2+ ghc ==8.0.2 ghc ==7.10.3 -Synopsis: Analysis and generation of C code-Description: Language C is a haskell library for the analysis and generation of C code.- It features a complete, well tested parser and pretty printer for all of C99 and a large- set of C11 and clang/GNU extensions.-Category: Language-Tested-With: GHC == 8.4.*, GHC == 8.6.*, GHC == 8.8.*, GHC == 8.10.*, GHC == 9.0.*, GHC == 9.2.*+homepage: https://visq.github.io/language-c/+bug-reports: https://github.com/visq/language-c/issues/+synopsis: Analysis and generation of C code+description:+ Language C is a haskell library for the analysis and generation of C code.+ It features a complete, well tested parser and pretty printer for all of C99 and a large+ set of C11 and clang/GNU extensions. -Extra-Source-Files: AUTHORS AUTHORS.c2hs ChangeLog README- src/Language/C/Parser/Lexer.x- src/Language/C/Parser/Parser.y+category: Language+build-type: Simple+extra-doc-files:+ ChangeLog.md+ README.md+ AUTHORS+ AUTHORS.c2hs -Source-Repository head- type: git- location: https://github.com/visq/language-c.git+source-repository head+ type: git+ location: https://github.com/visq/language-c.git -Flag useByteStrings- Description: Use ByteString as InputStream datatype- Default: True-Flag allWarnings- Description: Turn on all warnings for building (development)- Default: False-Flag iecFpExtension- Description: Support IEC 60559 floating point extension (defines _Float128)- Default: True-Library- default-extensions: CPP, DeriveDataTypeable, DeriveGeneric, PatternGuards, BangPatterns, ExistentialQuantification, GeneralizedNewtypeDeriving, ScopedTypeVariables- Build-Depends: base >= 4.8 && < 5,- array,- containers >= 0.3,- deepseq >= 1.4.0.0 && < 1.5,- directory,- filepath,- mtl,- pretty < 1.2.0,- process- if flag(allWarnings)- if impl(ghc >= 8.0)- ghc-options: -Wall -Wno-redundant-constraints+flag usebytestrings+ description: Use ByteString as InputStream datatype++flag allwarnings+ description: Turn on all warnings for building (development)+ default: False++flag iecfpextension+ description:+ Support IEC 60559 floating point extension (defines _Float128)++library+ exposed-modules:+ Language.C+ Language.C.Data+ Language.C.Data.Position+ Language.C.Data.Ident+ Language.C.Data.Error+ Language.C.Data.Name+ Language.C.Data.Node+ Language.C.Data.InputStream+ Language.C.Syntax+ Language.C.Syntax.AST+ Language.C.Syntax.Constants+ Language.C.Syntax.Ops+ Language.C.Syntax.Utils+ Language.C.Parser+ Language.C.Pretty+ Language.C.System.Preprocess+ Language.C.System.GCC+ Language.C.Analysis+ Language.C.Analysis.ConstEval+ Language.C.Analysis.Builtins+ Language.C.Analysis.SemError+ Language.C.Analysis.SemRep+ Language.C.Analysis.DefTable+ Language.C.Analysis.TravMonad+ Language.C.Analysis.AstAnalysis+ Language.C.Analysis.DeclAnalysis+ Language.C.Analysis.Debug+ Language.C.Analysis.TypeCheck+ Language.C.Analysis.TypeConversions+ Language.C.Analysis.TypeUtils+ Language.C.Analysis.NameSpaceMap+ Language.C.Analysis.MachineDescs+ Language.C.Analysis.Export++ build-tool-depends: happy:happy, alex:alex+ hs-source-dirs: src+ other-modules:+ Language.C.Data.RList+ Language.C.Parser.Builtin+ Language.C.Parser.Lexer+ Language.C.Parser.ParserMonad+ Language.C.Parser.Tokens+ Language.C.Parser.Parser++ default-language: Haskell2010+ default-extensions:+ CPP DeriveDataTypeable DeriveGeneric PatternGuards BangPatterns+ ExistentialQuantification GeneralizedNewtypeDeriving+ ScopedTypeVariables++ build-depends:+ base >=4.8 && <5,+ array <0.6,+ containers >=0.3 && <0.8,+ deepseq >=1.4.0.0 && <1.6,+ directory <1.4,+ filepath <1.6,+ mtl <2.4,+ pretty <1.2.0,+ process <1.7++ if flag(allwarnings)+ if impl(ghc >=8.0)+ ghc-options: -Wall -Wno-redundant-constraints+ else- ghc-options: -Wall+ ghc-options: -Wall - if flag(useByteStrings)- Build-Depends: bytestring >= 0.9.0+ if flag(usebytestrings)+ build-depends: bytestring >=0.9.0 && <0.13+ else cpp-options: -DNO_BYTESTRING - if flag(iecFpExtension)+ if flag(iecfpextension) cpp-options: -DIEC_60559_TYPES_EXT - Build-Tools: happy, alex-- Hs-Source-Dirs: src- Exposed-Modules:- -- top-level- Language.C- -- data- Language.C.Data- Language.C.Data.Position- Language.C.Data.Ident- Language.C.Data.Error- Language.C.Data.Name- Language.C.Data.Node- Language.C.Data.InputStream- -- syntax- Language.C.Syntax- Language.C.Syntax.AST- Language.C.Syntax.Constants- Language.C.Syntax.Ops- Language.C.Syntax.Utils- -- parser- Language.C.Parser- -- pretty printer- Language.C.Pretty- -- system- Language.C.System.Preprocess- Language.C.System.GCC- -- analysis [experimental]- Language.C.Analysis- Language.C.Analysis.ConstEval- Language.C.Analysis.Builtins- Language.C.Analysis.SemError- Language.C.Analysis.SemRep- Language.C.Analysis.DefTable- Language.C.Analysis.TravMonad- Language.C.Analysis.AstAnalysis- Language.C.Analysis.DeclAnalysis- Language.C.Analysis.Debug- Language.C.Analysis.TypeCheck- Language.C.Analysis.TypeConversions- Language.C.Analysis.TypeUtils- Language.C.Analysis.NameSpaceMap- Language.C.Analysis.MachineDescs- -- semrep -> code [alpha]- Language.C.Analysis.Export- Other-Modules:- Language.C.Data.RList- -- parser implementation- Language.C.Parser.Builtin- Language.C.Parser.Lexer- Language.C.Parser.ParserMonad- Language.C.Parser.Tokens- Language.C.Parser.Parser- default-language: Haskell2010---- test description-Test-Suite language-c-harness- type: exitcode-stdio-1.0- main-is: test/harness/run-harness.hs- build-depends: base, directory, process, filepath+test-suite language-c-harness+ type: exitcode-stdio-1.0+ main-is: test/harness/run-harness.hs default-language: Haskell2010+ build-depends:+ base <5,+ directory,+ process,+ filepath
src/Language/C/Analysis/AstAnalysis.hs view
@@ -766,6 +766,7 @@ builtinType (CBuiltinOffsetOf _ _ _) = return size_tType builtinType (CBuiltinTypesCompatible _ _ _) = return boolType builtinType (CBuiltinConvertVector _expr ty _) = analyseTypeDecl ty+builtinType (CBuiltinBitCast ty _expr _) = analyseTypeDecl ty -- return @Just declspecs@ without @CTypedef@ if the declaration specifier contain @typedef@ hasTypeDef :: [CDeclSpec] -> Maybe [CDeclSpec]
src/Language/C/Parser/Lexer.x view
@@ -323,10 +323,11 @@ (CTokGnuC GnuCVaArg) __builtin_va_arg (CTokGnuC GnuCOffsetof) __builtin_offsetof (CTokGnuC GnuCTyCompat) __builtin_types_compatible_p+(CTokGnuC GnuBitCast) __builtin_bit_cast (flip CTokClangC ClangBuiltinConvertVector) __builtin_convertvector -} --- Tokens: _Alignas _Alignof __alignof alignof __alignof__ __asm asm __asm__ _Atomic auto break _Bool case char __const const __const__ continue _Complex __complex__ default do double else enum extern float for _Generic goto if __inline inline __inline__ int __int128 __int128_t long _Noreturn _Nullable __nullable _Nonnull __nonnull register __restrict restrict __restrict__ return short __signed signed __signed__ sizeof static _Static_assert struct switch typedef __typeof typeof __typeof__ __thread _Thread_local __uint128 __uint128_t union unsigned void __volatile volatile __volatile__ while __label__ _Float32 _Float32x _Float64 _Float64x _Float128 __float128 _Float128x __attribute __attribute__ __extension__ __real __real__ __imag __imag__ __builtin_va_arg __builtin_offsetof __builtin_types_compatible_p __builtin_convertvector+-- Tokens: _Alignas _Alignof __alignof alignof __alignof__ __asm asm __asm__ _Atomic auto break _Bool case char __const const __const__ continue _Complex __complex__ default do double else enum extern float for _Generic goto if __inline inline __inline__ int __int128_t long _Noreturn _Nullable __nullable _Nonnull __nonnull register __restrict restrict __restrict__ return short __signed signed __signed__ sizeof static _Static_assert struct switch typedef __typeof typeof __typeof__ __thread _Thread_local __uint128 __uint128_t union unsigned void __volatile volatile __volatile__ while __label__ _Float32 _Float32x _Float64 _Float64x _Float128 __float128 _Float128x __attribute __attribute__ __extension__ __real __real__ __imag __imag__ __builtin_va_arg __builtin_offsetof __builtin_types_compatible_p __builtin_bit_cast __builtin_convertvector idkwtok ('_' : 'A' : 'l' : 'i' : 'g' : 'n' : 'a' : 's' : []) = tok 8 CTokAlignas idkwtok ('_' : 'A' : 'l' : 'i' : 'g' : 'n' : 'o' : 'f' : []) = tok 8 CTokAlignof idkwtok ('_' : 'A' : 't' : 'o' : 'm' : 'i' : 'c' : []) = tok 7 CTokAtomic@@ -356,6 +357,7 @@ idkwtok ('_' : '_' : 'a' : 't' : 't' : 'r' : 'i' : 'b' : 'u' : 't' : 'e' : '_' : '_' : []) = tok 13 (CTokGnuC GnuCAttrTok) idkwtok ('a' : 'u' : 't' : 'o' : []) = tok 4 CTokAuto idkwtok ('b' : 'r' : 'e' : 'a' : 'k' : []) = tok 5 CTokBreak+idkwtok ('_' : '_' : 'b' : 'u' : 'i' : 'l' : 't' : 'i' : 'n' : '_' : 'b' : 'i' : 't' : '_' : 'c' : 'a' : 's' : 't' : []) = tok 18 (flip CTokClangC ClangCBitCast) idkwtok ('_' : '_' : 'b' : 'u' : 'i' : 'l' : 't' : 'i' : 'n' : '_' : 'c' : 'o' : 'n' : 'v' : 'e' : 'r' : 't' : 'v' : 'e' : 'c' : 't' : 'o' : 'r' : []) = tok 23 (flip CTokClangC ClangBuiltinConvertVector) idkwtok ('_' : '_' : 'b' : 'u' : 'i' : 'l' : 't' : 'i' : 'n' : '_' : 'o' : 'f' : 'f' : 's' : 'e' : 't' : 'o' : 'f' : []) = tok 18 (CTokGnuC GnuCOffsetof) idkwtok ('_' : '_' : 'b' : 'u' : 'i' : 'l' : 't' : 'i' : 'n' : '_' : 't' : 'y' : 'p' : 'e' : 's' : '_' : 'c' : 'o' : 'm' : 'p' : 'a' : 't' : 'i' : 'b' : 'l' : 'e' : '_' : 'p' : []) = tok 28 (CTokGnuC GnuCTyCompat)
src/Language/C/Parser/Parser.y view
@@ -257,6 +257,7 @@ "__builtin_types_compatible_p" { CTokGnuC GnuCTyCompat _ } "__builtin_convertvector" { CTokClangC _ ClangBuiltinConvertVector } clangcversion { CTokClangC _ (ClangCVersionTok $$) } -- Clang version literal+"__builtin_bit_cast" { CTokClangC _ ClangCBitCast } "__kernel" { CTokClKernel _ } -- OpenCL kernel function "__read_only" { CTokClRdOnly _ } -- OpenCL read only qualifier "__write_only" { CTokClWrOnly _ } -- OpenCL write only qualifier@@ -1770,7 +1771,10 @@ {% withNodeInfo $1 $ CBuiltinExpr . CBuiltinTypesCompatible $3 $5 } | "__builtin_convertvector" '(' assignment_expression ',' type_name ')'- {% withNodeInfo $1 $ CBuiltinExpr . CBuiltinConvertVector $3 $5 }+ {% withNodeInfo $1 $ CBuiltinExpr . CBuiltinConvertVector $3 $5 }++ | "__builtin_bit_cast" '(' type_name ',' assignment_expression ')'+ {% withNodeInfo $1 $ CBuiltinExpr . CBuiltinBitCast $3 $5 } -- Generic Selection association list (C11 6.5.1.1) --
src/Language/C/Parser/Tokens.hs view
@@ -163,6 +163,7 @@ data ClangCTok = ClangCVersionTok !ClangCVersion -- version constant from 'availability' attribute | ClangBuiltinConvertVector+ | ClangCBitCast -- `__builtin_bit_cast` instance Pos CToken where posOf = fst . posLenOfTok@@ -395,6 +396,7 @@ showsPrec _ (CTokGnuC GnuCTyCompat _) = showString "__builtin_types_compatible_p" showsPrec _ (CTokClangC _ (ClangCVersionTok v)) = shows v showsPrec _ (CTokClangC _ ClangBuiltinConvertVector) = showString "__builtin_convertvector"+ showsPrec _ (CTokClangC _ ClangCBitCast) = showString "__builtin_bit_cast" showsPrec _ (CTokClKernel _ ) = showString "__kernel" showsPrec _ (CTokClRdOnly _ ) = showString "__read_only" showsPrec _ (CTokClWrOnly _ ) = showString "__write_only"
src/Language/C/Pretty.hs view
@@ -473,6 +473,9 @@ pretty (CBuiltinConvertVector expr ty _) = text "__builtin_convertvector" <+> parens (pretty expr <> comma <+> pretty ty)+ pretty (CBuiltinBitCast ty expr _) =+ text "__builtin_bit_cast" <+>+ parens (pretty ty <> comma <+> pretty expr) instance Pretty CAssignOp where pretty op = text $ case op of
src/Language/C/Syntax/AST.hs view
@@ -763,6 +763,7 @@ | CBuiltinOffsetOf (CDeclaration a) [CPartDesignator a] a -- ^ @(type, designator-list)@ | CBuiltinTypesCompatible (CDeclaration a) (CDeclaration a) a -- ^ @(type,type)@ | CBuiltinConvertVector (CExpression a) (CDeclaration a) a -- ^ @(expr, type)@+ | CBuiltinBitCast (CDeclaration a) (CExpression a) a -- ^ @(type, expr)@ deriving (Show, Data,Typeable, Generic {-! ,CNode ,Functor ,Annotated !-}) instance NFData a => NFData (CBuiltinThing a)@@ -1397,6 +1398,7 @@ nodeInfo (CBuiltinOffsetOf _ _ n) = nodeInfo n nodeInfo (CBuiltinTypesCompatible _ _ n) = nodeInfo n nodeInfo (CBuiltinConvertVector _ _ n) = nodeInfo n+ nodeInfo (CBuiltinBitCast _ _ n) = nodeInfo n instance CNode t1 => Pos (CBuiltinThing t1) where posOf x = posOf (nodeInfo x) @@ -1409,12 +1411,15 @@ = CBuiltinTypesCompatible (fmap _f a1) (fmap _f a2) (_f a3) fmap _f (CBuiltinConvertVector a1 a2 a3) = CBuiltinConvertVector (fmap _f a1) (fmap _f a2) (_f a3)+ fmap _f (CBuiltinBitCast a1 a2 a3)+ = CBuiltinBitCast (fmap _f a1) (fmap _f a2) (_f a3) instance Annotated CBuiltinThing where annotation (CBuiltinVaArg _ _ n) = n annotation (CBuiltinOffsetOf _ _ n) = n annotation (CBuiltinTypesCompatible _ _ n) = n annotation (CBuiltinConvertVector _ _ n) = n+ annotation (CBuiltinBitCast _ _ n) = n amap f (CBuiltinVaArg a_1 a_2 a_3) = CBuiltinVaArg a_1 a_2 (f a_3) amap f (CBuiltinOffsetOf a_1 a_2 a_3) = CBuiltinOffsetOf a_1 a_2 (f a_3)@@ -1422,6 +1427,8 @@ = CBuiltinTypesCompatible a_1 a_2 (f a_3) amap f (CBuiltinConvertVector a_1 a_2 a_3) = CBuiltinConvertVector a_1 a_2 (f a_3)+ amap f (CBuiltinBitCast a_1 a_2 a_3) =+ CBuiltinBitCast a_1 a_2 (f a_3) instance CNode t1 => CNode (CConstant t1) where nodeInfo (CIntConst _ n) = nodeInfo n