Changeset 1dcd52a3


Ignore:
Timestamp:
Feb 9, 2018, 11:59:35 AM (3 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-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
7a052e34
Parents:
538334a
git-author:
Rob Schluntz <rschlunt@…> (02/09/18 11:44:40)
git-committer:
Rob Schluntz <rschlunt@…> (02/09/18 11:59:35)
Message:

Disregard outermost const, volatile, _Atomic qualifiers on parameters when unifying function types [fixes #48]

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Unify.cc

    r538334a r1dcd52a3  
    563563                        flatten( dcl->get_type(), back_inserter( types ) );
    564564                        for ( Type * t : types ) {
     565                                // outermost const, volatile, _Atomic qualifiers in parameters should not play a role in the unification of function types, since they do not determine whether a function is callable.
     566                                // Note: MUST consider at least mutex qualifier, since functions can be overloaded on outermost mutex and a mutex function has different requirements than a non-mutex function.
     567                                t->get_qualifiers() -= Type::Qualifiers(Type::Const | Type::Volatile | Type::Atomic);
     568
    565569                                dst.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::C, nullptr, t, nullptr ) );
    566570                        }
  • src/tests/tuple/tupleVariadic.c

    r538334a r1dcd52a3  
    9595}
    9696
     97forall(ttype T | { void foo(T); }) void bar(T x) {}
     98void foo(int) {}
     99
    97100int main() {
    98101        array * x0 = new();
     
    117120        func(3, 2.0, 111, 4.145);
    118121        printf("finished func\n");
     122
     123        {
     124                // T = [const int] -- this ensures that void(*)(int) satisfies void(*)(const int)
     125                const int x;
     126                bar(x);
     127        }
    119128}
    120129
Note: See TracChangeset for help on using the changeset viewer.