Changeset 7937abf
- Timestamp:
- May 4, 2016, 1:58:35 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 1b7ea43, 7b937575
- Parents:
- 0638c44
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/LaTeXmacros/common.tex
r0638c44 r7937abf 11 11 %% Created On : Sat Apr 9 10:06:17 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Tue May 3 07:59:41201614 %% Update Count : 4413 %% Last Modified On : Wed May 4 08:01:10 2016 14 %% Update Count : 54 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 132 132 % blocks and titles 133 133 \newcommand{\define}[1]{\emph{#1\/}\index{#1}} 134 \newcommand{\rewrite}{\(\Rightarrow\)}135 134 \newcommand{\rewriterules}{\paragraph{Rewrite Rules}~\par\noindent} 136 135 \newcommand{\examples}{\paragraph{Examples}~\par\noindent} … … 144 143 \newcommand{\lhs}[1]{\par{\emph{#1:}}\index{#1@{\emph{#1}}|italic}} 145 144 \newcommand{\rhs}{\hfil\break\hbox{\hskip1in}} 146 \newcommand{\oldlhs}[1]{\emph{#1: \ ldots}\index{#1@{\emph{#1}}|italic}}145 \newcommand{\oldlhs}[1]{\emph{#1: \dots}\index{#1@{\emph{#1}}|italic}} 147 146 \newcommand{\nonterm}[1]{\emph{#1\/}\index{#1@{\emph{#1}}|italic}} 148 147 \newcommand{\opt}{$_{opt}$\ } … … 200 199 belowskip=2pt, 201 200 moredelim=**[is][\color{red}]{®}{®}, % red highlighting 202 % moredelim=**[is][\color{blue}]{ ©}{©}, % blue highlighting201 % moredelim=**[is][\color{blue}]{¢}{¢}, % blue highlighting 203 202 moredelim=[is][\lstset{keywords={}}]{¶}{¶}, % temporarily turn off keywords 204 203 % literate={\\`}{\raisebox{0.3ex}{\ttfamily\upshape \hspace*{-2pt}`}}1, % escape \`, otherwise used for red highlighting 204 literate={...}{{$\dots$}}1 {<-}{{$\leftarrow$}}1 {=>}{{$\Rightarrow$}}1, 205 205 }% 206 206 -
doc/refrat/refrat.tex
r0638c44 r7937abf 10 10 %% Created On : Wed Apr 6 14:52:25 2016 11 11 %% Last Modified By : Peter A. Buhr 12 %% Last Modified On : Tue May 3 09:23:43201613 %% Update Count : 5212 %% Last Modified On : Tue May 3 18:00:28 2016 13 %% Update Count : 64 14 14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15 15 … … 139 139 \subsection{Scopes of identifiers}\index{scopes} 140 140 141 \CFA's scope rules differ from C's in one major respect: a declaration of an identifier may overload\index{overloading} outer declarations of lexically identical identifiers in the same 142 \Index{name space}, instead of hiding them. 141 \CFA's scope rules differ from C's in one major respect: a declaration of an identifier may overload\index{overloading} outer declarations of lexically identical identifiers in the same \Index{name space}, instead of hiding them. 143 142 The outer declaration is hidden if the two declarations have \Index{compatible type}, or if one declares an array type and the other declares a pointer type and the element type and pointed-at type are compatible, or if one has function type and the other is a pointer to a compatible function type, or if one declaration is a ©type©\use{type} or ©typedef©\use{typedef} declaration and the other is not. 144 143 The outer declaration becomes \Index{visible} when the scope of the inner declaration terminates. … … 153 152 154 153 \CFA's linkage rules differ from C's in only one respect: instances of a particular identifier with external or internal linkage do not necessarily denote the same object or function. 155 Instead, in the set of translation units and libraries that constitutes an entire program, any two instances of a particular identifier with \Index{external linkage} denote the same object or function if they have 156 \Index{compatible type}s, or if one declares an array type and the other declares a pointer type and the element type and pointed-at type are compatible, or if one has function type and the other is a pointer to a compatible function type. 154 Instead, in the set of translation units and libraries that constitutes an entire program, any two instances of a particular identifier with \Index{external linkage} denote the same object or function if they have \Index{compatible type}s, or if one declares an array type and the other declares a pointer type and the element type and pointed-at type are compatible, or if one has function type and the other is a pointer to a compatible function type. 157 155 Within one translation unit, each instance of an identifier with \Index{internal linkage} denotes the same object or function in the same circumstances. 158 156 Identifiers with \Index{no linkage} always denote unique entities. … … 229 227 \CFA defines situations where values of one type are automatically converted to another type. 230 228 These conversions are called \define{implicit conversion}s. 231 The programmer can request 232 \define{explicit conversion}s using cast expressions. 229 The programmer can request \define{explicit conversion}s using cast expressions. 233 230 234 231 … … 281 278 \label{anon-conv} 282 279 283 If an expression's type is a pointer to a structure or union type that has a member that is an 284 \Index{anonymous structure} or an \Index{anonymous union}, it can be implicitly converted\index{implicit conversion} to a pointer to the anonymous structure's or anonymous union's type. 280 If an expression's type is a pointer to a structure or union type that has a member that is an \Index{anonymous structure} or an \Index{anonymous union}, it can be implicitly converted\index{implicit conversion} to a pointer to the anonymous structure's or anonymous union's type. 285 281 The result of the conversion is a pointer to the member. 286 282 … … 708 704 \rewriterules 709 705 \begin{lstlisting} 710 a[b] §\rewrite§?[?]( b, a ) // if a has integer type§\use{?[?]}§711 a[b] §\rewrite§?[?]( a, b ) // otherwise712 a( §\emph{arguments}§ ) §\rewrite§?()( a, §\emph{arguments}§ )§\use{?()}§713 a++ §\rewrite§?++(&( a ))§\use{?++}§714 a-- §\rewrite§?--(&( a ))§\use{?--}§706 a[b] => ?[?]( b, a ) // if a has integer type§\use{?[?]}§ 707 a[b] => ?[?]( a, b ) // otherwise 708 a( §\emph{arguments}§ ) => ?()( a, §\emph{arguments}§ )§\use{?()}§ 709 a++ => ?++(&( a ))§\use{?++}§ 710 a-- => ?--(&( a ))§\use{?--}§ 715 711 \end{lstlisting} 716 712 … … 744 740 Subscript expressions are rewritten as function calls that pass the first parameter by value. 745 741 This is somewhat unfortunate, since array-like types tend to be large. 746 The alternative is to use the rewrite rule ``©a[b] © \rewrite ©?[?](&(a), b)©''.742 The alternative is to use the rewrite rule ``©a[b] => ?[?](&(a), b)©''. 747 743 However, C semantics forbid this approach: the ©a© in ``©a[b]©'' can be an arbitrary pointer value, which does not have an address. 748 744 … … 771 767 The type of the valid interpretation is the return type of the function designator. 772 768 773 For those combinations where the interpretation of the \nonterm{postfix-expression} is a 774 \Index{polymorphic function} designator and the function designator accepts the number of arguments given, there shall be at least one set of \define{implicit argument}s for the implicit parameters such that 769 For those combinations where the interpretation of the \nonterm{postfix-expression} is a \Index{polymorphic function} designator and the function designator accepts the number of arguments given, there shall be at least one set of \define{implicit argument}s for the implicit parameters such that 775 770 \begin{itemize} 776 771 \item … … 798 793 For instance, it should be possible to replace a function ``©int f( int );©'' with ``©forall( otype T ) T f( T );©'' without affecting any calls of ©f©. 799 794 800 \CFA\index{deficiencies!generalizability} does not fully possess this property, because 801 \Index{unsafe conversion} are not done when arguments are passed to polymorphic parameters. 795 \CFA\index{deficiencies!generalizability} does not fully possess this property, because \Index{unsafe conversion} are not done when arguments are passed to polymorphic parameters. 802 796 Consider 803 797 \begin{lstlisting} … … 1123 1117 \rewriterules 1124 1118 \begin{lstlisting} 1125 *a §\rewrite§ *?( a )§\use{*?}§1126 +a §\rewrite§ +?( a )§\use{+?}§1127 -a §\rewrite§ -?( a )§\use{-?}§1128 ~a §\rewrite§ ~?( a )§\use{~?}§1129 !a §\rewrite§ !?( a )§\use{"!?}§1130 ++a §\rewrite§ ++?(&( a ))§\use{++?}§1131 --a §\rewrite§ --?(&( a ))§\use{--?}§1119 *a => *?( a )§\use{*?}§ 1120 +a => +?( a )§\use{+?}§ 1121 -a => -?( a )§\use{-?}§ 1122 ~a => ~?( a )§\use{~?}§ 1123 !a => !?( a )§\use{"!?}§ 1124 ++a => ++?(&( a ))§\use{++?}§ 1125 --a => --?(&( a ))§\use{--?}§ 1132 1126 \end{lstlisting} 1133 1127 … … 1270 1264 1271 1265 \constraints 1272 The operand of the unary ``©&©'' operator shall have exactly one 1273 \Index{interpretation}\index{ambiguous interpretation}, which shall be unambiguous. 1266 The operand of the unary ``©&©'' operator shall have exactly one \Index{interpretation}\index{ambiguous interpretation}, which shall be unambiguous. 1274 1267 1275 1268 \semantics … … 1317 1310 long int li; 1318 1311 void eat_double( double );§\use{eat_double}§ 1319 eat_double(-li ); // §\rewrite§eat_double( -?( li ) );1312 eat_double(-li ); // => eat_double( -?( li ) ); 1320 1313 \end{lstlisting} 1321 1314 The valid interpretations of ``©-li©'' (assuming no extended integer types exist) are … … 1425 1418 \rewriterules 1426 1419 \begin{lstlisting} 1427 a * b §\rewrite§?*?( a, b )§\use{?*?}§1428 a / b §\rewrite§?/?( a, b )§\use{?/?}§1429 a % b §\rewrite§?%?( a, b )§\use{?%?}§1420 a * b => ?*?( a, b )§\use{?*?}§ 1421 a / b => ?/?( a, b )§\use{?/?}§ 1422 a % b => ?%?( a, b )§\use{?%?}§ 1430 1423 \end{lstlisting} 1431 1424 … … 1461 1454 1462 1455 \begin{rationale} 1463 {\c11} does not include conversions from the \Index{real type}s to \Index{complex type}s in the 1464 \Index{usual arithmetic conversion}s. Instead it specifies conversion of the result of binary operations on arguments from mixed type domains. \CFA's predefined operators match that pattern. 1456 {\c11} does not include conversions from the \Index{real type}s to \Index{complex type}s in the \Index{usual arithmetic conversion}s. Instead it specifies conversion of the result of binary operations on arguments from mixed type domains. \CFA's predefined operators match that pattern. 1465 1457 \end{rationale} 1466 1458 … … 1536 1528 \rewriterules 1537 1529 \begin{lstlisting} 1538 a + b §\rewrite§?+?( a, b )§\use{?+?}§1539 a - b §\rewrite§?-?( a, b )§\use{?-?}§1530 a + b => ?+?( a, b )§\use{?+?}§ 1531 a - b => ?-?( a, b )§\use{?-?}§ 1540 1532 \end{lstlisting} 1541 1533 … … 1615 1607 \end{syntax} 1616 1608 1617 \rewriterules \use{?>>?}%use{?<<?}1618 \begin{lstlisting} 1619 a << b §\rewrite§ ?<<?( a, b )1620 a >> b §\rewrite§ ?>>?( a, b )1609 \rewriterules 1610 \begin{lstlisting} 1611 a << b => ?<<?( a, b )§\use{?<<?}§ 1612 a >> b => ?>>?( a, b )§\use{?>>?}§ 1621 1613 \end{lstlisting} 1622 1614 … … 1656 1648 \end{syntax} 1657 1649 1658 \rewriterules \use{?>?}\use{?>=?}%use{?<?}%use{?<=?}1659 \begin{lstlisting} 1660 a < b §\rewrite§ ?<?( a, b )1661 a > b §\rewrite§ ?>?( a, b )1662 a <= b §\rewrite§ ?<=?( a, b )1663 a >= b §\rewrite§ ?>=?( a, b )1650 \rewriterules 1651 \begin{lstlisting} 1652 a < b => ?<?( a, b )§\use{?<?}§ 1653 a > b => ?>?( a, b )§\use{?>?}§ 1654 a <= b => ?<=?( a, b )§\use{?<=?}§ 1655 a >= b => ?>=?( a, b )§\use{?>=?}§ 1664 1656 \end{lstlisting} 1665 1657 … … 1717 1709 \rewriterules 1718 1710 \begin{lstlisting} 1719 a == b §\rewrite§?==?( a, b )§\use{?==?}§1720 a != b §\rewrite§?!=?( a, b )§\use{?"!=?}§1711 a == b => ?==?( a, b )§\use{?==?}§ 1712 a != b => ?!=?( a, b )§\use{?"!=?}§ 1721 1713 \end{lstlisting} 1722 1714 … … 1805 1797 \rewriterules 1806 1798 \begin{lstlisting} 1807 a & b §\rewrite§?&?( a, b )§\use{?&?}§1799 a & b => ?&?( a, b )§\use{?&?}§ 1808 1800 \end{lstlisting} 1809 1801 … … 1837 1829 \rewriterules 1838 1830 \begin{lstlisting} 1839 a ^ b §\rewrite§?^?( a, b )§\use{?^?}§1831 a ^ b => ?^?( a, b )§\use{?^?}§ 1840 1832 \end{lstlisting} 1841 1833 … … 1867 1859 \end{syntax} 1868 1860 1869 \rewriterules \use{?"|?}1870 \begin{lstlisting} 1871 a | b §\rewrite§ ?|?( a, b )1861 \rewriterules 1862 \begin{lstlisting} 1863 a | b => ?|?( a, b )§\use{?"|?}§ 1872 1864 \end{lstlisting} 1873 1865 … … 2024 2016 \nonterm{assignment-expression} 2025 2017 \lhs{assignment-operator} one of 2026 \rhs ©=©\ \ ©*=©\ \ ©/=©\ \ ©%=©\ \ ©+=©\ \ ©-=©\ \ 2027 ©<<=©\ \ ©>>=©\ \ ©&=©\ \ ©^=©\ \ ©|=© 2018 \rhs ©=©\ \ ©*=©\ \ ©/=©\ \ ©%=©\ \ ©+=©\ \ ©-=©\ \ ©<<=©\ \ ©>>=©\ \ ©&=©\ \ ©^=©\ \ ©|=© 2028 2019 \end{syntax} 2029 2020 2030 2021 \rewriterules 2031 Let `` \(\leftarrow\)'' be any of the assignment operators.2022 Let ``©<-©'' be any of the assignment operators. 2032 2023 Then 2033 \use{?=?}\use{?*=?}\use{?/=?}\use{?%=?}\use{?+=?}\use{?-=?} 2034 \use{?>>=?}\use{?&=?}\use{?^=?}\use{?"|=?}%use{?<<=?} 2035 \begin{lstlisting} 2036 a §$\leftarrow$§ b §\rewrite§ ?§$\leftarrow$§?( &( a ), b ) 2024 \use{?=?}\use{?*=?}\use{?/=?}\use{?%=?}\use{?+=?}\use{?-=?}\use{?>>=?}\use{?&=?}\use{?^=?}\use{?"|=?}%use{?<<=?} 2025 \begin{lstlisting} 2026 a <- b => ?<-?( &( a ), b ) 2037 2027 \end{lstlisting} 2038 2028 … … 2709 2699 D( §\normalsize\nonterm{parameter-type-list}§ ) 2710 2700 \end{lstlisting} then a type identifier declared by one of the \nonterm{forall-specifier}s is an \define{inferred parameter} of the function declarator if and only if it is not an inferred parameter of a function declarator in ©D©, and it is used in the type of a parameter in the following 2711 \nonterm{type-parameter-list} or it and an inferred parameter are used as arguments of a 2712 \Index{specification} in one of the \nonterm{forall-specifier}s. 2701 \nonterm{type-parameter-list} or it and an inferred parameter are used as arguments of a \Index{specification} in one of the \nonterm{forall-specifier}s. 2713 2702 The identifiers declared by assertions that use an inferred parameter of a function declarator are \Index{assertion parameter}s of that function declarator. 2714 2703 … … 2732 2721 2733 2722 If a function declarator is part of a function definition, its inferred parameters and assertion parameters have \Index{block scope}; 2734 otherwise, identifiers declared by assertions have a 2735 \define{declaration scope}, which terminates at the end of the \nonterm{declaration}. 2723 otherwise, identifiers declared by assertions have a \define{declaration scope}, which terminates at the end of the \nonterm{declaration}. 2736 2724 2737 2725 A function type that has at least one inferred parameter is a \define{polymorphic function} type. … … 2742 2730 Let $f$ and $g$ be two polymorphic function types with the same number of inferred parameters, and let $f_i$ and $g_i$ be the inferred parameters of $f$ and $g$ in their order of occurance in the function types' \nonterm{parameter-type-list}s. 2743 2731 Let $f'$ be $f$ with every occurrence of $f_i$ replaced by $g_i$, for all $i$. 2744 Then $f$ and $g$ are 2745 \Index{compatible type}s if $f'$'s and $g$'s return types and parameter lists are compatible, and if for every assertion parameter of $f'$ there is an assertion parameter in $g$ with the same identifier and compatible type, and vice versa. 2732 Then $f$ and $g$ are \Index{compatible type}s if $f'$'s and $g$'s return types and parameter lists are compatible, and if for every assertion parameter of $f'$ there is an assertion parameter in $g$ with the same identifier and compatible type, and vice versa. 2746 2733 2747 2734 \examples … … 2960 2947 2961 2948 \semantics 2962 An \define{assertion} is a declaration of a collection of objects and functions, called 2963 \define{assertion parameters}. 2949 An \define{assertion} is a declaration of a collection of objects and functions, called \define{assertion parameters}. 2964 2950 2965 2951 The assertion parameters produced by an assertion that applies the name of a specification to type arguments are found by taking the declarations specified in the specification and treating each of the specification's parameters as a synonym for the corresponding \nonterm{type-name} argument. … … 3040 3026 3041 3027 A type declaration without an \Index{initializer} and without a \Index{storage-class specifier} or with storage-class specifier ©static©\use{static} defines an \Index{incomplete type}. 3042 If a 3043 \Index{translation unit} or \Index{block} contains one or more such declarations for an identifier, it must contain exactly one definition of the identifier ( but not in an enclosed block, which would define a new type known only within that block). 3028 If a \Index{translation unit} or \Index{block} contains one or more such declarations for an identifier, it must contain exactly one definition of the identifier ( but not in an enclosed block, which would define a new type known only within that block). 3044 3029 \begin{rationale} 3045 3030 Incomplete type declarations allow compact mutually-recursive types. … … 3059 3044 3060 3045 A type declaration without an initializer and with \Index{storage-class specifier} ©extern©\use{extern} is an \define{opaque type declaration}. 3061 Opaque types are 3062 \Index{object type}s. 3046 Opaque types are \Index{object type}s. 3063 3047 An opaque type is not a \nonterm{constant-expression}; 3064 neither is a structure or union that has a member whose type is not a \nonterm{constant-expression}. Every other3065 \Index{object type} is a \nonterm{constant-expression}.3048 neither is a structure or union that has a member whose type is not a \nonterm{constant-expression}. 3049 Every other \Index{object type} is a \nonterm{constant-expression}. 3066 3050 Objects with static storage duration shall be declared with a type that is a \nonterm{constant-expression}. 3067 3051 \begin{rationale} … … 3075 3059 An \Index{incomplete type} which is not a qualified version\index{qualified type} of a type is a value of \Index{type-class} ©dtype©. 3076 3060 An object type\index{object types} which is not a qualified version of a type is a value of type-classes ©type© and ©dtype©. 3077 A 3078 \Index{function type} is a value of type-class ©ftype©. 3061 A \Index{function type} is a value of type-class ©ftype©. 3079 3062 \begin{rationale} 3080 3063 Syntactically, a type value is a \nonterm{type-name}, which is a declaration for an object which omits the identifier being declared. … … 3128 3111 // File a.c: 3129 3112 extern type t1; 3130 type t2 = struct { t1 f1; ... } 3113 type t2 = struct { t1 f1; ... } // illegal 3131 3114 // File b.c: 3132 3115 extern type t2; 3133 type t1 = struct { t2 f2; ... } 3116 type t1 = struct { t2 f2; ... } // illegal 3134 3117 \end{lstlisting} 3135 3118 \end{rationale} … … 3154 3137 #include <stdlib.h> 3155 3138 T * new( otype T ) { return ( T * )malloc( sizeof( T) ); }; 3156 §\ldots§int * ip = new( int );3139 ... int * ip = new( int ); 3157 3140 \end{lstlisting} 3158 3141 This looks sensible, but \CFA's declaration-before-use rules mean that ``©T©'' in the function body refers to the parameter, but the ``©T©'' in the return type refers to the meaning of ©T© in the scope that contains ©new©; … … 3239 3222 3240 3223 A definition\index{type definition} of a type identifier ©T© with \Index{implementation type} ©I© and type-class ©type© implicitly defines a default assignment function. 3241 A definition\index{type definition} of a type identifier ©T© with implementation type ©I© and an assertion list implicitly defines \define{default function}s and 3242 \define{default object}s as declared by the assertion declarations. 3224 A definition\index{type definition} of a type identifier ©T© with implementation type ©I© and an assertion list implicitly defines \define{default function}s and \define{default object}s as declared by the assertion declarations. 3243 3225 The default objects and functions have the same \Index{scope} and \Index{linkage} as the identifier ©T©. 3244 3226 Their values are determined as follows: … … 3296 3278 Default functions and objects are subject to the normal scope rules. 3297 3279 \begin{lstlisting} 3298 otype T = §\ldots§;3299 T a_T = §\ldots§; // Default assignment used.3280 otype T = ...; 3281 T a_T = ...; // Default assignment used. 3300 3282 T ?=?( T *, T ); 3301 T a_T = §\ldots§; // Programmer-defined assignment called.3283 T a_T = ...; // Programmer-defined assignment called. 3302 3284 \end{lstlisting} 3303 3285 \begin{rationale} … … 3421 3403 The statement 3422 3404 \begin{lstlisting} 3423 for ( a; b; c ) §\ldots§3405 for ( a; b; c ) ... 3424 3406 \end{lstlisting} is treated as 3425 3407 \begin{lstlisting} … … 3581 3563 \end{lstlisting} 3582 3564 3583 The various flavors of ©char© and ©int© and the enumerated types make up the 3584 \define{integral types}. 3565 The various flavors of ©char© and ©int© and the enumerated types make up the \define{integral types}. 3585 3566 \begin{lstlisting} 3586 3567 trait integral( otype T | arithmetic( T ) ) {§\impl{integral}§§\use{arithmetic}§ -
src/examples/abstype.c
r0638c44 r7937abf 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 27 18:10:01 201513 // Update Count : 412 // Last Modified On : Wed Apr 6 22:16:08 2016 13 // Update Count : 8 14 14 // 15 15 16 type T | { T x( T ); };16 otype T | { T x( T ); }; 17 17 18 18 T y( T t ) { … … 21 21 } 22 22 23 forall( type T) lvalue T*?( T* );24 int ?++( int * );25 int ?=?( int *, int );26 forall( dtype DT) DT* ?=?( DT **, DT* );23 forall( otype T ) lvalue T *?( T* ); 24 int ?++( int * ); 25 int ?=?( int *, int ); 26 forall( dtype DT ) DT * ?=?( DT **, DT* ); 27 27 28 type U = int*;28 otype U = int *; 29 29 30 30 U x( U u ) { -
src/examples/alloc.c
r0638c44 r7937abf 11 11 // Created On : Wed Feb 3 07:56:22 2016 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Wed Feb 17 11:43:23201614 // Update Count : 4013 // Last Modified On : Fri Mar 11 17:42:08 2016 14 // Update Count : 59 15 15 // 16 16 17 forall( otype T ) T * malloc( char fill ); 18 forall( dtype T ) T *?=?( T **, void * ); 19 void *malloc( unsigned long int ); 20 #if 0 17 21 #include <fstream> 18 22 #include <stdlib> … … 25 29 int * bar( int * p, int c ) { return p; } 26 30 int * baz( int * p, int c ) { return p; } 31 #endif 27 32 28 33 int main( void ) { 34 #if 0 29 35 size_t size = 10; 30 36 int * p; 31 37 struct S { int x; double y; } * s; 38 #endif 32 39 40 #if 0 33 41 p = malloc( sizeof(*p) ); // C malloc, type unsafe 34 42 printf( "here1\n" ); … … 37 45 printf( "here2\n" ); 38 46 free( p ); 39 p = malloc( (char)'\0' ); // CFA malloc, type safe 47 #endif 48 // int * p; 49 // p = malloc( (char)'\0' ); // CFA malloc, type safe 50 (int *)malloc( (char)'\0' ); // CFA malloc, type safe 51 (void *)malloc( (char)'\0' ); // CFA malloc, type safe 52 #if 0 40 53 printf( "here3\n" ); 41 54 p = malloc( p, 1000 ); // CFA remalloc, type safe … … 60 73 printf( "here9\n" ); 61 74 free( p ); 62 #if 0 75 63 76 float * fp = malloc() + 1; 64 77 fprintf( stderr, "%p %p\n", fp, fp - 1 ); -
src/examples/includes.c
r0638c44 r7937abf 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 23:28:02 201613 // Update Count : 3 2812 // Last Modified On : Wed Apr 13 22:30:02 2016 13 // Update Count : 370 14 14 // 15 15 … … 24 24 #if 1 25 25 #define _GNU_SOURCE 26 #include <aio.h>27 #include <a.out.h>28 #include <aliases.h>29 #include <alloca.h>30 #include <ansidecl.h>31 #include <ar.h>32 #include <argp.h>26 //#include <aio.h> 27 //#include <a.out.h> 28 //#include <aliases.h> 29 //#include <alloca.h> 30 //#include <ansidecl.h> 31 //#include <ar.h> 32 //#include <argp.h> 33 33 #include <argz.h> 34 #include <assert.h>34 //#include <assert.h> 35 35 #include <bfd.h> 36 #if 0 36 37 #include <bfdlink.h> 37 38 #include <byteswap.h> … … 56 57 #include <err.h> 57 58 #include <errno.h> 58 #if 059 59 #include <error.h> 60 #endif61 60 #include <eti.h> 62 61 #include <evdns.h> 63 62 #include <event.h> 64 63 #include <evhttp.h> 64 #endif 65 65 #if 0 66 66 #include <evrpc.h> … … 129 129 130 130 //#define _GNU_SOURCE 131 #include <error.h> 131 #include <bfd.h> 132 //#include <error.h> 132 133 133 134 #endif // 0
Note: See TracChangeset
for help on using the changeset viewer.