Changeset 85a95cc


Ignore:
Timestamp:
Mar 13, 2023, 6:25:27 PM (21 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, master
Children:
02b1ac6
Parents:
1cdc052
Message:

add test for problem with anonymous naming across compilation units

Location:
tests/linking/mangling
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • tests/linking/mangling/header.hfa

    r1cdc052 r85a95cc  
    88extern name_but_a_typedefed_t a_typedefed_global;
    99
    10 extern struct /* anonymous */ {
    11         int some_int;
    12         int some_other_int;
    13 } a_global_with_no_type;
     10// Must be extern C to prevent name mangling.
     11extern "C" {
     12        extern struct /* anonymous */ {
     13                int some_int;
     14                int some_other_int;
     15        } a_global_with_no_type;
     16}
  • tests/linking/mangling/lib.cfa

    r1cdc052 r85a95cc  
    33name_but_a_typedefed_t a_typedefed_global;
    44
    5 struct {
    6         int some_int;
    7         int some_other_int;
    8 } a_global_with_no_type;
     5// Must be extern C to prevent name mangling.
     6extern "C" {
     7        // This declaration is necessary to create an instance of a_global_with_no_type.
     8        // typeof is a trick to get a_global_with_no_type's type because its type is anonymous.
     9        // Otherwise C generates conflicting types for a_global_with_no_type in .h and .c
     10        // because C uses name equivalence and the two anonymous types cannot have the same name.
     11        typeof(a_global_with_no_type) a_global_with_no_type;
     12}
  • tests/linking/mangling/main.cfa

    r1cdc052 r85a95cc  
    11#include <fstream.hfa>
    22
    3 struct { int a; } test; //purposefully before the include
     3static struct { int a; } test; // purposefully before the include to force anonymous name numbering
    44
    55#include "header.hfa"
     
    1313
    1414        sout | "Done!";
    15 
    16         return 0;
    1715}
Note: See TracChangeset for help on using the changeset viewer.