blob: b4b875b08024b1fb89c60c333cdf84d978ce7ead (
plain) (
blame)
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
81
82
83
84
85
86
87
88
89
|
/*******************************************************************************
* Copyright (c) 2009 Alena Laskavaia
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alena Laskavaia - initial API and implementation
* Felipe Martinez - ExpressionRequiredInReturnCheckerTest implementation
*******************************************************************************/
package org.eclipse.cdt.codan.core.internal.checkers;
import org.eclipse.cdt.codan.core.test.CheckerTestCase;
/**
* Test for {@see ExpressionRequiredInReturnCheckerTest} class
*
*/
public class ExpressionRequiredInReturnCheckerTest extends CheckerTestCase {
// dummy() {
// return; // error here on line 2
// }
public void testDummyFunction() {
loadCodeAndRun(getAboveComment());
checkNoErrors(); // because return type if not defined, usually people don't care
}
// void void_function(void) {
// return; // no error here
// }
public void testVoidFunction() {
loadCodeAndRun(getAboveComment());
checkNoErrors();
}
// int integer_return_function(void) {
// if (global) {
// if (global == 100) {
// return; // error here on line 4
// }
// }
// }
public void testBasicTypeFunction() {
loadCodeAndRun(getAboveComment());
checkErrorLine(4);
}
//
// struct My_Struct {
// int a;
// };
//
// struct My_Struct struct_return_function(void) {
// return; // error here on line 6
// }
public void testUserDefinedFunction() {
loadCodeAndRun(getAboveComment());
checkErrorLine(6);
}
// typedef unsigned int uint8_t;
//
// uint8_t return_typedef(void) {
// return; // error here on line 4
// }
public void testTypedefReturnFunction() {
loadCodeAndRun(getAboveComment());
checkErrorLine(4);
}
// typedef unsigned int uint8_t;
//
// uint8_t (*return_fp_no_typedef(void))(void)
// {
// return; // error here on line 5
// }
public void testFunctionPointerReturnFunction() {
loadCodeAndRun(getAboveComment());
checkErrorLine(5);
}
}
|