Changes in / [d1f5054:26d40a1]


Ignore:
Files:
3 added
4 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • doc/bibliography/pl.bib

    rd1f5054 r26d40a1  
    30883088    note        = {WikipediA},
    30893089    howpublished= {\url{http://www.akkadia.org/drepper/tls.pdf}},
    3090 }
    3091 
    3092 @misc{DARPA24,
    3093     contributer = {pabuhr@plg},
    3094     title       = {Eliminating Memory Safety Vulnerabilities Once and For All},
    3095     author      = {Defense Advanced Research Projects Agency},
    3096     year        = 2024,
    3097     month       = jul,
    3098     howpublished= {\url{https://www.darpa.mil/news-events/2024-07-31a}},
    30993090}
    31003091
     
    76957686}
    76967687
    7697 @misc{WhiteHouse24,
    7698     contributer = {pabuhr@plg},
    7699     title       = {Part {II}: Securing the Building Blocks of Cyberspace},
    7700     author      = {U.S. Federal Government},
    7701     year        = 2024,
    7702     howpublished= {\url{https://www.whitehouse.gov/wp-content/uploads/2024/02/Final-ONCD-Technical-Report.pdf}},
    7703 }
    7704 
    77057688@inproceedings{Chen07,
    77067689    keywords    = {chip multiprocessors, constructive cache sharing, parallel depth first, scheduling algorithms, thread granularity, work stealing, working set profiling},
  • doc/theses/jiada_liang_MMath/test1.cfa

    rd1f5054 r26d40a1  
    11#include <fstream.hfa>                                                                  // sout
    22#include <stdlib.hfa>                                                                   // ato
    3 #include <enum.hfa>
    43
    54// integral
     
    109enum( Letter ) Greek { Alph = A, Beta = B, Gamma = G, /* more enums */ Zeta = Z }; // alphabet intersection
    1110
    12 // integral
    1311enum( char ) Currency { Dollar = '$', Cent = '¢', Yen = '¥', Pound = '£', Euro = 'E' }; // iso-latin-1
    1412enum( Currency ) Europe { Euro = Currency.Euro, Pound = Currency.Pound };
     
    3533
    3634enum() Mode { O_RDONLY, O_WRONLY, O_CREAT, O_TRUNC, O_APPEND };
    37 Mode mode = O_RDONLY;
    38 void opaque() {
    39 bool b = mode == O_RDONLY || mode < O_APPEND;   // disallowed
    40 //int www = mode;       // disallowed
    41 }
     35Mode iomode = O_RDONLY;
     36//bool b = iomode == O_RDONLY || iomode < O_APPEND;     // disallowed
     37//int www = iomode;     // disallowed
    4238
    4339enum( char * ) Colour { Red = "red", Green = "green", Blue = "blue"  };
    44 
    45 enum E1 { A1, B1, C1 = A1, D1 = B1 };
    46 enum(float) E2 { A2 = 3.5, B2 = 4.5, C2 = A, D2 = B };
    4740
    4841void fred() {
     
    5245//greek = A;                                                            // disallowed
    5346
    54         for ( Greek l = Alph; posn(l) < posn(Gamma); l = succ( l ) ) {
     47        for ( Greek l = Alph; posn(l) <= posn(Gamma); l = succ( l ) ) {
    5548                printf( "%s %c %d\n", label( l ), value( l ), posn( l ) );
    5649        }
    57         for ( Currency c = Dollar; posn(c) < posn(Currency.Euro); c = succ( c ) ) {
     50        for ( Currency c = Dollar; posn(c) <= posn(Currency.Euro); c = succ( c ) ) {
    5851                printf( "%s %c %d\n", label( c ), value( c ), posn( c ) );
    5952        }
    6053}
    6154
    62 enum( const char * ) Names { Fred = "FRED", Mary = "MARY", Jane = "JANE" };
    63 enum( const char * ) Names2 { inline Names, Jack = "JACK", Jill = "JILL" };
    64 enum( const char * ) Names3 { inline Names2, Sue = "SUE", Tom = "TOM" };
    65 void bar() {
    66         Names fred = Names.Fred;
    67         (Names2)fred;  (Names3)fred;  (Names3)Names2.Jack;  // cast to super type
    68         Names2 fred2 = fred;  Names3 fred3 = fred2; // assign to super type
    69         const char * name = fred;
    70         Names name = Fred;
    71         sout | name | label( name ) | posn( name ) | value( name );
    72 }
     55
     56enum( char * ) Names { Fred = "FRED", Mary = "MARY", Jane = "JANE" };
     57enum( char * ) Names2 { inline Names, Jack = "JACK", Jill = "JILL" };
     58enum( char * ) Names3 { inline Names2, Sue = "SUE", Tom = "TOM" };
     59
    7360void f( Names n ) { sout | "Name" | posn( n ); }
    7461void g( Names2 );
     
    7663void j( char * );
    7764
    78 enum CColour { Red, Blue, Green };
    79 CColour c0 = 0;
    80 CColour c1 = 1;
    81 CColour c = 2;
    82 int w = Red;
    83 
    84 void coo() {
    85         enum(int) Color { Red, Blue, Green };
    86         Colour c = Red;
    87         sout | countof( Colour ) | Countof( c );
    88 //      sout | Countof( Colour );
    89         sout | countof( c );
    90 }
     65enum color { red, blue, green };
     66//color c = 0;
     67//color c = 1;
     68color c = 2;
     69int w = red;
    9170
    9271// enum(int) Week ! { Mon, Tue, Wed, Thu = 10, Fri, Sat, Sun };
     
    10079// }
    10180
    102 void baz() {
    103         enum(int) Count { First, Second, Third/* = First*/, Fourth/* = Second*/ };
    104         enum CCount { First, Second, Third/* = First*/, Fourth/* = Second*/ };
    105         Count cnt = Second;
    106         CCount ccnt = Second;
    107         if ( cnt < Third ) sout | "less than Third";
    108         if ( cnt ) sout | "XXX";
    109         if ( ccnt ) sout | "YYY";
    110         enum(float) F {WWW = 0.0};
    111         F f;
    112         if ( f ) sout | "FFF";
    113         bool ?!=?( Name n, zero_t ) { sout | "DDD";  return n != Fred; }
    114         Name n = Mary;
    115         if ( n ) sout | "NAME";
    116         choose( cnt ) {
    117                 case First: sout | "First";
    118                 case Second: sout | "Second";
    119                 case Third: sout | "Third";
    120                 case Fourth: sout | "Fourth";
    121         }
    122 //      for (d; Week) { sout | d; }
    123 //      for (p; +~=Planet) { sout | p; }
    124         for ( cx; Count ) { sout | cx | nonl; } sout | nl;
    125         for ( cx; +~= Count ) { sout | cx | nonl; } sout | nl;
    126         for ( cx; -~= Count ) { sout | cx | nonl; } sout | nl;
    127         for ( Count cx = lowerBound();; ) {
    128                 sout | cx | nonl;
    129           if ( cx == upperBound() ) break;
    130                 cx = succ( cx );
    131         }
    132         sout | nl;
    133 }
    134 
    13581int main() {
    13682        fred();
    137         Names name = Names.Fred;
     83        Names name = Fred;
    13884//      f( name );
    13985
    14086        int jane_pos = posn( Names.Jane );
    141         const char * jane_value = value( Names.Jane );
    142         const char * jane_label = label( Names.Jane );
     87        char * jane_value = value( Names.Jane );
     88        char * jane_label = label( Names.Jane );
    14389        sout | Names.Jane | posn( Names.Jane) | label( Names.Jane ) | value( Names.Jane );
    144 
    145         bar();
    146         baz();
    147         coo();
    148 
    149         enum Ex { Ax, Bx, Cx, Nx };
    150         float H1[Nx] = { [Ax] : 3.4, [Bx] : 7.1, [Cx] : 0.01 }; // C
    151 //      float H2[Ex] = { [Ax] : 3.4, [Bx] : 7.1, [Cx] : 0.01 }; // CFA
    152 
    153         enum(int) E { A = 3 } e = A;
    154         sout | A | label( A ) | posn( A ) | value( A );
    155         sout | e | label( e ) | posn( e ) | value( e );
    15690}
  • doc/theses/mike_brooks_MMath/background.tex

    rd1f5054 r26d40a1  
    22
    33Since this work builds on C, it is necessary to explain the C mechanisms and their shortcomings for array, linked list, and string.
    4 
    5 
    6 \section{Ill-typed expressions}
    7 
    8 C reports many ill-typed expressions as warnings.
    9 For example, these attempts to assign @y@ to @x@ and vice-versa are obviously ill-typed.
    10 \lstinput{12-15}{bkgd-c-tyerr.c}
    11 with warnings:
    12 \begin{cfa}
    13 warning: assignment to 'float *' from incompatible pointer type 'void (*)(void)'
    14 warning: assignment to 'void (*)(void)' from incompatible pointer type 'float *'
    15 \end{cfa}
    16 Similarly,
    17 \lstinput{17-19}{bkgd-c-tyerr.c}
    18 with warning:
    19 \begin{cfa}
    20 warning: passing argument 1 of 'f' from incompatible pointer type
    21 note: expected 'void (*)(void)' but argument is of type 'float *'
    22 \end{cfa}
    23 with a segmentation fault at runtime.
    24 Clearly, @gcc@ understands these ill-typed case, and yet allows the program to compile, which seems inappropriate.
    25 Compiling with flag @-Werror@, which turns warnings into errors, is often too strong, because some warnings are just warnings, \eg unused variable.
    26 In the following discussion, ``ill-typed'' means giving a nonzero @gcc@ exit condition with a message that discusses typing.
    27 Note, \CFA's type-system rejects all these ill-typed cases as type mismatch errors.
    28 
    29 % That @f@'s attempt to call @g@ fails is not due to 3.14 being a particularly unlucky choice of value to put in the variable @pi@.
    30 % Rather, it is because obtaining a program that includes this essential fragment, yet exhibits a behaviour other than "doomed to crash," is a matter for an obfuscated coding competition.
    31 
    32 % A "tractable syntactic method for proving the absence of certain program behaviours by classifying phrases according to the kinds of values they compute"*1 rejected the program.
    33 % The behaviour (whose absence is unprovable) is neither minor nor unlikely.
    34 % The rejection shows that the program is ill-typed.
    35 %
    36 % Yet, the rejection presents as a GCC warning.
    37 % *1  TAPL-pg1 definition of a type system
    384
    395
  • doc/theses/mike_brooks_MMath/intro.tex

    rd1f5054 r26d40a1  
    11\chapter{Introduction}
    22
    3 All modern programming languages provide three high-level containers (collections): array, linked-list, and string.
    4 Often array is part of the programming language, while linked-list is built from (recursive) pointer types, and string from a combination of array and linked-list.
    5 For all three types, languages supply varying degrees of high-level mechanism for manipulating these objects at the bulk level and at the component level, such as array copy, slicing and iterating.
    6 
    7 This work looks at extending these three foundational container types in the programming language \CFA, which is a new dialect of the C programming language.
    8 A primary goal of \CFA~\cite{Cforall} is 99\% backward compatibility with C, while maintaining a look and feel that matches with C programmer experience and intuition.
    9 This goal requires ``thinking inside the box'' to engineer new features that ``work and play'' with C and its massive legacy code-base.
    10 An additional goal is balancing good performance with safety.
     3All modern programming languages provide three high-level containers (collection): array, linked-list, and string.
     4Often array is part of the programming language, while linked-list is built from pointer types, and string from a combination of array and linked-list.
     5For all three types, there is some corresponding mechanism for iterating through the structure, where the iterator flexibility varies with the kind of structure and ingenuity of the iterator implementor.
    116
    127
    138\section{Array}
    149
    15 An array provides a homogeneous container with $O(1)$ access to elements using subscripting.
     10An array provides a homogeneous container with $O(1)$ access to elements using subscripting (some form of pointer arithmetic).
    1611The array size can be static, dynamic but fixed after creation, or dynamic and variable after creation.
    1712For static and dynamic-fixed, an array can be stack allocated, while dynamic-variable requires the heap.
    18 Because array layout has contiguous components, subscripting is a computation (some form of pointer arithmetic).
     13Because array layout has contiguous components, subscripting is a computation.
     14However, the computation can exceed the array bounds resulting in programming errors and security violations~\cite{Elliott18, Blache19, Ruef19, Oorschot23}.
     15The goal is to provide good performance with safety.
    1916
    2017
    2118\section{Linked list}
    2219
    23 A linked-list provides a homogeneous container often with $O(log N)$/$O(N)$ access to elements using successor and predecessor operations that normally involve pointer chasing.
     20A linked-list provides a homogeneous container often with $O(log N)$/$O(N)$ access to elements using successor and predecessor operations.
    2421Subscripting by value is sometimes available, \eg hash table.
    2522Linked types are normally dynamically sized by adding/removing nodes using link fields internal or external to the elements (nodes).
    2623If a programming language allows pointer to stack storage, linked-list types can be allocated on the stack;
    27 otherwise, elements are heap allocated with explicitly/implicitly managed.
     24otherwise, elements are heap allocated and explicitly/implicitly managed.
    2825
    2926
     
    3128
    3229A string provides a dynamic array of homogeneous elements, where the elements are often human-readable characters.
    33 What differentiates a string from other types in that its operations work on blocks of elements for scanning and changing, \eg @index@ and @substr@.
     30What differentiates a string from other types in that its operations work on blocks of elements for scanning and changing the elements, rather than accessing individual elements, \eg @index@ and @substr@.
    3431Subscripting individual elements is often available.
    35 Therefore, the cost of string operations is less important than the power of the operations to accomplish complex text manipulation, \eg search, analysing, composing, and decomposing.
     32Often the cost of string operations is less important than the power of the operations to accomplish complex text manipulation, \eg search, analysing, composing, and decomposing.
    3633The dynamic nature of a string means storage is normally heap allocated but often implicitly managed, even in unmanaged languages.
    37 Often string management is separate from heap management, \ie strings roll their own heap.
    3834
    3935
    4036\section{Motivation}
    4137
    42 The primary motivation for this work is two fold:
    43 \begin{enumerate}[leftmargin=*]
    44 \item
    45 These three aspects of C are extremely difficult to understand, teach, and get right because they are correspondingly extremely low level.
    46 Providing higher-level versions of these containers in \CFA is a major component of the primary goal.
    47 \item
    48 These three aspects of C cause the greatest safety issues because there are few or no safe guards when a programmer misunderstands or misuses these features~\cite{Elliott18, Blache19, Ruef19, Oorschot23}.
    49 Estimates suggest 50\%~\cite{Mendio24} of total reported open-source vulnerabilities occur in C resulting from errors using these facilities (memory errors), providing the major hacker attack-vectors.
    50 \end{enumerate}
    51 Both White House~\cite{WhiteHouse24} and DARPA~\cite{DARPA24} recently released a recommendation to move away from C and \CC, because of cybersecurity threats exploiting vulnerabilities in these older languages.
    52 Hardening these three types goes a long way to make the majority of C programs safer.
    53 
    54 
    55 While multiple new languages purport to be systems languages replacing C, the reality is that rewriting massive C code-bases is impractical and a non-starter if the new runtime uses garage collection.
    56 Furthermore, these languages must still interact with the underlying C operating system through fragile, type-unsafe, interlanguage-communication.
    57 Switching to \CC is equally impractical as its complex and interdependent type-system (\eg objects, inheritance, templates) means idiomatic \CC code is difficult to use from C, and C programmers must expend significant effort learning \CC.
    58 Hence, rewriting and retraining costs for these languages can be prohibitive for companies with a large C software-base (Google, Apple, Microsoft, Amazon, AMD, Nvidia).
     38The goal of this work is to introduce safe and complex versions of array, link lists, and strings into the programming language \CFA~\cite{Cforall}, which is based on C.
     39Unfortunately, to make C better, while retaining a high level of backwards compatibility, requires a significant knowledge of C's design.
     40Hence, it is assumed the reader has a medium knowledge of C or \CC, on which extensive new C knowledge is built.
    5941
    6042
     
    6446However, most programming languages are only partially explained by standard's manuals.
    6547When it comes to explaining how C works, the definitive source is the @gcc@ compiler, which is mimicked by other C compilers, such as Clang~\cite{clang}.
    66 Often other C compilers must mimic @gcc@ because a large part of the C library (runtime) system (@glibc@ on Linux) contains @gcc@ features.
    67 While some key aspects of C need to be explained by quoting from the language reference manual, to illustrate definite program semantics, my approach in this thesis is to devise a program, whose behaviour exercises a point at issue, and shows its behaviour.
     48Often other C compilers must mimic @gcc@ because a large part of the C library (runtime) system contains @gcc@ features.
     49While some key aspects of C need to be explained by quoting from the language reference manual, to illustrate definite program semantics, I devise a program, whose behaviour exercises the point at issue, and shows its behaviour.
    6850These example programs show
    69 \begin{itemize}[leftmargin=*]
    70         \item if the compiler accepts or rejects certain syntax,
     51\begin{itemize}
     52        \item the compiler accepts or rejects certain syntax,
    7153        \item prints output to buttress a claim of behaviour,
    72         \item or executes without triggering any embedded assertions testing pre/post-assertions or invariants.
     54        \item executes without triggering any embedded assertions testing pre/post-assertions or invariants.
    7355\end{itemize}
    7456This work has been tested across @gcc@ versions 8--12 and clang version 10 running on ARM, AMD, and Intel architectures.
    7557Any discovered anomalies among compilers or versions is discussed.
    76 In all case, it is never clear whether the \emph{truth} lies in the compiler or the C standard.
     58In all case, I do not argue that my sample of major Linux compilers is doing the right thing with respect to the C standard.
     59
     60
     61\subsection{Ill-typed expressions}
     62
     63C reports many ill-typed expressions as warnings.
     64For example, these attempts to assign @y@ to @x@ and vice-versa are obviously ill-typed.
     65\lstinput{12-15}{bkgd-c-tyerr.c}
     66with warnings:
     67\begin{cfa}
     68warning: assignment to 'float *' from incompatible pointer type 'void (*)(void)'
     69warning: assignment to 'void (*)(void)' from incompatible pointer type 'float *'
     70\end{cfa}
     71Similarly,
     72\lstinput{17-19}{bkgd-c-tyerr.c}
     73with warning:
     74\begin{cfa}
     75warning: passing argument 1 of 'f' from incompatible pointer type
     76note: expected 'void (*)(void)' but argument is of type 'float *'
     77\end{cfa}
     78with a segmentation fault at runtime.
     79Clearly, @gcc@ understands these ill-typed case, and yet allows the program to compile, which seems inappropriate.
     80Compiling with flag @-Werror@, which turns warnings into errors, is often too strong, because some warnings are just warnings, \eg unsed variable.
     81In the following discussion, ``ill-typed'' means giving a nonzero @gcc@ exit condition with a message that discusses typing.
     82Note, \CFA's type-system rejects all these ill-typed cases as type mismatch errors.
     83
     84% That @f@'s attempt to call @g@ fails is not due to 3.14 being a particularly unlucky choice of value to put in the variable @pi@.
     85% Rather, it is because obtaining a program that includes this essential fragment, yet exhibits a behaviour other than "doomed to crash," is a matter for an obfuscated coding competition.
     86
     87% A "tractable syntactic method for proving the absence of certain program behaviours by classifying phrases according to the kinds of values they compute"*1 rejected the program.
     88% The behaviour (whose absence is unprovable) is neither minor nor unlikely.
     89% The rejection shows that the program is ill-typed.
     90%
     91% Yet, the rejection presents as a GCC warning.
     92% *1  TAPL-pg1 definition of a type system
    7793
    7894
  • doc/theses/mike_brooks_MMath/string.tex

    rd1f5054 r26d40a1  
    11\chapter{String}
    22
    3 
    4 
    5 
     3\section{String}
    64
    75\subsection{Logical overlap}
  • doc/theses/mike_brooks_MMath/uw-ethesis.bib

    rd1f5054 r26d40a1  
    114114    pages       = {53-60},
    115115}
    116 
    117 
    118 @misc{Mendio24,
    119     contributer = {pabuhr@plg},
    120     title       = {What are the most secure programming languages?},
    121     author      = {Mend.io (White Source Ltd.)},
    122     year        = 2024,
    123     howpublished= {\url{https://www.mend.io/most-secure-programming-languages}},
    124 }
  • libcfa/src/concurrency/io/call.cfa.in

    rd1f5054 r26d40a1  
    214214        __attribute__((unused)) bool parked;
    215215        parked = wait( future );
    216 #if defined(CFA_HAVE_LINUX_IO_URING_H)
    217216        __STATS__(false, if(!parked) io.submit.nblk += 1; )
    218 #endif
    219217        if( future.result < 0 ) {{
    220218                errno = -future.result;
  • src/AST/Expr.hpp

    rd1f5054 r26d40a1  
    1111// Last Modified By : Peter A. Buhr
    1212// Created On       : Fri May 10 10:30:00 2019
    13 // Update Count     : 8
     13// Update Count     : 7
    1414//
    1515
     
    8686
    8787                /// initializes from other InferUnion
    88                 void init_from( const InferUnion & o ) {
     88                void init_from( const InferUnion& o ) {
    8989                        if (o.data.resnSlots) {
    9090                                data.resnSlots = new ResnSlots(*o.data.resnSlots);
     
    9696
    9797                /// initializes from other InferUnion (move semantics)
    98                 void init_from( InferUnion && o ) {
     98                void init_from( InferUnion&& o ) {
    9999                        data.resnSlots = o.data.resnSlots;
    100100                        data.inferParams = o.data.inferParams;
     
    104104
    105105                InferUnion() : mode(Empty), data() {}
    106                 InferUnion( const InferUnion & o ) : mode( o.mode ), data() { init_from( o ); }
    107                 InferUnion( InferUnion && o ) : mode( o.mode ), data() { init_from( std::move(o) ); }
    108                 InferUnion & operator= ( const InferUnion & ) = delete;
    109                 InferUnion & operator= ( InferUnion && ) = delete;
     106                InferUnion( const InferUnion& o ) : mode( o.mode ), data() { init_from( o ); }
     107                InferUnion( InferUnion&& o ) : mode( o.mode ), data() { init_from( std::move(o) ); }
     108                InferUnion& operator= ( const InferUnion& ) = delete;
     109                InferUnion& operator= ( InferUnion&& ) = delete;
    110110
    111111                bool hasSlots() const { return data.resnSlots; }
    112112                bool hasParams() const { return data.inferParams; }
    113113
    114                 ResnSlots & resnSlots() {
     114                ResnSlots& resnSlots() {
    115115                        if (!data.resnSlots) {
    116116                                data.resnSlots = new ResnSlots();
     
    119119                }
    120120
    121                 const ResnSlots & resnSlots() const {
     121                const ResnSlots& resnSlots() const {
    122122                        if (data.resnSlots) {
    123123                                return *data.resnSlots;
     
    127127                }
    128128
    129                 InferredParams & inferParams() {
     129                InferredParams& inferParams() {
    130130                        if (!data.inferParams) {
    131131                                data.inferParams = new InferredParams();
     
    134134                }
    135135
    136                 const InferredParams & inferParams() const {
     136                const InferredParams& inferParams() const {
    137137                        if (data.inferParams) {
    138138                                return *data.inferParams;
     
    669669        ptr<ApplicationExpr> callExpr;
    670670
    671         ImplicitCopyCtorExpr( const CodeLocation & loc, const ApplicationExpr * call )
     671        ImplicitCopyCtorExpr( const CodeLocation& loc, const ApplicationExpr * call )
    672672        : Expr( loc, call->result ), callExpr(call) { assert( call ); assert(call->result); }
    673673
  • src/CodeGen/CodeGenerator.cpp

    rd1f5054 r26d40a1  
    7979                currentLocation.first_line += 2;
    8080        } else {
    81                 output << "\n# " << to.first_line << " \"" << to.filename.c_str()
     81                output << "\n# " << to.first_line << " \"" << to.filename
    8282                       << "\"\n" << indent;
    8383                currentLocation = to;
  • src/Common/CodeLocation.hpp

    rd1f5054 r26d40a1  
    1717
    1818#include <iostream>
    19 #include "Symbol.hpp"
     19#include <string>
    2020
    2121struct CodeLocation {
    2222        int first_line = -1, first_column = -1, last_line = -1, last_column = -1;
    23         Symbol filename = "";
     23        std::string filename = "";
    2424
    2525        /// Create a new unset CodeLocation.
     
    4646
    4747        bool startsBefore( CodeLocation const & other ) const {
    48                 if( filename.str() < other.filename.str() ) return true;
    49                 if( filename.str() > other.filename.str() ) return false;
     48                if( filename < other.filename ) return true;
     49                if( filename > other.filename ) return false;
    5050
    5151                if( first_line < other.first_line ) return true;
     
    7272inline std::ostream & operator<<( std::ostream & out, const CodeLocation & location ) {
    7373        // Column number ":1" allows IDEs to parse the error message and position the cursor in the source text.
    74         return location.isSet() ? out << location.filename.str() << ":" << location.first_line << ":1 " : out;
     74        return location.isSet() ? out << location.filename << ":" << location.first_line << ":1 " : out;
    7575}
  • src/Common/module.mk

    rd1f5054 r26d40a1  
    4848        Common/Stats/Time.cpp \
    4949        Common/Stats/Time.hpp \
    50         Common/Symbol.cpp \
    51         Common/Symbol.hpp \
    5250        Common/ToString.hpp \
    5351        Common/UniqueName.cpp \
  • src/GenPoly/Lvalue.cpp

    rd1f5054 r26d40a1  
    1010// Created On       : Thu Sep 15 14:08:00 2022
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Aug 12 18:07:00 2024
    13 // Update Count     : 1
     12// Last Modified On : Wed Oct  6  9:59:00 2022
     13// Update Count     : 0
    1414//
    1515
     
    119119/// Replace all reference types with pointer types.
    120120struct ReferenceTypeElimination final {
    121         ast::SizeofExpr const * previsit( ast::SizeofExpr const * expr );
    122         ast::AlignofExpr const * previsit( ast::AlignofExpr const * expr );
    123121        ast::Type const * postvisit( ast::ReferenceType const * type );
    124122};
     
    605603}
    606604
    607 ast::SizeofExpr const * ReferenceTypeElimination::previsit(
    608                 ast::SizeofExpr const * expr ) {
    609         if ( expr->expr ) return expr;
    610         return ast::mutate_field( expr, &ast::SizeofExpr::type,
    611                 expr->type->stripReferences() );
    612 }
    613 
    614 ast::AlignofExpr const * ReferenceTypeElimination::previsit(
    615                 ast::AlignofExpr const * expr ) {
    616         if ( expr->expr ) return expr;
    617         return ast::mutate_field( expr, &ast::AlignofExpr::type,
    618                 expr->type->stripReferences() );
    619 }
    620 
    621605ast::Type const * ReferenceTypeElimination::postvisit(
    622606                ast::ReferenceType const * type ) {
  • src/InitTweak/FixInit.cpp

    rd1f5054 r26d40a1  
    731731        try {
    732732                mutLast->expr = makeCtorDtor( "?{}", ret, mutLast->expr );
    733         } catch (...) {
     733        } catch(...) {
    734734                std::cerr << "*CFA internal error: ";
    735735                std::cerr << "can't resolve implicit constructor";
    736                 std::cerr << " at " << stmtExpr->location.filename.c_str();
     736                std::cerr << " at " << stmtExpr->location.filename;
    737737                std::cerr << ":" << stmtExpr->location.first_line << std::endl;
    738738
  • src/Parser/parser.yy

    rd1f5054 r26d40a1  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug 13 11:25:16 2024
    13 // Update Count     : 6740
     12// Last Modified On : Fri Jul 26 14:09:30 2024
     13// Update Count     : 6733
    1414//
    1515
     
    952952                }
    953953        | COUNTOF unary_expression
    954                 { $$ = new ExpressionNode( new ast::CountExpr( yylloc, maybeMoveBuild( $2 ) ) ); }
     954                {  $$ = new ExpressionNode( new ast::CountExpr( yylloc, maybeMoveBuild( $2 ) ) ); }
    955955        | COUNTOF '(' type_no_function ')'
    956956                { $$ = new ExpressionNode( new ast::CountExpr( yylloc, maybeMoveBuildType( $3 ) ) ); }
     
    16261626enum_key:
    16271627        type_name
    1628                 {
    1629                         typedefTable.makeTypedef( *$1->symbolic.name, "enum_type_nobody 1" );
    1630                         $$ = DeclarationNode::newEnum( $1->symbolic.name, nullptr, false, false );
    1631                 }
     1628                {       typedefTable.makeTypedef( *$1->symbolic.name, "enum_type_nobody 1" );
     1629                        $$ = DeclarationNode::newEnum( $1->symbolic.name, nullptr, false, false ); }
    16321630        | ENUM identifier
    1633                 {
    1634                         typedefTable.makeTypedef( *$2, "enum_type_nobody 2" );
    1635                         $$ = DeclarationNode::newEnum( $2, nullptr, false, false );
    1636                 }
     1631                {       typedefTable.makeTypedef( *$2, "enum_type_nobody 2" );
     1632                        $$ = DeclarationNode::newEnum( $2, nullptr, false, false ); }
    16371633        | ENUM type_name
    1638                 {
    1639                         typedefTable.makeTypedef( *$2->symbolic.name, "enum_type_nobody 3" );
    1640                         $$ = DeclarationNode::newEnum( $2->symbolic.name, nullptr, false, false );
    1641                 }
     1634                {       typedefTable.makeTypedef( *$2->symbolic.name, "enum_type_nobody 3" );
     1635                        $$ = DeclarationNode::newEnum( $2->symbolic.name, nullptr, false, false ); }
    16421636        ;
    16431637
     
    18551849
    18561850handler_clause:
    1857         handler_key '(' exception_declaration handler_predicate_opt ')' compound_statement
    1858                 { $$ = new ClauseNode( build_catch( yylloc, $1, $3, $4, $6 ) ); }
    1859         | handler_clause handler_key '(' exception_declaration handler_predicate_opt ')' compound_statement
    1860                 { $$ = $1->set_last( new ClauseNode( build_catch( yylloc, $2, $4, $5, $7 ) ) ); }
     1851        handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement
     1852                { $$ = new ClauseNode( build_catch( yylloc, $1, $4, $6, $8 ) ); }
     1853        | handler_clause handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement
     1854                { $$ = $1->set_last( new ClauseNode( build_catch( yylloc, $2, $5, $7, $9 ) ) ); }
    18611855        ;
    18621856
     
    28562850
    28572851enumerator_list:
    2858         // empty
    2859                 { SemanticError( yylloc, "enumeration must have a minimum of one enumerator, empty enumerator list is meaningless." );  $$ = nullptr; }
    2860         | visible_hide_opt identifier_or_type_name enumerator_value_opt
     2852        visible_hide_opt identifier_or_type_name enumerator_value_opt
    28612853                { $$ = DeclarationNode::newEnumValueGeneric( $2, $3 ); }
    28622854        | INLINE type_name
     
    31633155        '|' identifier_or_type_name '(' type_list ')'
    31643156                { $$ = DeclarationNode::newTraitUse( $2, $4 ); }
    3165         | '|' '{' trait_declaration_list '}'
    3166                 { $$ = $3; }
     3157        | '|' '{' push trait_declaration_list pop '}'
     3158                { $$ = $4; }
    31673159        // | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list pop '}' '(' type_list ')'
    31683160        //      { SemanticError( yylloc, "Generic data-type assertion is currently unimplemented." ); $$ = nullptr; }
     
    32163208        | forall TRAIT identifier_or_type_name '{' '}'          // alternate
    32173209                { $$ = DeclarationNode::newTrait( $3, $1, nullptr ); }
    3218         | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' trait_declaration_list '}'
     3210        | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}'
    32193211                {
    32203212                        SemanticWarning( yylloc, Warning::DeprecTraitSyntax );
    3221                         $$ = DeclarationNode::newTrait( $2, $4, $7 );
    3222                 }
    3223         | forall TRAIT identifier_or_type_name '{' trait_declaration_list '}' // alternate
    3224                 { $$ = DeclarationNode::newTrait( $3, $1, $5 ); }
     3213                        $$ = DeclarationNode::newTrait( $2, $4, $8 );
     3214                }
     3215        | forall TRAIT identifier_or_type_name '{' push trait_declaration_list pop '}' // alternate
     3216                { $$ = DeclarationNode::newTrait( $3, $1, $6 ); }
    32253217        ;
    32263218
    32273219trait_declaration_list:                                                                 // CFA
    32283220        trait_declaration
    3229         | trait_declaration_list trait_declaration
    3230                 { $$ = $1->set_last( $2 ); }
     3221        | trait_declaration_list pop push trait_declaration
     3222                { $$ = $1->set_last( $4 ); }
    32313223        ;
    32323224
     
    32393231        cfa_variable_specifier
    32403232        | cfa_function_specifier
    3241         | cfa_trait_declaring_list ',' identifier_or_type_name
    3242                 { $$ = $1->set_last( $1->cloneType( $3 ) ); }
     3233        | cfa_trait_declaring_list pop ',' push identifier_or_type_name
     3234                { $$ = $1->set_last( $1->cloneType( $5 ) ); }
    32433235        ;
    32443236
    32453237trait_declaring_list:                                                                   // CFA
    3246                 // Cannot declare an aggregate or enumeration in a trait.
    3247         type_specifier_nobody declarator
     3238        type_specifier declarator
    32483239                { $$ = $2->addType( $1 ); }
    3249         | trait_declaring_list ',' declarator
    3250                 { $$ = $1->set_last( $1->cloneBaseType( $3 ) ); }
    3251         | error
    3252                 { SemanticError( yylloc, "Possible cause is declaring an aggregate or enumeration type in a trait." ); $$ = nullptr; }
     3240        | trait_declaring_list pop ',' push declarator
     3241                { $$ = $1->set_last( $1->cloneBaseType( $5 ) ); }
    32533242        ;
    32543243
  • src/ResolvExpr/CandidateFinder.cpp

    rd1f5054 r26d40a1  
    12811281                                // count one safe conversion for each value that is thrown away
    12821282                                thisCost.incSafe( discardedValues );
    1283 
    1284                                 // See Aaron Moss, page 47; this reasoning does not hold since implicit conversions
    1285                                 // can create the same resolution issue. The C intrinsic interpretations are pruned
    1286                                 // immediately for the lowest cost option regardless of result type. Related code in
    1287                                 // postvisit (UntypedExpr).
    1288                                 // Cast expression costs are updated now to use the general rules.
    1289                                 /*
    12901283                                // select first on argument cost, then conversion cost
    12911284                                if ( cand->cost < minExprCost || ( cand->cost == minExprCost && thisCost < minCastCost ) ) {
     
    12961289                                // ambigious case, still output candidates to print in error message
    12971290                                if ( cand->cost == minExprCost && thisCost == minCastCost ) {
    1298                                 */
    1299                                 cand->cost += thisCost;
    1300                                 if (cand->cost < minExprCost) {
    1301                                         minExprCost = cand->cost;
    1302                                         matches.clear();
    1303                                 }
    1304                                 if (cand->cost == minExprCost) {
    13051291                                        CandidateRef newCand = std::make_shared<Candidate>(
    13061292                                                restructureCast( cand->expr, toType, castExpr->isGenerated ),
    1307                                                 copy( cand->env ), std::move( open ), std::move( need ), cand->cost);
     1293                                                copy( cand->env ), std::move( open ), std::move( need ), cand->cost + thisCost);
    13081294                                        // currently assertions are always resolved immediately so this should have no effect.
    13091295                                        // if this somehow changes in the future (e.g. delayed by indeterminate return type)
  • tests/time.cfa

    rd1f5054 r26d40a1  
    1010// Created On       : Tue Mar 27 17:24:56 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug 13 09:09:47 2024
    13 // Update Count     : 76
     12// Last Modified On : Fri Jul 19 08:06:59 2024
     13// Update Count     : 75
    1414//
    1515
     
    1818#include <stdlib.h>                                                                             // putenv
    1919
    20 extern "C" size_t malloc_unfreed() { return 2048; }             // guess at unfreed storage from putenv/tzset
     20extern "C" size_t malloc_unfreed() { return 1024; }             // guess at unfreed storage from putenv
    2121
    2222int main() {
    2323        // Set fixed time location to obtain repeatable output where ever run.
    24         putenv( "TZ=America/Toronto" );                                         // pick fixed time zone
     24        putenv( "TZ=America/Toronto" );                                         // set fixed time zone
    2525        // tzset has the stupidest interface I have ever seen.
    2626        tzset();                                                                                        // set time zone
Note: See TracChangeset for help on using the changeset viewer.