diff --git a/src/kernel_internals/typing/cabs2cil.ml b/src/kernel_internals/typing/cabs2cil.ml index 3137c53e5a21baab52734c1af0bbd3abc3009467..c6490fa0157ea47853823fff2f61fd7061e5a11d 100644 --- a/src/kernel_internals/typing/cabs2cil.ml +++ b/src/kernel_internals/typing/cabs2cil.ml @@ -4343,7 +4343,11 @@ let rec doSpecList ghost (suggestedAnonName: string) * collected and processed separately. *) let attrs : A.attribute list ref = ref [] in (* __attribute__, etc. *) let cvattrs : A.cvspec list ref = ref [] in (* const/volatile *) - + let suggestedAnonName = + if suggestedAnonName <> "" then suggestedAnonName + else if get_current_stdheader () = "" then "" + else "fc_stdlib" + in let doSpecElem (se: A.spec_elem) (acc: A.typeSpecifier list) : A.typeSpecifier list = diff --git a/tests/syntax/anon_enum_libc.c b/tests/syntax/anon_enum_libc.c new file mode 100644 index 0000000000000000000000000000000000000000..f59a10e2cf3bafc3c3d3f0ec95b5454ceb9f1b19 --- /dev/null +++ b/tests/syntax/anon_enum_libc.c @@ -0,0 +1,13 @@ +/* run.config +OPT: -cpp-extra-args="-I @PTEST_DIR@" -ocode @PTEST_DIR@/result/@PTEST_NAME@.c -print -then -ocode="" @PTEST_DIR@/result/@PTEST_NAME@.c -print +*/ + +struct { int x; float y; } s1; + +enum { BLA=4, BLI=12 }; + +#include "anon_enum_libc.h" + +int f() { return BLA + s1.x; } + +int g() { return FOO + s2.t; } diff --git a/tests/syntax/anon_enum_libc.h b/tests/syntax/anon_enum_libc.h new file mode 100644 index 0000000000000000000000000000000000000000..e659c07ea7ea7e8c9b91dd5d2351d341af180ca6 --- /dev/null +++ b/tests/syntax/anon_enum_libc.h @@ -0,0 +1,5 @@ +#include "features.h" +__PUSH_FC_STDLIB +struct { char z; unsigned long t; } s2; +enum { FOO, BAR=3 }; +__POP_FC_STDLIB diff --git a/tests/syntax/oracle/anon_enum_libc.res.oracle b/tests/syntax/oracle/anon_enum_libc.res.oracle new file mode 100644 index 0000000000000000000000000000000000000000..0c3e5392e4f093c75d66e6426534fd81cf341e49 --- /dev/null +++ b/tests/syntax/oracle/anon_enum_libc.res.oracle @@ -0,0 +1,28 @@ +[kernel] Parsing tests/syntax/anon_enum_libc.c (with preprocessing) +[kernel] Parsing tests/syntax/result/anon_enum_libc.c (with preprocessing) +/* Generated by Frama-C */ +#include "/home/virgile/Frama-C/frama-c-stable/tests/syntax/anon_enum_libc.h" +struct __anonstruct_s1_1 { + int x ; + float y ; +}; +enum __anonenum_2 { + BLA = 4, + BLI = 12 +}; +struct __anonstruct_s1_1 s1; +int f(void) +{ + int __retres; + __retres = BLA + s1.x; + return __retres; +} + +int g(void) +{ + int __retres; + __retres = (int)((unsigned long)FOO + s2.t); + return __retres; +} + +