Changeset 4d5e57b


Ignore:
Timestamp:
Nov 20, 2017, 4:03:55 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
1ba5803
Parents:
cdbfab0
Message:

Prevent implicit conversion of void * to other pointer type for parameter passing

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/PtrsAssignable.cc

    rcdbfab0 r4d5e57b  
    6868
    6969        void PtrsAssignable::visit( __attribute((unused)) VoidType *voidType ) {
    70                 if ( ! dynamic_cast< FunctionType* >( dest ) ) {
    71                         // T * = void * is safe for any T that is not a function type.
    72                         // xxx - this should be unsafe...
    73                         result = 1;
    74                 } // if
     70                // T * = void * is disallowed - this is a change from C, where any
     71                // void * can be assigned or passed to a non-void pointer without a cast.
    7572        }
    7673
  • src/tests/.expect/completeTypeError.txt

    rcdbfab0 r4d5e57b  
    1 completeTypeError.c:34:1 error: No reasonable alternatives for expression Applying untyped:
     1completeTypeError.c:33:1 error: No reasonable alternatives for expression Applying untyped:
    22  Name: *?
    33...to:
    44  Name: v
    55
     6completeTypeError.c:34:1 error: No reasonable alternatives for expression Applying untyped:
     7  Name: *?
     8...to:
     9  Name: y
     10
     11completeTypeError.c:35:1 error: No reasonable alternatives for expression Applying untyped:
     12  Name: foo
     13...to:
     14  Name: v
    615
    716completeTypeError.c:36:1 error: No reasonable alternatives for expression Applying untyped:
     
    1019  Name: v
    1120
    12 
    1321completeTypeError.c:37:1 error: No reasonable alternatives for expression Applying untyped:
    1422  Name: quux
    1523...to:
    1624  Name: v
    17 
    1825
    1926completeTypeError.c:58:1 error: No reasonable alternatives for expression Applying untyped:
     
    2229  Name: y
    2330
    24 
    2531completeTypeError.c:59:1 error: No reasonable alternatives for expression Applying untyped:
    2632  Name: quux
    2733...to:
    2834  Name: y
    29 
    3035
    3136completeTypeError.c:60:1 error: No reasonable alternatives for expression Applying untyped:
     
    3439  Name: y
    3540
    36 
    3741completeTypeError.c:72:1 error: No reasonable alternatives for expression Applying untyped:
    3842  Name: baz
     
    4044  Name: z
    4145
    42 
  • src/tests/completeTypeError.c

    rcdbfab0 r4d5e57b  
    1212        void *v;
    1313
    14         // A * x;
    15         // A * y;
    16         // B * x;
    17         // B * z;
     14        A * x;
     15        A * y;
     16        B * x;
     17        B * z;
    1818
    1919        // okay
    2020        *i;
    21         // *x; // picks B
    22         // *z;
     21        *x; // picks B
     22        *z;
    2323        foo(i);
    2424        bar(i);
     
    2929        bar(v);
    3030        qux(v);
    31         foo(v); // questionable, but works at the moment for C compatibility
    3231
    3332        // bad
    3433        *v;
    35         // *y;
     34        *y;
     35        foo(v);
    3636        baz(v);
    3737        quux(v);
Note: See TracChangeset for help on using the changeset viewer.