Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 594

Show
Ignore:
Timestamp:
08/03/10 00:53:04 (14 years ago)
Author:
walter
Message:

Bugzilla 4569 extern(c++) doesn't understand const types, produces bad mangled symbol

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dmd-1.x/src/cppmangle.c

    r428 r594  
    11 
    22// Compiler implementation of the D programming language 
    3 // Copyright (c) 1999-2007 by Digital Mars 
     3// Copyright (c) 1999-2010 by Digital Mars 
    44// All Rights Reserved 
    55// written by Walter Bright 
    66// http://www.digitalmars.com 
    77// License for redistribution is by either the Artistic License 
    88// in artistic.txt, or the GNU General Public License in gnu.txt. 
    99// See the included readme.txt for details. 
    1010 
    1111#include <stdio.h> 
    1212#include <assert.h> 
    1313 
    1414#include "mars.h" 
    1515#include "dsymbol.h" 
    1616#include "mtype.h" 
    1717#include "scope.h" 
    1818#include "init.h" 
    1919#include "expression.h" 
    2020#include "attrib.h" 
    2121#include "declaration.h" 
    2222#include "template.h" 
    2323#include "id.h" 
    2424#include "enum.h" 
    2525#include "import.h" 
    2626#include "aggregate.h" 
    2727 
    28 #if DMDV2 
     28#if CPP_MANGLE 
    2929 
    3030/* Do mangling for C++ linkage. 
    3131 * Follows Itanium C++ ABI 1.86 
    3232 * No attempt is made to support mangling of templates, operator 
    3333 * overloading, or special functions. 
    3434 * 
    3535 * So why don't we use the C++ ABI for D name mangling? 
    3636 * Because D supports a lot of things (like modules) that the C++ 
    3737 * ABI has no concept of. These affect every D mangled name, 
    3838 * so nothing would be compatible anyway. 
    3939 */ 
    4040 
    4141struct CppMangleState 
    4242{ 
    4343    static Array components; 
    4444 
    4545    int substitute(OutBuffer *buf, void *p); 
    4646}; 
    4747 
    4848Array CppMangleState::components; 
     
    181181     * a        signed char 
    182182     * h        unsigned char 
    183183     * s        short 
    184184     * t        unsigned short 
    185185     * i        int 
    186186     * j        unsigned int 
    187187     * l        long 
    188188     * m        unsigned long 
    189189     * x        long long, __int64 
    190190     * y        unsigned long long, __int64 
    191191     * n        __int128 
    192192     * o        unsigned __int128 
    193193     * f        float 
    194194     * d        double 
    195195     * e        long double, __float80 
    196196     * g        __float128 
    197197     * z        ellipsis 
    198198     * u <source-name>  # vendor extended type 
    199199     */ 
    200200 
     201    if (isConst()) 
     202        buf->writeByte('K'); 
     203 
    201204    switch (ty) 
    202205    { 
    203206        case Tvoid:     c = 'v';        break; 
    204207        case Tint8:     c = 'a';        break; 
    205208        case Tuns8:     c = 'h';        break; 
    206209        case Tint16:    c = 's';        break; 
    207210        case Tuns16:    c = 't';        break; 
    208211        case Tint32:    c = 'i';        break; 
    209212        case Tuns32:    c = 'j';        break; 
    210213        case Tfloat32:  c = 'f';        break; 
    211214        case Tint64:    c = 'x';        break; 
    212215        case Tuns64:    c = 'y';        break; 
    213216        case Tfloat64:  c = 'd';        break; 
    214217        case Tfloat80:  c = 'e';        break; 
    215218        case Tbool:     c = 'b';        break; 
    216219        case Tchar:     c = 'c';        break; 
    217220        case Twchar:    c = 't';        break; 
    218221        case Tdchar:    c = 'w';        break; 
    219222 
    220223        case Timaginary32: p = 'G'; c = 'f';    break; 
  • trunk/src/cppmangle.c

    r428 r594  
    11 
    22// Compiler implementation of the D programming language 
    3 // Copyright (c) 1999-2009 by Digital Mars 
     3// Copyright (c) 1999-2010 by Digital Mars 
    44// All Rights Reserved 
    55// written by Walter Bright 
    66// http://www.digitalmars.com 
    77// License for redistribution is by either the Artistic License 
    88// in artistic.txt, or the GNU General Public License in gnu.txt. 
    99// See the included readme.txt for details. 
    1010 
    1111#include <stdio.h> 
    1212#include <assert.h> 
    1313 
    1414#include "mars.h" 
    1515#include "dsymbol.h" 
    1616#include "mtype.h" 
    1717#include "scope.h" 
    1818#include "init.h" 
    1919#include "expression.h" 
    2020#include "attrib.h" 
    2121#include "declaration.h" 
    2222#include "template.h" 
    2323#include "id.h" 
     
    181181     * a        signed char 
    182182     * h        unsigned char 
    183183     * s        short 
    184184     * t        unsigned short 
    185185     * i        int 
    186186     * j        unsigned int 
    187187     * l        long 
    188188     * m        unsigned long 
    189189     * x        long long, __int64 
    190190     * y        unsigned long long, __int64 
    191191     * n        __int128 
    192192     * o        unsigned __int128 
    193193     * f        float 
    194194     * d        double 
    195195     * e        long double, __float80 
    196196     * g        __float128 
    197197     * z        ellipsis 
    198198     * u <source-name>  # vendor extended type 
    199199     */ 
    200200 
     201    if (isConst()) 
     202        buf->writeByte('K'); 
     203 
    201204    switch (ty) 
    202205    { 
    203206        case Tvoid:     c = 'v';        break; 
    204207        case Tint8:     c = 'a';        break; 
    205208        case Tuns8:     c = 'h';        break; 
    206209        case Tint16:    c = 's';        break; 
    207210        case Tuns16:    c = 't';        break; 
    208211        case Tint32:    c = 'i';        break; 
    209212        case Tuns32:    c = 'j';        break; 
    210213        case Tfloat32:  c = 'f';        break; 
    211214        case Tint64:    c = 'x';        break; 
    212215        case Tuns64:    c = 'y';        break; 
    213216        case Tfloat64:  c = 'd';        break; 
    214217        case Tfloat80:  c = 'e';        break; 
    215218        case Tbool:     c = 'b';        break; 
    216219        case Tchar:     c = 'c';        break; 
    217220        case Twchar:    c = 't';        break; 
    218221        case Tdchar:    c = 'w';        break; 
    219222 
    220223        case Timaginary32: p = 'G'; c = 'f';    break;