Ignore:
Timestamp:
Oct 15, 2020, 9:41:31 PM (12 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
afe2939
Parents:
0b18db7
Message:

Expanding earlier #182 fix to another case of the same issue. Fixes #224?

There is now a reusable helper function addDataSectonAttribute that applies the fix to an ObjectDecl? when we realize it needs it. Test const-init is expanded with case of #224.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/const-init.cfa

    r0b18db7 rf1791a4  
    1616/*
    1717
    18 This test shows non-crashing of generated code for constants with interesting initizers.
     18These tests show non-crashing of generated code for constants with interesting initializers.
    1919The potential for these to crash is compiler dependent.
    2020
    2121There are two cases:
    22 1. static constants in one compilation unit (tested here)
     221. static constants in one compilation unit (tested here, in a few sub-cases)
    23232. extern constants across compilation units (tested by libcfa being loadable, specifically
    24    the constant declarations in libcfa/src/limits.cfa, which almost every test exercises,
     24   the constant definitions in libcfa/src/limits.cfa, which almost every test exercises,
    2525   including "hello;" but notably, the "limits" test does not exercise it because that test
    2626   is compile-only)
     
    3737GCC-10 on Ubuntu 20.04    Has crashed      Has crashed
    3838
    39 For this test case to fail, with most other tests passing, would be a situation only ever
     39For this test to fail, with most other tests passing, would be a situation only ever
    4040observed with GCC-8.
    4141
    4242*/
    4343
     44// initailized by generated function, called before main
    4445static const char foo = -1;
    4546
     47struct thing{};
     48void ^?{}( thing & ) { printf("dtor\n"); }
     49
    4650int main() {
    47     printf("done\n");
     51    // foo is already initialized
     52
     53    // no dtor => stays a (static) local, initialized here
     54    static const char bar = -1;
     55
     56    // has dtor => becomes a global, ctor called here, dtor called at exit
     57    static const thing it;
     58
     59    printf("almost done\n");
    4860}
Note: See TracChangeset for help on using the changeset viewer.