summaryrefslogtreecommitdiffstats
path: root/test/FixIt
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2012-12-02 13:20:44 +0000
committerdim <dim@FreeBSD.org>2012-12-02 13:20:44 +0000
commit056abd2059c65a3e908193aeae16fad98017437c (patch)
tree2732d02d7d51218d6eed98ac7fcfc5b8794896b5 /test/FixIt
parentcc73504950eb7b5dff2dded9bedd67bc36d64641 (diff)
downloadFreeBSD-src-056abd2059c65a3e908193aeae16fad98017437c.zip
FreeBSD-src-056abd2059c65a3e908193aeae16fad98017437c.tar.gz
Vendor import of clang release_32 branch r168974 (effectively, 3.2 RC2):
http://llvm.org/svn/llvm-project/cfe/branches/release_32@168974
Diffstat (limited to 'test/FixIt')
-rw-r--r--test/FixIt/fixit-cxx0x.cpp2
-rw-r--r--test/FixIt/fixit-include.c2
-rw-r--r--test/FixIt/fixit-missing-self-in-block.m20
-rw-r--r--test/FixIt/fixit-objc.m2
-rw-r--r--test/FixIt/fixit.c7
-rw-r--r--test/FixIt/fixit.cpp9
-rw-r--r--test/FixIt/format-darwin.m198
-rw-r--r--test/FixIt/no-fixit.cpp6
-rw-r--r--test/FixIt/typo.cpp42
9 files changed, 282 insertions, 6 deletions
diff --git a/test/FixIt/fixit-cxx0x.cpp b/test/FixIt/fixit-cxx0x.cpp
index 0c837b4..a173ce4 100644
--- a/test/FixIt/fixit-cxx0x.cpp
+++ b/test/FixIt/fixit-cxx0x.cpp
@@ -66,13 +66,11 @@ const char *p = "foo"bar; // expected-error {{requires a space between}}
#define ord - '0'
int k = '4'ord; // expected-error {{requires a space between}}
-void operator""_x(char); // expected-error {{requires a space}}
void operator"x" _y(char); // expected-error {{must be '""'}}
void operator L"" _z(char); // expected-error {{encoding prefix}}
void operator "x" "y" U"z" ""_whoops "z" "y"(char); // expected-error {{must be '""'}}
void f() {
- 'a'_x;
'b'_y;
'c'_z;
'd'_whoops;
diff --git a/test/FixIt/fixit-include.c b/test/FixIt/fixit-include.c
index 51bd9b0..383c513 100644
--- a/test/FixIt/fixit-include.c
+++ b/test/FixIt/fixit-include.c
@@ -3,8 +3,10 @@
// RUN: cp %S/fixit-include.h %T
// RUN: not %clang_cc1 -fsyntax-only -fixit %t
// RUN: %clang_cc1 -Wall -pedantic %t
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
#include <fixit-include.h> // expected-error {{'fixit-include.h' file not found with <angled> include; use "quotes" instead}}
+// CHECK: fix-it:{{.*}}:{8:10-8:27}
#pragma does_not_exist // expected-warning {{unknown pragma ignored}}
diff --git a/test/FixIt/fixit-missing-self-in-block.m b/test/FixIt/fixit-missing-self-in-block.m
new file mode 100644
index 0000000..8fd9564
--- /dev/null
+++ b/test/FixIt/fixit-missing-self-in-block.m
@@ -0,0 +1,20 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -x objective-c -fobjc-arc -fblocks -fixit %t
+// RUN: %clang_cc1 -x objective-c -fobjc-arc -fblocks -Werror %t
+// rdar://11194874
+
+@interface Root @end
+
+@interface I : Root
+{
+ int _bar;
+}
+@end
+
+@implementation I
+ - (void)foo{
+ ^{
+ _bar = 3;
+ }();
+ }
+@end
diff --git a/test/FixIt/fixit-objc.m b/test/FixIt/fixit-objc.m
index df591c7..77099fc 100644
--- a/test/FixIt/fixit-objc.m
+++ b/test/FixIt/fixit-objc.m
@@ -49,7 +49,7 @@ void f(Test *t) {
@property (assign) int y;
@end
-int f0(Radar7861841 *a) { return a.x; } // expected-error {{property 'x' not found on object of type 'Radar7861841 *'; did you mean to access ivar 'x'}}
+int f0(Radar7861841 *a) { return a.x; } // expected-error {{property 'x' not found on object of type 'Radar7861841 *'; did you mean to access instance variable 'x'}}
int f1(Radar7861841 *a) { return a->y; } // expected-error {{property 'y' found on object of type 'Radar7861841 *'; did you mean to access it with the "." operator?}}
diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c
index ce6f109..00adb19 100644
--- a/test/FixIt/fixit.c
+++ b/test/FixIt/fixit.c
@@ -81,6 +81,13 @@ void oopsMoreCommas() {
&a == &b ? oopsMoreCommas() : removeUnusedLabels(a[0]);
}
+int commaAtEndOfStatement() {
+ int a = 1;
+ a = 5, // expected-error {{';'}}
+ int m = 5, // expected-error {{';'}}
+ return 0, // expected-error {{';'}}
+}
+
int noSemiAfterLabel(int n) {
switch (n) {
default:
diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp
index 3eac434..253abd0 100644
--- a/test/FixIt/fixit.cpp
+++ b/test/FixIt/fixit.cpp
@@ -64,7 +64,7 @@ namespace rdar7796492 {
// extra qualification on member
class C {
- int C::foo(); // expected-warning {{extra qualification}}
+ int C::foo(); // expected-error {{extra qualification}}
};
namespace rdar8488464 {
@@ -292,3 +292,10 @@ namespace greatergreater {
//(void)(&t<S<int>>==p);
}
}
+
+class foo {
+ static void test() {
+ (void)&i; // expected-error{{must explicitly qualify name of member function when taking its address}}
+ }
+ int i();
+};
diff --git a/test/FixIt/format-darwin.m b/test/FixIt/format-darwin.m
new file mode 100644
index 0000000..1bfe272
--- /dev/null
+++ b/test/FixIt/format-darwin.m
@@ -0,0 +1,198 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -fblocks -Wformat-non-iso -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -Wformat-non-iso -verify %s
+
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fdiagnostics-parseable-fixits -fblocks -Wformat-non-iso %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fdiagnostics-parseable-fixits -fblocks -Wformat-non-iso %s 2>&1 | FileCheck %s
+
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fdiagnostics-parseable-fixits -fblocks -Wformat-non-iso %s 2>&1 | FileCheck -check-prefix=CHECK-32 %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fdiagnostics-parseable-fixits -fblocks -Wformat-non-iso %s 2>&1 | FileCheck -check-prefix=CHECK-64 %s
+
+int printf(const char * restrict, ...);
+
+#if __LP64__
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+typedef int SInt32;
+typedef unsigned int UInt32;
+
+#else
+
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+typedef long SInt32;
+typedef unsigned long UInt32;
+#endif
+
+NSInteger getNSInteger();
+NSUInteger getNSUInteger();
+SInt32 getSInt32();
+UInt32 getUInt32();
+
+void testCorrectionInAllCases() {
+ printf("%s", getNSInteger()); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+ printf("%s", getNSUInteger()); // expected-warning{{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
+ printf("%s", getSInt32()); // expected-warning{{values of type 'SInt32' should not be used as format arguments; add an explicit cast to 'int' instead}}
+ printf("%s", getUInt32()); // expected-warning{{values of type 'UInt32' should not be used as format arguments; add an explicit cast to 'unsigned int' instead}}
+
+ // CHECK: fix-it:"{{.*}}":{32:11-32:13}:"%ld"
+ // CHECK: fix-it:"{{.*}}":{32:16-32:16}:"(long)"
+
+ // CHECK: fix-it:"{{.*}}":{33:11-33:13}:"%lu"
+ // CHECK: fix-it:"{{.*}}":{33:16-33:16}:"(unsigned long)"
+
+ // CHECK: fix-it:"{{.*}}":{34:11-34:13}:"%d"
+ // CHECK: fix-it:"{{.*}}":{34:16-34:16}:"(int)"
+
+ // CHECK: fix-it:"{{.*}}":{35:11-35:13}:"%u"
+ // CHECK: fix-it:"{{.*}}":{35:16-35:16}:"(unsigned int)"
+}
+
+@interface Foo {
+@public
+ NSInteger _value;
+}
+- (NSInteger)getInteger;
+
+@property NSInteger value;
+@end
+
+struct Bar {
+ NSInteger value;
+};
+
+
+void testParens(Foo *obj, struct Bar *record) {
+ NSInteger arr[4] = {0};
+ NSInteger i = 0;
+
+ // These cases match the cases in CheckPrintfHandler::checkFormatExpr.
+ printf("%s", arr[0]); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+ printf("%s", getNSInteger()); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+ printf("%s", i); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+ printf("%s", obj->_value); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+ printf("%s", [obj getInteger]); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+ printf("%s", obj.value); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+ printf("%s", record->value); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+ printf("%s", (i ? i : i)); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+ printf("%s", *arr); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+
+ // CHECK-NOT: fix-it:{{.*}}:")"
+
+ printf("%s", i ? i : i); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+
+ // CHECK: fix-it:"{{.*}}":{81:11-81:13}:"%ld"
+ // CHECK: fix-it:"{{.*}}":{81:16-81:16}:"(long)("
+ // CHECK: fix-it:"{{.*}}":{81:25-81:25}:")"
+}
+
+
+#if __LP64__
+
+void testWarn() {
+ printf("%d", getNSInteger()); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+ printf("%u", getNSUInteger()); // expected-warning{{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
+ printf("%ld", getSInt32()); // expected-warning{{values of type 'SInt32' should not be used as format arguments; add an explicit cast to 'int' instead}}
+ printf("%lu", getUInt32()); // expected-warning{{values of type 'UInt32' should not be used as format arguments; add an explicit cast to 'unsigned int' instead}}
+
+ // CHECK-64: fix-it:"{{.*}}":{92:11-92:13}:"%ld"
+ // CHECK-64: fix-it:"{{.*}}":{92:16-92:16}:"(long)"
+
+ // CHECK-64: fix-it:"{{.*}}":{93:11-93:13}:"%lu"
+ // CHECK-64: fix-it:"{{.*}}":{93:16-93:16}:"(unsigned long)"
+
+ // CHECK-64: fix-it:"{{.*}}":{94:11-94:14}:"%d"
+ // CHECK-64: fix-it:"{{.*}}":{94:17-94:17}:"(int)"
+
+ // CHECK-64: fix-it:"{{.*}}":{95:11-95:14}:"%u"
+ // CHECK-64: fix-it:"{{.*}}":{95:17-95:17}:"(unsigned int)"
+}
+
+void testPreserveHex() {
+ printf("%x", getNSInteger()); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+ printf("%x", getNSUInteger()); // expected-warning{{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
+
+ // CHECK-64: fix-it:"{{.*}}":{111:11-111:13}:"%lx"
+ // CHECK-64: fix-it:"{{.*}}":{111:16-111:16}:"(long)"
+
+ // CHECK-64: fix-it:"{{.*}}":{112:11-112:13}:"%lx"
+ // CHECK-64: fix-it:"{{.*}}":{112:16-112:16}:"(unsigned long)"
+}
+
+void testNoWarn() {
+ printf("%ld", getNSInteger()); // no-warning
+ printf("%lu", getNSUInteger()); // no-warning
+ printf("%d", getSInt32()); // no-warning
+ printf("%u", getUInt32()); // no-warning
+}
+
+#else
+
+void testWarn() {
+ printf("%ld", getNSInteger()); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+ printf("%lu", getNSUInteger()); // expected-warning{{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
+ printf("%d", getSInt32()); // expected-warning{{values of type 'SInt32' should not be used as format arguments; add an explicit cast to 'int' instead}}
+ printf("%u", getUInt32()); // expected-warning{{values of type 'UInt32' should not be used as format arguments; add an explicit cast to 'unsigned int' instead}}
+
+ // CHECK-32: fix-it:"{{.*}}":{131:17-131:17}:"(long)"
+
+ // CHECK-32: fix-it:"{{.*}}":{132:17-132:17}:"(unsigned long)"
+
+ // CHECK-32: fix-it:"{{.*}}":{133:16-133:16}:"(int)"
+
+ // CHECK-32: fix-it:"{{.*}}":{134:16-134:16}:"(unsigned int)"
+}
+
+void testPreserveHex() {
+ printf("%lx", getNSInteger()); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+ printf("%lx", getNSUInteger()); // expected-warning{{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
+
+ // CHECK-32: fix-it:"{{.*}}":{146:17-146:17}:"(long)"
+
+ // CHECK-32: fix-it:"{{.*}}":{147:17-147:17}:"(unsigned long)"
+}
+
+void testNoWarn() {
+ printf("%d", getNSInteger()); // no-warning
+ printf("%u", getNSUInteger()); // no-warning
+ printf("%ld", getSInt32()); // no-warning
+ printf("%lu", getUInt32()); // no-warning
+}
+
+#endif
+
+
+void testCasts() {
+ printf("%s", (NSInteger)0); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+ printf("%s", (NSUInteger)0); // expected-warning{{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
+ printf("%s", (SInt32)0); // expected-warning{{values of type 'SInt32' should not be used as format arguments; add an explicit cast to 'int' instead}}
+ printf("%s", (UInt32)0); // expected-warning{{values of type 'UInt32' should not be used as format arguments; add an explicit cast to 'unsigned int' instead}}
+
+ // CHECK: fix-it:"{{.*}}":{165:11-165:13}:"%ld"
+ // CHECK: fix-it:"{{.*}}":{165:16-165:27}:"(long)"
+
+ // CHECK: fix-it:"{{.*}}":{166:11-166:13}:"%lu"
+ // CHECK: fix-it:"{{.*}}":{166:16-166:28}:"(unsigned long)"
+
+ // CHECK: fix-it:"{{.*}}":{167:11-167:13}:"%d"
+ // CHECK: fix-it:"{{.*}}":{167:16-167:24}:"(int)"
+
+ // CHECK: fix-it:"{{.*}}":{168:11-168:13}:"%u"
+ // CHECK: fix-it:"{{.*}}":{168:16-168:24}:"(unsigned int)"
+}
+
+void testCapitals() {
+ printf("%D", 1); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}}
+ printf("%U", 1); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}}
+ printf("%O", 1); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}}
+
+ // CHECK: fix-it:"{{.*}}":{184:12-184:13}:"d"
+ // CHECK: fix-it:"{{.*}}":{185:12-185:13}:"u"
+ // CHECK: fix-it:"{{.*}}":{186:12-186:13}:"o"
+
+
+ printf("%lD", 1); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}} expected-warning{{format specifies type 'long' but the argument has type 'int'}}
+
+ // FIXME: offering two somewhat-conflicting fixits is less than ideal.
+ // CHECK: fix-it:"{{.*}}":{193:13-193:14}:"d"
+ // CHECK: fix-it:"{{.*}}":{193:11-193:14}:"%D"
+}
diff --git a/test/FixIt/no-fixit.cpp b/test/FixIt/no-fixit.cpp
index c95c867..9da2922 100644
--- a/test/FixIt/no-fixit.cpp
+++ b/test/FixIt/no-fixit.cpp
@@ -5,3 +5,9 @@
// CHECK-NOT: fix-it:
template<template<typename> +> void func();
+
+struct {
+ void i() {
+ (void)&i;
+ }
+} x;
diff --git a/test/FixIt/typo.cpp b/test/FixIt/typo.cpp
index 3d40da8..b3568a5 100644
--- a/test/FixIt/typo.cpp
+++ b/test/FixIt/typo.cpp
@@ -5,7 +5,8 @@
// RUN: grep test_string %t
namespace std {
- template<typename T> class basic_string { // expected-note 2{{'basic_string' declared here}}
+ template<typename T> class basic_string { // expected-note 2{{'basic_string' declared here}} \
+ // expected-note {{'otherstd::basic_string' declared here}}
public:
int find(const char *substr); // expected-note{{'find' declared here}}
static const int npos = -1; // expected-note{{'npos' declared here}}
@@ -76,13 +77,50 @@ int foo() {
}
namespace nonstd {
- typedef std::basic_string<char> yarn; // expected-note{{'nonstd::yarn' declared here}}
+ typedef std::basic_string<char> yarn; // expected-note 2 {{'nonstd::yarn' declared here}}
+ int narf; // expected-note{{'nonstd::narf' declared here}}
}
yarn str4; // expected-error{{unknown type name 'yarn'; did you mean 'nonstd::yarn'?}}
+wibble::yarn str5; // expected-error{{no type named 'yarn' in namespace 'otherstd'; did you mean 'nonstd::yarn'?}}
+
+int poit() {
+ nonstd::basic_string<char> str; // expected-error{{no template named 'basic_string' in namespace 'nonstd'; did you mean 'otherstd::basic_string'?}}
+ return wibble::narf; // expected-error{{no member named 'narf' in namespace 'otherstd'; did you mean 'nonstd::narf'?}}
+}
namespace check_bool {
void f() {
Bool b; // expected-error{{use of undeclared identifier 'Bool'; did you mean 'bool'?}}
}
}
+
+namespace outr {
+}
+namespace outer {
+ namespace inner { // expected-note{{'outer::inner' declared here}} \
+ // expected-note{{namespace 'outer::inner' defined here}} \
+ // expected-note{{'inner' declared here}}
+ int i;
+ }
+}
+
+using namespace outr::inner; // expected-error{{no namespace named 'inner' in namespace 'outr'; did you mean 'outer::inner'?}}
+
+void func() {
+ outr::inner::i = 3; // expected-error{{no member named 'inner' in namespace 'outr'; did you mean 'outer::inner'?}}
+ outer::innr::i = 4; // expected-error{{no member named 'innr' in namespace 'outer'; did you mean 'inner'?}}
+}
+
+struct base {
+};
+struct derived : base {
+ int i;
+};
+
+void func2() {
+ derived d;
+ // FIXME: we should offer a fix here. We do if the 'i' is misspelled, but we don't do name qualification changes
+ // to replace base::i with derived::i as we would for other qualified name misspellings.
+ // d.base::i = 3;
+}
OpenPOWER on IntegriCloud