summaryrefslogtreecommitdiffstats
path: root/compilerplugins/clang/test/typedefparam.cxx
blob: 777a5128db0f8bceeecd597b74168557f8d037c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include "tools/solar.h"

namespace test1
{
class Foo
{
    void bar(sal_uIntPtr x); // expected-note {{declaration site here [loplugin:typedefparam]}}
    sal_uIntPtr bar(); // expected-note {{declaration site here [loplugin:typedefparam]}}
};

void Foo::bar(sal_uLong)
// expected-error-re@-1 {{function param 1 at definition site does not match function param at declaration site, 'sal_uLong' (aka 'unsigned {{.+}}') vs 'sal_uIntPtr' (aka 'unsigned {{.+}}') [loplugin:typedefparam]}}
{
}

sal_uLong Foo::bar()
// expected-error-re@-1 {{function return type at definition site does not match function param at declaration site, 'sal_uLong' (aka 'unsigned {{.+}}') vs 'sal_uIntPtr' (aka 'unsigned {{.+}}') [loplugin:typedefparam]}}
{
    return 1;
}
};

// Carve out an exception for the "typedef struct S {...} T" idiom we use in the UNO code
namespace test2
{
typedef struct Foo
{
    int x;
} FooT;

void bar(struct Foo*);

void bar(FooT*){
    // no warning expected
};
};
namespace test3
{
typedef struct Foo
{
    int x;
} FooT;

void bar(Foo*);

void bar(FooT*){
    // no warning expected
};
};

// check method overrides
namespace test4
{
struct Struct1
{
    virtual sal_uIntPtr foo1();
    // expected-note@-1 {{super-class method here [loplugin:typedefparam]}}
    virtual void foo2(sal_uIntPtr);
    // expected-note@-1 {{super-class method here [loplugin:typedefparam]}}
    virtual ~Struct1();
};
struct Struct2 : public Struct1
{
    virtual sal_uLong foo1() override;
    // expected-error-re@-1 {{method return type does not match overridden method 'sal_uLong' (aka 'unsigned {{.+}}') vs 'sal_uIntPtr' (aka 'unsigned {{.+}}') [loplugin:typedefparam]}}
    virtual void foo2(sal_uLong) override;
    // expected-error-re@-1 {{method param 1 does not match overridden method param 'sal_uLong' (aka 'unsigned {{.+}}') vs 'sal_uIntPtr' (aka 'unsigned {{.+}}') [loplugin:typedefparam]}}
};
};

/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */