Ignore:
Timestamp:
Feb 6, 2025, 3:42:32 PM (11 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
eca364f7
Parents:
a8e2215
Message:

first attempt at generalizing attributes to statements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/attributes.cfa

    ra8e2215 rcd28605  
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 //
    7 // attributes.cfa --
     6// 
     7// attributes.cfa -- 
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Mon Feb  6 16:07:02 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec 20 15:32:21 2024
    13 // Update Count     : 53
     12// Last Modified On : Thu Feb  6 12:06:22 2025
     13// Update Count     : 117
    1414//
    1515
     
    3737
    3838// field_declaring_list
     39typedef short int shint;
    3940struct Fdl {
    4041    int f1 __attribute__(( unused ));
     
    5051    int ( ( __attribute__(( unused )) * (f13)  __attribute__(( unused )) ) __attribute__(( unused )) );
    5152    int ( ( ( __attribute__(( unused )) * (f14) )  __attribute__(( unused )) ) __attribute__(( unused )) );
     53//      shint __attribute__(( used )) shi1;
     54//      shint __attribute__(( used )) shi2 __attribute__(( used ));
     55        __attribute__(( used )) shint shi3;
     56        __attribute__(( used )) shint shi4 __attribute__(( used ));
     57//      __attribute__(( used )) shint __attribute__(( used )) shi5 __attribute__(( used ));
    5258};
    5359
     
    6369const __attribute__(( used )) int __attribute__(( used )) (* __attribute__(( used )) vd7)() __attribute__(( used )), __attribute__(( unused )) ((* __attribute__(( used )) vd8)()) __attribute__(( used ));
    6470const __attribute__(( used )) int __attribute__(( used )) ( __attribute__(( used )) * vd9)() __attribute__(( used )), __attribute__(( unused )) (( __attribute__(( used )) * vd10)()) __attribute__(( used ));
     71
    6572
    6673// function_declarator
     
    9198    __attribute__(( unused )) int __attribute__(( unused )) * __attribute__(( unused )) ((t6))() __attribute__(( unused ));
    9299}
    93 
    94100
    95101// identifier_parameter_declarator
     
    164170};
    165171
    166 [[ noreturn ]] void fred() {
     172
     173// statments
     174void fred() {
    167175        int [[unused]] i;
    168176        // C23 attributes are parsed but not pushed through the compiler.
    169177        // int [[gnu::xxx]] j;
    170178        switch ( 3 ) {
     179                __attribute__((unused)) int ret;
    171180          case 2:
    172181                4;
    173 //              __attribute__(( fallthrough ))
    174 //              [[fallthrough]]
     182                __attribute__(( fallthrough ));
     183                [[fallthrough]];
    175184          case 1:
    176185                3;
    177186        }
    178         abort();
    179 }
    180 
    181 @[ noreturn ] void mary() {
    182         @[aligned(16)] struct S { int i; };
     187  L : __attribute__(( unused )) goto L;
     188  L1 : [[ unused ]] L2 : [[ unused ]] goto L2;
     189        __attribute__(( unused )) return;
     190        [[ noreturn ]] return;
     191        __attribute__(( noreturn )) return;
     192        [[ GNU::fred ]] i += 1;
     193}
     194
     195void mary() {
     196        @[aligned(64)] struct S { int i; };
    183197        int @[unused] i;
    184198        switch ( 3 ) {
    185199          case 2:
    186200                4;
    187 //              __attribute__(( fallthrough ))
    188 //              [[fallthrough]]
     201                __attribute__(( fallthrough ));
     202                @[fallthrough];
    189203          case 1:
    190204                3;
    191205        }
    192         abort();
     206  L : __attribute__(( unused )) goto L;
     207  L1 : @[ unused ] L2 : @[ unused ] goto L2;
     208        __attribute__(( unused )) return;
     209        @[ noreturn ] return;
     210        __attribute__(( noreturn )) return;
     211}
     212
     213[[ noreturn ]] void jack() {
     214        exit( -1 );
    193215}
    194216
Note: See TracChangeset for help on using the changeset viewer.