Use functions with prototypes when appropriate; NFC

A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the final batch of tests being updated to add prototypes,
hopefully.
This commit is contained in:
Aaron Ballman 2022-02-24 15:27:07 -05:00
parent f9704f0cfb
commit 1c2558021c
31 changed files with 129 additions and 129 deletions

View File

@ -51,7 +51,7 @@ typedef signed char BOOL;
- (void)setObject:(id)object atIndexedSubscript:(int)index; - (void)setObject:(id)object atIndexedSubscript:(int)index;
@end @end
void TestObjCEncode() { void TestObjCEncode(void) {
@encode(int); @encode(int);
@encode(typeof(^{;})); @encode(typeof(^{;}));
} }
@ -61,11 +61,11 @@ void TestObjCMessage(I *Obj) {
[I method2]; [I method2];
} }
void TestObjCBoxed() { void TestObjCBoxed(void) {
@(1 + 1); @(1 + 1);
} }
void TestObjCSelector() { void TestObjCSelector(void) {
SEL s = @selector(dealloc); SEL s = @selector(dealloc);
} }
@ -90,7 +90,7 @@ void TestObjCIVarRef(I *Ptr) {
Ptr->public = 0; Ptr->public = 0;
} }
void TestObjCBoolLiteral() { void TestObjCBoolLiteral(void) {
__objc_yes; __objc_yes;
__objc_no; __objc_no;
} }
@ -123,7 +123,7 @@ void TestObjCBoolLiteral() {
// CHECK-NEXT: "name": "TestObjCEncode", // CHECK-NEXT: "name": "TestObjCEncode",
// CHECK-NEXT: "mangledName": "TestObjCEncode", // CHECK-NEXT: "mangledName": "TestObjCEncode",
// CHECK-NEXT: "type": { // CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void ()" // CHECK-NEXT: "qualType": "void (void)"
// CHECK-NEXT: }, // CHECK-NEXT: },
// CHECK-NEXT: "inner": [ // CHECK-NEXT: "inner": [
// CHECK-NEXT: { // CHECK-NEXT: {
@ -133,7 +133,7 @@ void TestObjCBoolLiteral() {
// CHECK-NEXT: "begin": { // CHECK-NEXT: "begin": {
// CHECK-NEXT: "offset": {{[0-9]+}}, // CHECK-NEXT: "offset": {{[0-9]+}},
// CHECK-NEXT: "line": 54, // CHECK-NEXT: "line": 54,
// CHECK-NEXT: "col": 23, // CHECK-NEXT: "col": 27,
// CHECK-NEXT: "tokLen": 1 // CHECK-NEXT: "tokLen": 1
// CHECK-NEXT: }, // CHECK-NEXT: },
// CHECK-NEXT: "end": { // CHECK-NEXT: "end": {
@ -450,7 +450,7 @@ void TestObjCBoolLiteral() {
// CHECK-NEXT: "name": "TestObjCBoxed", // CHECK-NEXT: "name": "TestObjCBoxed",
// CHECK-NEXT: "mangledName": "TestObjCBoxed", // CHECK-NEXT: "mangledName": "TestObjCBoxed",
// CHECK-NEXT: "type": { // CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void ()" // CHECK-NEXT: "qualType": "void (void)"
// CHECK-NEXT: }, // CHECK-NEXT: },
// CHECK-NEXT: "inner": [ // CHECK-NEXT: "inner": [
// CHECK-NEXT: { // CHECK-NEXT: {
@ -460,7 +460,7 @@ void TestObjCBoolLiteral() {
// CHECK-NEXT: "begin": { // CHECK-NEXT: "begin": {
// CHECK-NEXT: "offset": {{[0-9]+}}, // CHECK-NEXT: "offset": {{[0-9]+}},
// CHECK-NEXT: "line": 64, // CHECK-NEXT: "line": 64,
// CHECK-NEXT: "col": 22, // CHECK-NEXT: "col": 26,
// CHECK-NEXT: "tokLen": 1 // CHECK-NEXT: "tokLen": 1
// CHECK-NEXT: }, // CHECK-NEXT: },
// CHECK-NEXT: "end": { // CHECK-NEXT: "end": {
@ -613,7 +613,7 @@ void TestObjCBoolLiteral() {
// CHECK-NEXT: "name": "TestObjCSelector", // CHECK-NEXT: "name": "TestObjCSelector",
// CHECK-NEXT: "mangledName": "TestObjCSelector", // CHECK-NEXT: "mangledName": "TestObjCSelector",
// CHECK-NEXT: "type": { // CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void ()" // CHECK-NEXT: "qualType": "void (void)"
// CHECK-NEXT: }, // CHECK-NEXT: },
// CHECK-NEXT: "inner": [ // CHECK-NEXT: "inner": [
// CHECK-NEXT: { // CHECK-NEXT: {
@ -623,7 +623,7 @@ void TestObjCBoolLiteral() {
// CHECK-NEXT: "begin": { // CHECK-NEXT: "begin": {
// CHECK-NEXT: "offset": {{[0-9]+}}, // CHECK-NEXT: "offset": {{[0-9]+}},
// CHECK-NEXT: "line": 68, // CHECK-NEXT: "line": 68,
// CHECK-NEXT: "col": 25, // CHECK-NEXT: "col": 29,
// CHECK-NEXT: "tokLen": 1 // CHECK-NEXT: "tokLen": 1
// CHECK-NEXT: }, // CHECK-NEXT: },
// CHECK-NEXT: "end": { // CHECK-NEXT: "end": {
@ -4997,7 +4997,7 @@ void TestObjCBoolLiteral() {
// CHECK-NEXT: "name": "TestObjCBoolLiteral", // CHECK-NEXT: "name": "TestObjCBoolLiteral",
// CHECK-NEXT: "mangledName": "TestObjCBoolLiteral", // CHECK-NEXT: "mangledName": "TestObjCBoolLiteral",
// CHECK-NEXT: "type": { // CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void ()" // CHECK-NEXT: "qualType": "void (void)"
// CHECK-NEXT: }, // CHECK-NEXT: },
// CHECK-NEXT: "inner": [ // CHECK-NEXT: "inner": [
// CHECK-NEXT: { // CHECK-NEXT: {
@ -5007,7 +5007,7 @@ void TestObjCBoolLiteral() {
// CHECK-NEXT: "begin": { // CHECK-NEXT: "begin": {
// CHECK-NEXT: "offset": {{[0-9]+}}, // CHECK-NEXT: "offset": {{[0-9]+}},
// CHECK-NEXT: "line": 93, // CHECK-NEXT: "line": 93,
// CHECK-NEXT: "col": 28, // CHECK-NEXT: "col": 32,
// CHECK-NEXT: "tokLen": 1 // CHECK-NEXT: "tokLen": 1
// CHECK-NEXT: }, // CHECK-NEXT: },
// CHECK-NEXT: "end": { // CHECK-NEXT: "end": {

View File

@ -3,7 +3,7 @@
int TestLocation = 0; int TestLocation = 0;
int TestIndent = 1 + (1); int TestIndent = 1 + (1);
void TestDeclStmt() { void TestDeclStmt(void) {
int x = 0; int x = 0;
int y, z; int y, z;
} }
@ -332,7 +332,7 @@ void TestVLA(int n) {
// CHECK-NEXT: "begin": { // CHECK-NEXT: "begin": {
// CHECK-NEXT: "offset": {{[0-9]+}}, // CHECK-NEXT: "offset": {{[0-9]+}},
// CHECK-NEXT: "line": 6, // CHECK-NEXT: "line": 6,
// CHECK-NEXT: "col": 21, // CHECK-NEXT: "col": 25,
// CHECK-NEXT: "tokLen": 1 // CHECK-NEXT: "tokLen": 1
// CHECK-NEXT: }, // CHECK-NEXT: },
// CHECK-NEXT: "end": { // CHECK-NEXT: "end": {

View File

@ -11,7 +11,7 @@ void TestExprWithCleanup(int x) {
@interface A @interface A
@end @end
void TestObjCAtCatchStmt() { void TestObjCAtCatchStmt(void) {
@try { @try {
} @catch(A *a) { } @catch(A *a) {
} @catch(...) { } @catch(...) {
@ -513,7 +513,7 @@ void TestObjCAtCatchStmt() {
// CHECK-NEXT: "name": "TestObjCAtCatchStmt", // CHECK-NEXT: "name": "TestObjCAtCatchStmt",
// CHECK-NEXT: "mangledName": "TestObjCAtCatchStmt", // CHECK-NEXT: "mangledName": "TestObjCAtCatchStmt",
// CHECK-NEXT: "type": { // CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void ()" // CHECK-NEXT: "qualType": "void (void)"
// CHECK-NEXT: }, // CHECK-NEXT: },
// CHECK-NEXT: "inner": [ // CHECK-NEXT: "inner": [
// CHECK-NEXT: { // CHECK-NEXT: {
@ -523,7 +523,7 @@ void TestObjCAtCatchStmt() {
// CHECK-NEXT: "begin": { // CHECK-NEXT: "begin": {
// CHECK-NEXT: "offset": {{[0-9]+}}, // CHECK-NEXT: "offset": {{[0-9]+}},
// CHECK-NEXT: "line": 14, // CHECK-NEXT: "line": 14,
// CHECK-NEXT: "col": 28, // CHECK-NEXT: "col": 32,
// CHECK-NEXT: "tokLen": 1 // CHECK-NEXT: "tokLen": 1
// CHECK-NEXT: }, // CHECK-NEXT: },
// CHECK-NEXT: "end": { // CHECK-NEXT: "end": {

View File

@ -1,8 +1,8 @@
// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,debug.ExprInspection \ // RUN: %clang_analyze_cc1 -w -analyzer-checker=core,debug.ExprInspection \
// RUN: -analyzer-output=text -verify %s // RUN: -analyzer-output=text -verify %s
int OSAtomicCompareAndSwapPtrBarrier(*, *, **); int OSAtomicCompareAndSwapPtrBarrier(void *, void *, void **);
int OSAtomicCompareAndSwapPtrBarrier() { int OSAtomicCompareAndSwapPtrBarrier(void *, void *, void **) {
// There is some body in the actual header, // There is some body in the actual header,
// but we should trust our BodyFarm instead. // but we should trust our BodyFarm instead.
} }

View File

@ -4,7 +4,7 @@
// The synthetic global made by the CFE for big initializer should be marked // The synthetic global made by the CFE for big initializer should be marked
// constant. // constant.
void bar(); void bar(char *);
void foo(void) { void foo(void) {
// CHECK: private unnamed_addr constant // CHECK: private unnamed_addr constant
char Blah[] = "asdlfkajsdlfkajsd;lfkajds;lfkjasd;flkajsd;lkfja;sdlkfjasd"; char Blah[] = "asdlfkajsdlfkajsd;lfkajds;lfkjasd;flkajsd;lkfja;sdlkfjasd";

View File

@ -1,5 +1,5 @@
// RUN: %clang_cc1 %s -emit-llvm -triple i386-apple-darwin -o - | FileCheck %s // RUN: %clang_cc1 %s -emit-llvm -triple i386-apple-darwin -o - | FileCheck %s
extern void abort(); extern void abort(void);
extern void exit(int); extern void exit(int);
struct T struct T
{ {
@ -12,7 +12,7 @@ struct T s[1];
s[0]=t; s[0]=t;
return(char)s->c; return(char)s->c;
} }
main() main(void)
{ {
// CHECK: getelementptr inbounds [1 x %struct.T], [1 x %struct.T]* %s, i32 0, i32 0 // CHECK: getelementptr inbounds [1 x %struct.T], [1 x %struct.T]* %s, i32 0, i32 0
// CHECK: getelementptr inbounds [1 x %struct.T], [1 x %struct.T]* %s, i32 0, i32 0 // CHECK: getelementptr inbounds [1 x %struct.T], [1 x %struct.T]* %s, i32 0, i32 0

View File

@ -3,7 +3,7 @@ int foo(int x) {
} }
#line 100 #line 100
void test1() {} void test1(void) {}
#line 200 #line 200
void test2() {} void test2(void) {}

View File

@ -1,9 +1,9 @@
#line 1 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c" #line 1 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter1.h" #line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter1.h"
void test1() {} void test1(void) {}
#line 2 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c" #line 2 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter2.h" #line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter2.h"
void test2() {} void test2(void) {}
#line 3 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c" #line 3 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
int foo(int x) { int foo(int x) {
return x+1; return x+1;

View File

@ -13,7 +13,7 @@ float f(float x, float y) {
return 2.0f + x + y; return 2.0f + x + y;
} }
int getEvalMethod() { int getEvalMethod(void) {
// CHECK: ret i32 1 // CHECK: ret i32 1
// CHECK-EXT: ret i32 2 // CHECK-EXT: ret i32 2
return __FLT_EVAL_METHOD__; return __FLT_EVAL_METHOD__;

View File

@ -4,7 +4,7 @@
void foo(); void foo(float *);
float bar(void) { float bar(void) {
float lookupTable[] = {-1,-1,-1,0, -1,-1,0,-1, -1,-1,0,1, -1,-1,1,0, float lookupTable[] = {-1,-1,-1,0, -1,-1,0,-1, -1,-1,0,1, -1,-1,1,0,

View File

@ -3,12 +3,12 @@
void syslog(const char *, ...); void syslog(const char *, ...);
void handler( ); void handler(void(^)(void));
__attribute__((used)) __attribute__((used))
static void (^spd)(void) = ^(void) static void (^spd)(void) = ^(void)
{ {
handler( ^(){ syslog("%s", __FUNCTION__); } ); handler( ^(void){ syslog("%s", __FUNCTION__); } );
}; };
// CHECK: @__FUNCTION__.spd_block_invoke_2 = private unnamed_addr constant [19 x i8] c"spd_block_invoke_2\00" // CHECK: @__FUNCTION__.spd_block_invoke_2 = private unnamed_addr constant [19 x i8] c"spd_block_invoke_2\00"
// CHECK: define internal void @spd_block_invoke_2 // CHECK: define internal void @spd_block_invoke_2

View File

@ -19,7 +19,7 @@
// above) // above)
#line 1 #line 1
typedef struct { int array[12]; } BigStruct_t; typedef struct { int array[12]; } BigStruct_t;
BigStruct_t (^a)() = ^(int param) { BigStruct_t (^a)(int) = ^(int param) {
BigStruct_t b; BigStruct_t b;
return b; return b;
}; };

View File

@ -15,4 +15,4 @@
// Ensure #line directives without name do emit checksums // Ensure #line directives without name do emit checksums
// RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-line.cpp -o - | FileCheck %s --check-prefix CHECKSUM // RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-line.cpp -o - | FileCheck %s --check-prefix CHECKSUM
// CHECKSUM: !DIFile(filename: "{{.*}}debug-info-file-checksum-line.cpp", directory:{{.*}}, checksumkind: CSK_MD5, checksum: "7b568574d0e3c56c28e5e0234d1f4a06") // CHECKSUM: !DIFile(filename: "{{.*}}debug-info-file-checksum-line.cpp", directory:{{.*}}, checksumkind: CSK_MD5, checksum: "e13bca9b34ed822d596a519c9ce60995")

View File

@ -2,7 +2,7 @@
void *malloc(__SIZE_TYPE__ size) __attribute__ ((__nothrow__)); void *malloc(__SIZE_TYPE__ size) __attribute__ ((__nothrow__));
inline static void __zend_malloc() { inline static void __zend_malloc(int) {
malloc(1); malloc(1);
} }

View File

@ -8,4 +8,4 @@ struct abc {
long e; long e;
}; };
struct abc foo2(){} struct abc foo2(void){}

View File

@ -58,6 +58,6 @@ typedef struct BOXABLE NSEdgeInsets NSEdgeInsets;
@end @end
NSRange getRange(); NSRange getRange(void);
#endif // NSVALUE_BOXED_EXPRESSIONS_SUPPORT_H #endif // NSVALUE_BOXED_EXPRESSIONS_SUPPORT_H

View File

@ -727,7 +727,7 @@ void test19(void (^b)(void)) {
// CHECK-UNOPT: store i8* [[RETAINED]], i8** [[BLOCKCAPTURED]] // CHECK-UNOPT: store i8* [[RETAINED]], i8** [[BLOCKCAPTURED]]
// CHECK-UNOPT: call void @llvm.objc.storeStrong(i8** [[BLOCKCAPTURED]], i8* null) // CHECK-UNOPT: call void @llvm.objc.storeStrong(i8** [[BLOCKCAPTURED]], i8* null)
void test20_callee(void (^)()); void test20_callee(void (^)(void));
void test20(const id x) { void test20(const id x) {
test20_callee(^{ (void)x; }); test20_callee(^{ (void)x; });
} }

View File

@ -1,7 +1,7 @@
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -O3 -emit-llvm -o %t %s // RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -O3 -emit-llvm -o %t %s
// RUN: grep 'ret i32 385' %t // RUN: grep 'ret i32 385' %t
void *alloca(); void *alloca(unsigned);
@interface I0 { @interface I0 {
@public @public

View File

@ -13,7 +13,7 @@
// CHECK: [[EDGE_STR:.*]] = {{.*}}NSEdgeInsets=dddd{{.*}} // CHECK: [[EDGE_STR:.*]] = {{.*}}NSEdgeInsets=dddd{{.*}}
// CHECK-LABEL: define{{.*}} void @doRange() // CHECK-LABEL: define{{.*}} void @doRange()
void doRange() { void doRange(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSRange{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSRange{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSRange{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSRange{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -32,7 +32,7 @@ void doRange() {
} }
// CHECK-LABEL: define{{.*}} void @doPoint() // CHECK-LABEL: define{{.*}} void @doPoint()
void doPoint() { void doPoint(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGPoint{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGPoint{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGPoint{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGPoint{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -51,7 +51,7 @@ void doPoint() {
} }
// CHECK-LABEL: define{{.*}} void @doSize() // CHECK-LABEL: define{{.*}} void @doSize()
void doSize() { void doSize(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGSize{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGSize{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGSize{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGSize{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -70,7 +70,7 @@ void doSize() {
} }
// CHECK-LABEL: define{{.*}} void @doRect() // CHECK-LABEL: define{{.*}} void @doRect()
void doRect() { void doRect(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGRect{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGRect{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGRect{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGRect{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -91,7 +91,7 @@ void doRect() {
} }
// CHECK-LABEL: define{{.*}} void @doNSEdgeInsets() // CHECK-LABEL: define{{.*}} void @doNSEdgeInsets()
void doNSEdgeInsets() { void doNSEdgeInsets(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -110,10 +110,10 @@ void doNSEdgeInsets() {
} }
// CHECK-LABEL: define{{.*}} void @doRangeRValue() // CHECK-LABEL: define{{.*}} void @doRangeRValue()
void doRangeRValue() { void doRangeRValue(void) {
// CHECK: [[COERCE:%.*]] = alloca %struct._NSRange{{.*}} // CHECK: [[COERCE:%.*]] = alloca %struct._NSRange{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
// CHECK: call {{.*}} @getRange {{.*}} [[COERCE]]{{.*}} // CHECK: call {{.*}} @getRange({{.*}} [[COERCE]])
// CHECK: [[COERCE_CAST:%.*]] = bitcast %struct._NSRange* [[COERCE]]{{.*}} // CHECK: [[COERCE_CAST:%.*]] = bitcast %struct._NSRange* [[COERCE]]{{.*}}
// CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8* // CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8*
// CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]] // CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]]

View File

@ -13,7 +13,7 @@
// CHECK: [[EDGE_STR:.*]] = {{.*}}NSEdgeInsets=dddd{{.*}} // CHECK: [[EDGE_STR:.*]] = {{.*}}NSEdgeInsets=dddd{{.*}}
// CHECK-LABEL: define{{.*}} void @doRange() // CHECK-LABEL: define{{.*}} void @doRange()
void doRange() { void doRange(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSRange{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSRange{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSRange{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSRange{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -30,7 +30,7 @@ void doRange() {
} }
// CHECK-LABEL: define{{.*}} void @doPoint() // CHECK-LABEL: define{{.*}} void @doPoint()
void doPoint() { void doPoint(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGPoint{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGPoint{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGPoint{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGPoint{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -47,7 +47,7 @@ void doPoint() {
} }
// CHECK-LABEL: define{{.*}} void @doSize() // CHECK-LABEL: define{{.*}} void @doSize()
void doSize() { void doSize(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGSize{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGSize{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGSize{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGSize{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -64,7 +64,7 @@ void doSize() {
} }
// CHECK-LABEL: define{{.*}} void @doRect() // CHECK-LABEL: define{{.*}} void @doRect()
void doRect() { void doRect(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGRect{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGRect{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGRect{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGRect{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -83,7 +83,7 @@ void doRect() {
} }
// CHECK-LABEL: define{{.*}} void @doNSEdgeInsets() // CHECK-LABEL: define{{.*}} void @doNSEdgeInsets()
void doNSEdgeInsets() { void doNSEdgeInsets(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -100,10 +100,10 @@ void doNSEdgeInsets() {
} }
// CHECK-LABEL: define{{.*}} void @doRangeRValue() // CHECK-LABEL: define{{.*}} void @doRangeRValue()
void doRangeRValue() { void doRangeRValue(void) {
// CHECK: [[COERCE:%.*]] = alloca %struct._NSRange{{.*}} // CHECK: [[COERCE:%.*]] = alloca %struct._NSRange{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
// CHECK: call {{.*}} @getRange {{.*}} [[COERCE]]{{.*}} // CHECK: call {{.*}} @getRange({{.*}} [[COERCE]])
// CHECK: [[COERCE_CAST:%.*]] = bitcast %struct._NSRange* [[COERCE]]{{.*}} // CHECK: [[COERCE_CAST:%.*]] = bitcast %struct._NSRange* [[COERCE]]{{.*}}
// CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8* // CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8*
// CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]] // CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]]

View File

@ -13,7 +13,7 @@
// CHECK: [[EDGE_STR:.*]] = {{.*}}NSEdgeInsets=dddd{{.*}} // CHECK: [[EDGE_STR:.*]] = {{.*}}NSEdgeInsets=dddd{{.*}}
// CHECK-LABEL: define{{.*}} void @doRange() // CHECK-LABEL: define{{.*}} void @doRange()
void doRange() { void doRange(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSRange{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSRange{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSRange{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSRange{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -31,7 +31,7 @@ void doRange() {
} }
// CHECK-LABEL: define{{.*}} void @doPoint() // CHECK-LABEL: define{{.*}} void @doPoint()
void doPoint() { void doPoint(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSPoint{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSPoint{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSPoint{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSPoint{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -49,7 +49,7 @@ void doPoint() {
} }
// CHECK-LABEL: define{{.*}} void @doSize() // CHECK-LABEL: define{{.*}} void @doSize()
void doSize() { void doSize(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSSize{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSSize{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSSize{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSSize{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -67,7 +67,7 @@ void doSize() {
} }
// CHECK-LABEL: define{{.*}} void @doRect() // CHECK-LABEL: define{{.*}} void @doRect()
void doRect() { void doRect(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSRect{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSRect{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSRect{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSRect{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -87,7 +87,7 @@ void doRect() {
} }
// CHECK-LABEL: define{{.*}} void @doNSEdgeInsets() // CHECK-LABEL: define{{.*}} void @doNSEdgeInsets()
void doNSEdgeInsets() { void doNSEdgeInsets(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -105,7 +105,7 @@ void doNSEdgeInsets() {
} }
// CHECK-LABEL: define{{.*}} void @doRangeRValue() // CHECK-LABEL: define{{.*}} void @doRangeRValue()
void doRangeRValue() { void doRangeRValue(void) {
// CHECK: [[COERCE:%.*]] = alloca %struct._NSRange{{.*}} // CHECK: [[COERCE:%.*]] = alloca %struct._NSRange{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
// CHECK: [[RVAL:%.*]] = call {{.*}} @getRange() // CHECK: [[RVAL:%.*]] = call {{.*}} @getRange()

View File

@ -13,7 +13,7 @@
// CHECK: [[EDGE_STR:.*]] = {{.*}}NSEdgeInsets=dddd{{.*}} // CHECK: [[EDGE_STR:.*]] = {{.*}}NSEdgeInsets=dddd{{.*}}
// CHECK-LABEL: define{{.*}} void @doRange() // CHECK-LABEL: define{{.*}} void @doRange()
void doRange() { void doRange(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSRange{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSRange{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSRange{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSRange{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -30,7 +30,7 @@ void doRange() {
} }
// CHECK-LABEL: define{{.*}} void @doPoint() // CHECK-LABEL: define{{.*}} void @doPoint()
void doPoint() { void doPoint(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSPoint{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSPoint{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSPoint{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSPoint{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -47,7 +47,7 @@ void doPoint() {
} }
// CHECK-LABEL: define{{.*}} void @doSize() // CHECK-LABEL: define{{.*}} void @doSize()
void doSize() { void doSize(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSSize{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSSize{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSSize{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSSize{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -64,7 +64,7 @@ void doSize() {
} }
// CHECK-LABEL: define{{.*}} void @doRect() // CHECK-LABEL: define{{.*}} void @doRect()
void doRect() { void doRect(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSRect{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSRect{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSRect{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSRect{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -83,7 +83,7 @@ void doRect() {
} }
// CHECK-LABEL: define{{.*}} void @doNSEdgeInsets() // CHECK-LABEL: define{{.*}} void @doNSEdgeInsets()
void doNSEdgeInsets() { void doNSEdgeInsets(void) {
// CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}} // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}}
// CHECK: [[TEMP_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}} // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
@ -100,7 +100,7 @@ void doNSEdgeInsets() {
} }
// CHECK-LABEL: define{{.*}} void @doRangeRValue() // CHECK-LABEL: define{{.*}} void @doRangeRValue()
void doRangeRValue() { void doRangeRValue(void) {
// CHECK: [[COERCE:%.*]] = alloca %struct._NSRange{{.*}} // CHECK: [[COERCE:%.*]] = alloca %struct._NSRange{{.*}}
// CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
// CHECK: [[RVAL:%.*]] = call {{.*}} @getRange() // CHECK: [[RVAL:%.*]] = call {{.*}} @getRange()

View File

@ -6,6 +6,6 @@ inline int system_header_func(int x)
return 0; return 0;
} }
void test_system_header() { void test_system_header(void) {
system_header_func(0); // expected-warning {{system header warning}} system_header_func(0); // expected-warning {{system header warning}}
} }

View File

@ -25,7 +25,7 @@ struct S4 get_s(void);
enum [[nodiscard]] E2 { Two }; enum [[nodiscard]] E2 { Two };
enum E2 get_e(void); enum E2 get_e(void);
[[nodiscard]] int get_i(); [[nodiscard]] int get_i(void);
void f2(void) { void f2(void) {
get_s(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} get_s(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}

View File

@ -2,26 +2,26 @@
#define _diagnose_if(...) __attribute__((diagnose_if(__VA_ARGS__))) #define _diagnose_if(...) __attribute__((diagnose_if(__VA_ARGS__)))
void failure() _diagnose_if(); // expected-error{{exactly 3 arguments}} void failure1(void) _diagnose_if(); // expected-error{{exactly 3 arguments}}
void failure() _diagnose_if(0); // expected-error{{exactly 3 arguments}} void failure2(void) _diagnose_if(0); // expected-error{{exactly 3 arguments}}
void failure() _diagnose_if(0, ""); // expected-error{{exactly 3 arguments}} void failure3(void) _diagnose_if(0, ""); // expected-error{{exactly 3 arguments}}
void failure() _diagnose_if(0, "", "error", 1); // expected-error{{exactly 3 arguments}} void failure4(void) _diagnose_if(0, "", "error", 1); // expected-error{{exactly 3 arguments}}
void failure() _diagnose_if(0, 0, "error"); // expected-error{{requires a string}} void failure5(void) _diagnose_if(0, 0, "error"); // expected-error{{requires a string}}
void failure() _diagnose_if(0, "", "invalid"); // expected-error{{invalid diagnostic type for 'diagnose_if'; use "error" or "warning" instead}} void failure6(void) _diagnose_if(0, "", "invalid"); // expected-error{{invalid diagnostic type for 'diagnose_if'; use "error" or "warning" instead}}
void failure() _diagnose_if(0, "", "ERROR"); // expected-error{{invalid diagnostic type}} void failure7(void) _diagnose_if(0, "", "ERROR"); // expected-error{{invalid diagnostic type}}
void failure(int a) _diagnose_if(a, "", ""); // expected-error{{invalid diagnostic type}} void failure8(int a) _diagnose_if(a, "", ""); // expected-error{{invalid diagnostic type}}
void failure() _diagnose_if(a, "", ""); // expected-error{{undeclared identifier 'a'}} void failure9(void) _diagnose_if(a, "", ""); // expected-error{{undeclared identifier 'a'}}
int globalVar; int globalVar;
void never_constant() _diagnose_if(globalVar, "", "error"); // expected-error{{'diagnose_if' attribute expression never produces a constant expression}} expected-note{{subexpression not valid}} void never_constant(void) _diagnose_if(globalVar, "", "error"); // expected-error{{'diagnose_if' attribute expression never produces a constant expression}} expected-note{{subexpression not valid}}
void never_constant() _diagnose_if(globalVar, "", "warning"); // expected-error{{'diagnose_if' attribute expression never produces a constant expression}} expected-note{{subexpression not valid}} void never_constant(void) _diagnose_if(globalVar, "", "warning"); // expected-error{{'diagnose_if' attribute expression never produces a constant expression}} expected-note{{subexpression not valid}}
int alwaysok(int q) _diagnose_if(0, "", "error"); int alwaysok(int q) _diagnose_if(0, "", "error");
int neverok(int q) _diagnose_if(1, "oh no", "error"); // expected-note 5{{from 'diagnose_if' attribute on 'neverok'}} int neverok(int q) _diagnose_if(1, "oh no", "error"); // expected-note 5{{from 'diagnose_if' attribute on 'neverok'}}
int alwayswarn(int q) _diagnose_if(1, "oh no", "warning"); // expected-note 5{{from 'diagnose_if' attribute}} int alwayswarn(int q) _diagnose_if(1, "oh no", "warning"); // expected-note 5{{from 'diagnose_if' attribute}}
int neverwarn(int q) _diagnose_if(0, "", "warning"); int neverwarn(int q) _diagnose_if(0, "", "warning");
void runConstant() { void runConstant(void) {
int m; int m;
alwaysok(0); alwaysok(0);
alwaysok(1); alwaysok(1);
@ -58,7 +58,7 @@ void runConstant() {
} }
int abs(int q) _diagnose_if(q >= 0, "redundant abs call", "error"); //expected-note{{from 'diagnose_if'}} int abs(int q) _diagnose_if(q >= 0, "redundant abs call", "error"); //expected-note{{from 'diagnose_if'}}
void runVariable() { void runVariable(void) {
int m; int m;
abs(-1); abs(-1);
abs(1); // expected-error{{redundant abs call}} abs(1); // expected-error{{redundant abs call}}
@ -75,18 +75,18 @@ int ovl1(void *m) _overloadable;
int ovl2(const char *n) _overloadable _diagnose_if(n, "oh no", "error"); // expected-note{{candidate function}} int ovl2(const char *n) _overloadable _diagnose_if(n, "oh no", "error"); // expected-note{{candidate function}}
int ovl2(char *m) _overloadable; // expected-note{{candidate function}} int ovl2(char *m) _overloadable; // expected-note{{candidate function}}
void overloadsYay() { void overloadsYay(void) {
ovl1((void *)0); ovl1((void *)0);
ovl1(""); // expected-error{{oh no}} ovl1(""); // expected-error{{oh no}}
ovl2((void *)0); // expected-error{{ambiguous}} ovl2((void *)0); // expected-error{{ambiguous}}
} }
void errorWarnDiagnose1() _diagnose_if(1, "oh no", "error") // expected-note{{from 'diagnose_if'}} void errorWarnDiagnose1(void) _diagnose_if(1, "oh no", "error") // expected-note{{from 'diagnose_if'}}
_diagnose_if(1, "nop", "warning"); _diagnose_if(1, "nop", "warning");
void errorWarnDiagnose2() _diagnose_if(1, "oh no", "error") // expected-note{{from 'diagnose_if'}} void errorWarnDiagnose2(void) _diagnose_if(1, "oh no", "error") // expected-note{{from 'diagnose_if'}}
_diagnose_if(1, "nop", "error"); _diagnose_if(1, "nop", "error");
void errorWarnDiagnose3() _diagnose_if(1, "nop", "warning") void errorWarnDiagnose3(void) _diagnose_if(1, "nop", "warning")
_diagnose_if(1, "oh no", "error"); // expected-note{{from 'diagnose_if'}} _diagnose_if(1, "oh no", "error"); // expected-note{{from 'diagnose_if'}}
void errorWarnDiagnoseArg1(int a) _diagnose_if(a == 1, "oh no", "error") // expected-note{{from 'diagnose_if'}} void errorWarnDiagnoseArg1(int a) _diagnose_if(a == 1, "oh no", "error") // expected-note{{from 'diagnose_if'}}
@ -96,7 +96,7 @@ void errorWarnDiagnoseArg2(int a) _diagnose_if(a == 1, "oh no", "error") // expe
void errorWarnDiagnoseArg3(int a) _diagnose_if(a == 1, "nop", "warning") void errorWarnDiagnoseArg3(int a) _diagnose_if(a == 1, "nop", "warning")
_diagnose_if(a == 1, "oh no", "error"); // expected-note{{from 'diagnose_if'}} _diagnose_if(a == 1, "oh no", "error"); // expected-note{{from 'diagnose_if'}}
void runErrorWarnDiagnose() { void runErrorWarnDiagnose(void) {
errorWarnDiagnose1(); // expected-error{{oh no}} errorWarnDiagnose1(); // expected-error{{oh no}}
errorWarnDiagnose2(); // expected-error{{oh no}} errorWarnDiagnose2(); // expected-error{{oh no}}
errorWarnDiagnose3(); // expected-error{{oh no}} errorWarnDiagnose3(); // expected-error{{oh no}}
@ -106,18 +106,18 @@ void runErrorWarnDiagnose() {
errorWarnDiagnoseArg3(1); // expected-error{{oh no}} errorWarnDiagnoseArg3(1); // expected-error{{oh no}}
} }
void warnWarnDiagnose() _diagnose_if(1, "oh no!", "warning") _diagnose_if(1, "foo", "warning"); // expected-note 2{{from 'diagnose_if'}} void warnWarnDiagnose(void) _diagnose_if(1, "oh no!", "warning") _diagnose_if(1, "foo", "warning"); // expected-note 2{{from 'diagnose_if'}}
void runWarnWarnDiagnose() { void runWarnWarnDiagnose(void) {
warnWarnDiagnose(); // expected-warning{{oh no!}} expected-warning{{foo}} warnWarnDiagnose(); // expected-warning{{oh no!}} expected-warning{{foo}}
} }
void declsStackErr1(int a) _diagnose_if(a & 1, "decl1", "error"); // expected-note 2{{from 'diagnose_if'}} void declsStackErr1(int a) _diagnose_if(a & 1, "decl1", "error"); // expected-note 2{{from 'diagnose_if'}}
void declsStackErr1(int a) _diagnose_if(a & 2, "decl2", "error"); // expected-note{{from 'diagnose_if'}} void declsStackErr1(int a) _diagnose_if(a & 2, "decl2", "error"); // expected-note{{from 'diagnose_if'}}
void declsStackErr2(); void declsStackErr2(void);
void declsStackErr2() _diagnose_if(1, "complaint", "error"); // expected-note{{from 'diagnose_if'}} void declsStackErr2(void) _diagnose_if(1, "complaint", "error"); // expected-note{{from 'diagnose_if'}}
void declsStackErr3() _diagnose_if(1, "complaint", "error"); // expected-note{{from 'diagnose_if'}} void declsStackErr3(void) _diagnose_if(1, "complaint", "error"); // expected-note{{from 'diagnose_if'}}
void declsStackErr3(); void declsStackErr3(void);
void runDeclsStackErr() { void runDeclsStackErr(void) {
declsStackErr1(0); declsStackErr1(0);
declsStackErr1(1); // expected-error{{decl1}} declsStackErr1(1); // expected-error{{decl1}}
declsStackErr1(2); // expected-error{{decl2}} declsStackErr1(2); // expected-error{{decl2}}
@ -128,11 +128,11 @@ void runDeclsStackErr() {
void declsStackWarn1(int a) _diagnose_if(a & 1, "decl1", "warning"); // expected-note 2{{from 'diagnose_if'}} void declsStackWarn1(int a) _diagnose_if(a & 1, "decl1", "warning"); // expected-note 2{{from 'diagnose_if'}}
void declsStackWarn1(int a) _diagnose_if(a & 2, "decl2", "warning"); // expected-note 2{{from 'diagnose_if'}} void declsStackWarn1(int a) _diagnose_if(a & 2, "decl2", "warning"); // expected-note 2{{from 'diagnose_if'}}
void declsStackWarn2(); void declsStackWarn2(void);
void declsStackWarn2() _diagnose_if(1, "complaint", "warning"); // expected-note{{from 'diagnose_if'}} void declsStackWarn2(void) _diagnose_if(1, "complaint", "warning"); // expected-note{{from 'diagnose_if'}}
void declsStackWarn3() _diagnose_if(1, "complaint", "warning"); // expected-note{{from 'diagnose_if'}} void declsStackWarn3(void) _diagnose_if(1, "complaint", "warning"); // expected-note{{from 'diagnose_if'}}
void declsStackWarn3(); void declsStackWarn3(void);
void runDeclsStackWarn() { void runDeclsStackWarn(void) {
declsStackWarn1(0); declsStackWarn1(0);
declsStackWarn1(1); // expected-warning{{decl1}} declsStackWarn1(1); // expected-warning{{decl1}}
declsStackWarn1(2); // expected-warning{{decl2}} declsStackWarn1(2); // expected-warning{{decl2}}
@ -142,7 +142,7 @@ void runDeclsStackWarn() {
} }
void noMsg(int n) _diagnose_if(n, "", "warning"); // expected-note{{from 'diagnose_if'}} void noMsg(int n) _diagnose_if(n, "", "warning"); // expected-note{{from 'diagnose_if'}}
void runNoMsg() { void runNoMsg(void) {
noMsg(1); // expected-warning{{<no message provided>}} noMsg(1); // expected-warning{{<no message provided>}}
} }
@ -161,7 +161,7 @@ void underbarName(int a) __attribute__((__diagnose_if__(a, "", "warning")));
// PR38095 // PR38095
void constCharStar(const char *str) __attribute__((__diagnose_if__(!str[0], "empty string not allowed", "error"))); // expected-note {{from}} void constCharStar(const char *str) __attribute__((__diagnose_if__(!str[0], "empty string not allowed", "error"))); // expected-note {{from}}
void charStar(char *str) __attribute__((__diagnose_if__(!str[0], "empty string not allowed", "error"))); // expected-note {{from}} void charStar(char *str) __attribute__((__diagnose_if__(!str[0], "empty string not allowed", "error"))); // expected-note {{from}}
void runConstCharStar() { void runConstCharStar(void) {
constCharStar("foo"); constCharStar("foo");
charStar("bar"); charStar("bar");
constCharStar(""); // expected-error {{empty string not allowed}} constCharStar(""); // expected-error {{empty string not allowed}}

View File

@ -1,19 +1,19 @@
// RUN: %clang_cc1 %s -std=c90 -verify -fsyntax-only // RUN: %clang_cc1 %s -std=c90 -verify -fsyntax-only
void t0(int x) { void t0(int x) {
int explicit_decl(); int explicit_decl(void);
int (*p)(); int (*p)(void);
if(x > 0) if(x > 0)
x = g() + 1; // expected-note {{previous implicit declaration}} x = g() + 1; // expected-note {{previous implicit declaration}}
p = g; p = g;
if(x < 0) { if(x < 0) {
extern void u(int (*)[h()]); extern void u(int (*)[h()]);
int (*q)() = h; int (*q)(void) = h;
} }
p = h; /* expected-error {{use of undeclared identifier 'h'}} */ p = h; /* expected-error {{use of undeclared identifier 'h'}} */
} }
void t1(int x) { void t1(int x) {
int (*p)(); int (*p)(void);
switch (x) { switch (x) {
g(); g();
case 0: case 0:
@ -32,11 +32,11 @@ void t1(int x) {
int t2(int x) { int t2(int x) {
int y = ({ if (x > 0) x = g() + 1; 2*x; }); int y = ({ if (x > 0) x = g() + 1; 2*x; });
int (*p)() = g; /* expected-error {{use of undeclared identifier 'g'}} */ int (*p)(void) = g; /* expected-error {{use of undeclared identifier 'g'}} */
return y; return y;
} }
int PR34822() { int PR34822(void) {
{int i = sizeof(PR34822_foo());} /* expected-note {{previous definition is here}} */ {int i = sizeof(PR34822_foo());} /* expected-note {{previous definition is here}} */
{extern int PR34822_foo;} /* expected-error {{redefinition of 'PR34822_foo' as different kind of symbol}} */ {extern int PR34822_foo;} /* expected-error {{redefinition of 'PR34822_foo' as different kind of symbol}} */
@ -44,7 +44,7 @@ int PR34822() {
{int i = sizeof(PR34822_bar());} /* expected-warning {{use of out-of-scope declaration of 'PR34822_bar' whose type is not compatible with that of an implicit declaration}} expected-error {{called object type 'int' is not a function or function pointer}} */ {int i = sizeof(PR34822_bar());} /* expected-warning {{use of out-of-scope declaration of 'PR34822_bar' whose type is not compatible with that of an implicit declaration}} expected-error {{called object type 'int' is not a function or function pointer}} */
} }
int (*p)() = g; /* expected-error {{use of undeclared identifier 'g'}} */ int (*p)(void) = g; /* expected-error {{use of undeclared identifier 'g'}} */
int (*q)() = h; /* expected-error {{use of undeclared identifier 'h'}} */ int (*q)(void) = h; /* expected-error {{use of undeclared identifier 'h'}} */
float g(); /* expected-error {{conflicting types for 'g'}} */ float g(void); /* expected-error {{conflicting types for 'g'}} */

View File

@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-apple-darwin9 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-apple-darwin9
// rdar://6726818 // rdar://6726818
void f1() { void f1(void) {
const __builtin_va_list args2; const __builtin_va_list args2;
(void)__builtin_va_arg(args2, int); // expected-error {{first argument to 'va_arg' is of type 'const __builtin_va_list' and not 'va_list'}} (void)__builtin_va_arg(args2, int); // expected-error {{first argument to 'va_arg' is of type 'const __builtin_va_list' and not 'va_list'}}
} }
@ -33,7 +33,7 @@ void __attribute__((ms_abi)) g3(float a, ...) { // expected-note 2{{parameter of
__builtin_ms_va_start(ap, (a)); // expected-warning {{passing an object that undergoes default argument promotion to 'va_start' has undefined behavior}} __builtin_ms_va_start(ap, (a)); // expected-warning {{passing an object that undergoes default argument promotion to 'va_start' has undefined behavior}}
} }
void __attribute__((ms_abi)) g5() { void __attribute__((ms_abi)) g5(void) {
__builtin_ms_va_list ap; __builtin_ms_va_list ap;
__builtin_ms_va_start(ap, ap); // expected-error {{'va_start' used in function with fixed args}} __builtin_ms_va_start(ap, ap); // expected-error {{'va_start' used in function with fixed args}}
} }

View File

@ -34,7 +34,7 @@ void f4(const char *msg, ...) {
__builtin_va_end (ap); __builtin_va_end (ap);
} }
void f5() { void f5(void) {
__builtin_va_list ap; __builtin_va_list ap;
__builtin_va_start(ap,ap); // expected-error {{'va_start' used in function with fixed args}} __builtin_va_start(ap,ap); // expected-error {{'va_start' used in function with fixed args}}
} }

View File

@ -2,17 +2,17 @@
#define _zero_call_used_regs(...) __attribute__((zero_call_used_regs(__VA_ARGS__))) #define _zero_call_used_regs(...) __attribute__((zero_call_used_regs(__VA_ARGS__)))
void failure() _zero_call_used_regs(); // expected-error {{takes one argument}} void failure1(void) _zero_call_used_regs(); // expected-error {{takes one argument}}
void failure() _zero_call_used_regs("used", "used-gpr"); // expected-error {{takes one argument}} void failure2(void) _zero_call_used_regs("used", "used-gpr"); // expected-error {{takes one argument}}
void failure() _zero_call_used_regs(0); // expected-error {{requires a string}} void failure3(void) _zero_call_used_regs(0); // expected-error {{requires a string}}
void failure() _zero_call_used_regs("hello"); // expected-warning {{argument not supported: hello}} void failure4(void) _zero_call_used_regs("hello"); // expected-warning {{argument not supported: hello}}
void success() _zero_call_used_regs("skip"); void success1(void) _zero_call_used_regs("skip");
void success() _zero_call_used_regs("used-gpr-arg"); void success2(void) _zero_call_used_regs("used-gpr-arg");
void success() _zero_call_used_regs("used-gpr"); void success3(void) _zero_call_used_regs("used-gpr");
void success() _zero_call_used_regs("used-arg"); void success4(void) _zero_call_used_regs("used-arg");
void success() _zero_call_used_regs("used"); void success5(void) _zero_call_used_regs("used");
void success() _zero_call_used_regs("all-gpr-arg"); void success6(void) _zero_call_used_regs("all-gpr-arg");
void success() _zero_call_used_regs("all-gpr"); void success7(void) _zero_call_used_regs("all-gpr");
void success() _zero_call_used_regs("all-arg"); void success8(void) _zero_call_used_regs("all-arg");
void success() _zero_call_used_regs("all"); void success9(void) _zero_call_used_regs("all");

View File

@ -5,16 +5,16 @@
void test1(int x CALLED_ONCE); // expected-error{{'called_once' attribute only applies to function-like parameters}} void test1(int x CALLED_ONCE); // expected-error{{'called_once' attribute only applies to function-like parameters}}
void test2(double x CALLED_ONCE); // expected-error{{'called_once' attribute only applies to function-like parameters}} void test2(double x CALLED_ONCE); // expected-error{{'called_once' attribute only applies to function-like parameters}}
void test3(void (*foo)() CALLED_ONCE); // no-error void test3(void (*foo)(void) CALLED_ONCE); // no-error
void test4(int (^foo)(int) CALLED_ONCE); // no-error void test4(int (^foo)(int) CALLED_ONCE); // no-error
void test5(void (*foo)() __attribute__((called_once(1)))); void test5(void (*foo)(void) __attribute__((called_once(1))));
// expected-error@-1{{'called_once' attribute takes no arguments}} // expected-error@-1{{'called_once' attribute takes no arguments}}
void test6(void (*foo)() __attribute__((called_once("str1", "str2")))); void test6(void (*foo)(void) __attribute__((called_once("str1", "str2"))));
// expected-error@-1{{'called_once' attribute takes no arguments}} // expected-error@-1{{'called_once' attribute takes no arguments}}
CALLED_ONCE void test7(); // expected-warning{{'called_once' attribute only applies to parameters}} CALLED_ONCE void test7(void); // expected-warning{{'called_once' attribute only applies to parameters}}
void test8() { void test8(void) {
void (*foo)() CALLED_ONCE; // expected-warning{{'called_once' attribute only applies to parameters}} void (*foo)(void) CALLED_ONCE; // expected-warning{{'called_once' attribute only applies to parameters}}
foo(); foo();
} }

View File

@ -76,7 +76,7 @@ typedef signed char BOOL;
#define PAIR(x) @#x, [NSNumber numberWithInt:(x)] #define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
#define TWO(x) ((x), (x)) #define TWO(x) ((x), (x))
void foo() { void foo(void) {
NSString *str = M([NSString stringWithString:@"foo"]); // expected-warning {{redundant}} NSString *str = M([NSString stringWithString:@"foo"]); // expected-warning {{redundant}}
str = [[NSString alloc] initWithString:@"foo"]; // expected-warning {{redundant}} str = [[NSString alloc] initWithString:@"foo"]; // expected-warning {{redundant}}
NSArray *arr = [NSArray arrayWithArray:@[str]]; // expected-warning {{redundant}} NSArray *arr = [NSArray arrayWithArray:@[str]]; // expected-warning {{redundant}}