summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2010-04-02 08:55:10 +0000
committerrdivacky <rdivacky@FreeBSD.org>2010-04-02 08:55:10 +0000
commit07b2cfcdb817cc0790420f159a313d61e7241cb9 (patch)
treed374cdca417e76f1bf101f139dba2db1d10ee8f7 /test
parent1e255aab650a7fa2047fd953cae65b12215280af (diff)
downloadFreeBSD-src-07b2cfcdb817cc0790420f159a313d61e7241cb9.zip
FreeBSD-src-07b2cfcdb817cc0790420f159a313d61e7241cb9.tar.gz
Update clang to r100181.
Diffstat (limited to 'test')
-rw-r--r--test/Analysis/PR3991.m20
-rw-r--r--test/Analysis/inline.c2
-rw-r--r--test/Analysis/misc-ps-region-store.m45
-rw-r--r--test/Analysis/no-outofbounds.c3
-rw-r--r--test/Analysis/null-deref-ps.c4
-rw-r--r--test/Analysis/outofbound.c23
-rw-r--r--test/Analysis/plist-output.m40
-rw-r--r--test/Analysis/pr4209.m8
-rw-r--r--test/Analysis/retain-release-region-store.m16
-rw-r--r--test/Analysis/retain-release.m9
-rw-r--r--test/Analysis/uninit-vals-ps-region.m7
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp12
-rw-r--r--test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp13
-rw-r--r--test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp9
-rw-r--r--test/CXX/class.access/class.access.base/p5.cpp75
-rw-r--r--test/CXX/class.access/class.friend/p1.cpp43
-rw-r--r--test/CXX/class.access/p4.cpp69
-rw-r--r--test/CXX/class.derived/class.abstract/p4.cpp80
-rw-r--r--test/CXX/class.derived/class.abstract/p5.cpp23
-rw-r--r--test/CXX/class.derived/class.virtual/p2.cpp37
-rw-r--r--test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp43
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp14
-rw-r--r--test/CXX/stmt.stmt/stmt.select/p3.cpp11
-rw-r--r--test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp4
-rw-r--r--test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp80
-rw-r--r--test/CXX/temp/temp.decls/temp.friend/p1.cpp131
-rw-r--r--test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp26
-rw-r--r--test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p17.cpp31
-rw-r--r--test/CXX/temp/temp.res/temp.local/p1.cpp3
-rw-r--r--test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp2
-rw-r--r--test/CodeGen/atomic.c6
-rw-r--r--test/CodeGen/mangle.c4
-rw-r--r--test/CodeGen/palignr.c2
-rw-r--r--test/CodeGen/regparm.c11
-rw-r--r--test/CodeGen/restrict.c26
-rw-r--r--test/CodeGenCXX/constructor-init.cpp21
-rw-r--r--test/CodeGenCXX/copy-constructor-synthesis.cpp54
-rw-r--r--test/CodeGenCXX/member-expressions.cpp40
-rw-r--r--test/CodeGenCXX/multi-dim-operator-new.cpp49
-rw-r--r--test/CodeGenCXX/references.cpp8
-rw-r--r--test/CodeGenCXX/rtti-fundamental.cpp71
-rw-r--r--test/CodeGenCXX/rtti-linkage.cpp1
-rw-r--r--test/CodeGenCXX/template-instantiation.cpp76
-rw-r--r--test/CodeGenCXX/temporaries.cpp13
-rw-r--r--test/CodeGenCXX/thunks.cpp137
-rw-r--r--test/CodeGenCXX/virt.cpp52
-rw-r--r--test/CodeGenCXX/virtual-bases.cpp23
-rw-r--r--test/CodeGenCXX/vtable-layout-abi-examples.cpp1
-rw-r--r--test/CodeGenCXX/vtable-layout.cpp49
-rw-r--r--test/CodeGenCXX/vtable-linkage.cpp20
-rw-r--r--test/CodeGenObjC/complex-property.m32
-rw-r--r--test/CodeGenObjC/objc2-nonfragile-abi-impl.m15
-rw-r--r--test/Driver/nostdincxx.cpp4
-rw-r--r--test/FixIt/fixit.cpp3
-rw-r--r--test/Headers/c89.c10
-rw-r--r--test/Headers/x86-intrinsics-headers.c (renamed from test/Sema/x86-intrinsics-headers.c)0
-rw-r--r--test/Index/Inputs/remap-complete-to.c7
-rw-r--r--test/Index/cindex-on-invalid.m7
-rw-r--r--test/Index/print-usrs.c17
-rw-r--r--test/Index/recover-bad-code-rdar_7487294.c1
-rw-r--r--test/Index/remap-complete.c7
-rw-r--r--test/PCH/changed-files.c36
-rw-r--r--test/Parser/cxx-default-args.cpp9
-rw-r--r--test/Parser/objc-messaging-neg-1.m6
-rw-r--r--test/Parser/statements.c5
-rw-r--r--test/Preprocessor/dependencies-and-pp.c26
-rw-r--r--test/Preprocessor/macro_disable.c34
-rw-r--r--test/Preprocessor/macro_disable2.c8
-rw-r--r--test/Preprocessor/macro_disable3.c10
-rw-r--r--test/Preprocessor/macro_disable4.c6
-rw-r--r--test/Preprocessor/output_paste_avoid.c4
-rw-r--r--test/Sema/attr-format.c (renamed from test/Sema/format-attribute.c)46
-rw-r--r--test/Sema/attr-sentinel.c (renamed from test/Sema/function-sentinel-attr.c)24
-rw-r--r--test/Sema/attr-unused.c17
-rw-r--r--test/Sema/format-attr-pr4470.c12
-rw-r--r--test/Sema/format-attribute-printf0.c26
-rw-r--r--test/Sema/format-strings.c13
-rw-r--r--test/Sema/function-pointer-sentinel-attribute.c20
-rw-r--r--test/Sema/init.c3
-rw-r--r--test/Sema/nested-redef.c3
-rw-r--r--test/Sema/return.c17
-rw-r--r--test/Sema/struct-packed-align.c8
-rw-r--r--test/Sema/warn-gnu-designators.c2
-rw-r--r--test/Sema/warn-shadow.c5
-rw-r--r--test/SemaCXX/PR6618.cpp13
-rw-r--r--test/SemaCXX/class-base-member-init.cpp44
-rw-r--r--test/SemaCXX/class-layout.cpp7
-rw-r--r--test/SemaCXX/conditional-expr.cpp18
-rw-r--r--test/SemaCXX/destructor.cpp5
-rw-r--r--test/SemaCXX/exception-spec.cpp6
-rw-r--r--test/SemaCXX/invalid-member-expr.cpp18
-rw-r--r--test/SemaCXX/namespace-alias.cpp10
-rw-r--r--test/SemaCXX/namespace.cpp22
-rw-r--r--test/SemaCXX/nested-name-spec.cpp2
-rw-r--r--test/SemaCXX/new-delete-predefined-decl-2.cpp13
-rw-r--r--test/SemaCXX/qual-id-test.cpp9
-rw-r--r--test/SemaCXX/static-cast.cpp4
-rw-r--r--test/SemaCXX/warn-reorder-ctor-initialization.cpp12
-rw-r--r--test/SemaObjC/block-type-safety.m8
-rw-r--r--test/SemaObjC/category-1.m6
-rw-r--r--test/SemaObjC/compare-qualified-id.m7
-rw-r--r--test/SemaObjC/comptypes-7.m5
-rw-r--r--test/SemaObjC/conditional-expr.m4
-rw-r--r--test/SemaObjC/gcc-cast-ext.m6
-rw-r--r--test/SemaObjC/ivar-in-class-extension-error.m15
-rw-r--r--test/SemaObjC/ivar-in-implementations.m23
-rw-r--r--test/SemaObjC/ivar-sem-check-1.m3
-rw-r--r--test/SemaObjC/method-arg-decay.m10
-rw-r--r--test/SemaObjC/method-undef-category-warn-1.m22
-rw-r--r--test/SemaObjC/method-undef-extension-warn-1.m10
-rw-r--r--test/SemaObjC/method-undefined-warn-1.m16
-rw-r--r--test/SemaObjC/method-warn-unused-attribute.m12
-rw-r--r--test/SemaObjC/no-protocol-option-tests.m32
-rw-r--r--test/SemaObjC/nsobject-attribute.m6
-rw-r--r--test/SemaObjC/property-expression-error.m5
-rw-r--r--test/SemaObjC/property-in-class-extension.m15
-rw-r--r--test/SemaObjC/property-ivar-mismatch.m4
-rw-r--r--test/SemaObjC/property.m4
-rw-r--r--test/SemaObjC/undef-protocol-methods-1.m34
-rw-r--r--test/SemaTemplate/dependent-base-classes.cpp2
-rw-r--r--test/SemaTemplate/friend-template.cpp8
-rw-r--r--test/SemaTemplate/instantiate-declref.cpp2
-rw-r--r--test/SemaTemplate/instantiate-elab-type-specifier.cpp13
-rw-r--r--test/SemaTemplate/instantiate-expr-4.cpp13
-rw-r--r--test/SemaTemplate/instantiate-function-params.cpp57
-rw-r--r--test/SemaTemplate/instantiate-init.cpp18
-rw-r--r--test/SemaTemplate/instantiate-member-class.cpp30
-rw-r--r--test/SemaTemplate/instantiate-member-initializers.cpp6
-rw-r--r--test/SemaTemplate/instantiation-default-2.cpp2
-rw-r--r--test/SemaTemplate/temp_arg_nontype.cpp33
130 files changed, 2213 insertions, 391 deletions
diff --git a/test/Analysis/PR3991.m b/test/Analysis/PR3991.m
index 3fed57e..c1f238c 100644
--- a/test/Analysis/PR3991.m
+++ b/test/Analysis/PR3991.m
@@ -35,22 +35,16 @@ typedef struct _NSZone NSZone;
@protocol IHGoogleDocsAdapterDelegate - (void)googleDocsAdapter:(IHGoogleDocsAdapter*)inGoogleDocsAdapter accountVerifyIsValid:(BOOL)inIsValid error:(NSError *)inError;
@end @interface IHGoogleDocsAdapter : NSObject {
}
-- (NSArray *)entries;
+- (NSArray *)entries; // expected-note {{method definition for 'entries' not found}}
@end extern Class const kGDataUseRegisteredClass ;
-@interface IHGoogleDocsAdapter () - (GDataFeedDocList *)feedDocList;
-- (NSArray *)directoryPathComponents;
-- (unsigned int)currentPathComponentIndex;
-- (void)setCurrentPathComponentIndex:(unsigned int)aCurrentPathComponentIndex;
-- (NSURL *)folderFeedURL;
+@interface IHGoogleDocsAdapter () - (GDataFeedDocList *)feedDocList; // expected-note {{method definition for 'feedDocList' not found}}
+- (NSArray *)directoryPathComponents; // expected-note {{method definition for 'directoryPathComponents' not found}}
+- (unsigned int)currentPathComponentIndex; // expected-note {{method definition for 'currentPathComponentIndex' not found}}
+- (void)setCurrentPathComponentIndex:(unsigned int)aCurrentPathComponentIndex; // expected-note {{method definition for 'setCurrentPathComponentIndex:' not found}}
+- (NSURL *)folderFeedURL; // expected-note {{method definition for 'folderFeedURL' not found}}
@end
-@implementation IHGoogleDocsAdapter - (id)initWithUsername:(NSString *)inUsername password:(NSString *)inPassword owner:(NSObject <IHGoogleDocsAdapterDelegate> *)owner { // expected-warning {{incomplete implementation}} \
-// expected-warning {{method definition for 'entries' not found}} \
-// expected-warning {{method definition for 'feedDocList' not found}} \
-// expected-warning {{method definition for 'directoryPathComponents' not found}} \
-// expected-warning {{method definition for 'currentPathComponentIndex' not found}} \
-// expected-warning {{method definition for 'setCurrentPathComponentIndex:' not found}} \
-// expected-warning {{method definition for 'folderFeedURL' not found}}
+@implementation IHGoogleDocsAdapter - (id)initWithUsername:(NSString *)inUsername password:(NSString *)inPassword owner:(NSObject <IHGoogleDocsAdapterDelegate> *)owner { // expected-warning {{incomplete implementation}}
return 0;
}
diff --git a/test/Analysis/inline.c b/test/Analysis/inline.c
index 13d4f7f..952de73 100644
--- a/test/Analysis/inline.c
+++ b/test/Analysis/inline.c
@@ -15,6 +15,6 @@ void f2() {
}
if (x == 2) {
int *p = 0;
- *p = 3; // expected-warning{{Dereference of null pointer loaded from variable}}
+ *p = 3; // expected-warning{{Dereference of null pointer (loaded from variable 'p')}}
}
}
diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m
index 898a33e..d10b9fa 100644
--- a/test/Analysis/misc-ps-region-store.m
+++ b/test/Analysis/misc-ps-region-store.m
@@ -910,3 +910,48 @@ int rdar_7770737_pos(void)
struct rdar_7770737_s f = { .p = (intptr_t)&x };
return x; // expected-warning{{Undefined or garbage value returned to caller}}
}
+
+//===----------------------------------------------------------------------===//
+// Test handling of the implicit 'isa' field. For now we don't do anything
+// interesting.
+//===----------------------------------------------------------------------===//
+
+void pr6302(id x, Class y) {
+ // This previously crashed the analyzer (reported in PR 6302)
+ x->isa = y;
+}
+
+//===----------------------------------------------------------------------===//
+// Specially handle global variables that are declared constant. In the
+// example below, this forces the loop to take exactly 2 iterations.
+//===----------------------------------------------------------------------===//
+
+const int pr6288_L_N = 2;
+void pr6288_(void) {
+ int x[2];
+ int *px[2];
+ int i;
+ for (i = 0; i < pr6288_L_N; i++)
+ px[i] = &x[i];
+ *(px[0]) = 0; // no-warning
+}
+
+void pr6288_pos(int z) {
+ int x[2];
+ int *px[2];
+ int i;
+ for (i = 0; i < z; i++)
+ px[i] = &x[i]; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
+ *(px[0]) = 0; // expected-warning{{Dereference of undefined pointer value}}
+}
+
+void pr6288_b(void) {
+ const int L_N = 2;
+ int x[2];
+ int *px[2];
+ int i;
+ for (i = 0; i < L_N; i++)
+ px[i] = &x[i];
+ *(px[0]) = 0; // no-warning
+}
+
diff --git a/test/Analysis/no-outofbounds.c b/test/Analysis/no-outofbounds.c
index f9ac589..771323b 100644
--- a/test/Analysis/no-outofbounds.c
+++ b/test/Analysis/no-outofbounds.c
@@ -1,6 +1,5 @@
// RUN: %clang_cc1 -analyzer-check-objc-mem -analyze -analyzer-experimental-internal-checks -analyzer-store=basic -verify %s
// RUN: %clang_cc1 -analyzer-check-objc-mem -analyze -analyzer-experimental-internal-checks -analyzer-store=region -verify %s
-// XFAIL: *
//===----------------------------------------------------------------------===//
// This file tests cases where we should not flag out-of-bounds warnings.
@@ -10,4 +9,6 @@ void f() {
long x = 0;
char *y = (char*) &x;
char c = y[0] + y[1] + y[2]; // no-warning
+ short *z = (short*) &x;
+ short s = z[0] + z[1]; // no-warning
}
diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c
index 704ad33..5376ca0 100644
--- a/test/Analysis/null-deref-ps.c
+++ b/test/Analysis/null-deref-ps.c
@@ -26,7 +26,7 @@ int f2(struct foo_struct* p) {
if (p)
p->x = 1;
- return p->x++; // expected-warning{{Dereference of null pointer}}
+ return p->x++; // expected-warning{{Field access results in a dereference of a null pointer (loaded from variable 'p')}}
}
int f3(char* x) {
@@ -57,7 +57,7 @@ int f4(int *p) {
return 1;
int *q = (int*) x;
- return *q; // expected-warning{{Dereference of null pointer loaded from variable 'q'}}
+ return *q; // expected-warning{{Dereference of null pointer (loaded from variable 'q')}}
}
int f4_b() {
diff --git a/test/Analysis/outofbound.c b/test/Analysis/outofbound.c
index 45325e9..e1ff66c 100644
--- a/test/Analysis/outofbound.c
+++ b/test/Analysis/outofbound.c
@@ -13,3 +13,26 @@ void f2() {
int *p = malloc(12);
p[3] = 4; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
}
+
+struct three_words {
+ int c[3];
+};
+
+struct seven_words {
+ int c[7];
+};
+
+void f3() {
+ struct three_words a, *p;
+ p = &a;
+ p[0] = a; // no-warning
+ p[1] = a; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
+}
+
+void f4() {
+ struct seven_words c;
+ struct three_words a, *p = (struct three_words *)&c;
+ p[0] = a; // no-warning
+ p[1] = a; // no-warning
+ p[2] = a; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
+}
diff --git a/test/Analysis/plist-output.m b/test/Analysis/plist-output.m
index f49fef5..aa866de 100644
--- a/test/Analysis/plist-output.m
+++ b/test/Analysis/plist-output.m
@@ -124,7 +124,7 @@ void test_null_field(void) {
// CHECK: <array>
// CHECK: <dict>
// CHECK: <key>line</key><integer>5</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
@@ -135,12 +135,12 @@ void test_null_field(void) {
// CHECK: </array>
// CHECK: </array>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Dereference of null pointer loaded from variable &apos;p&apos;</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
-// CHECK: <string>Dereference of null pointer loaded from variable &apos;p&apos;</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: </dict>
// CHECK: </array>
-// CHECK: <key>description</key><string>Dereference of null pointer loaded from variable &apos;p&apos;</string>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>location</key>
@@ -262,7 +262,7 @@ void test_null_field(void) {
// CHECK: <array>
// CHECK: <dict>
// CHECK: <key>line</key><integer>11</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
@@ -273,12 +273,12 @@ void test_null_field(void) {
// CHECK: </array>
// CHECK: </array>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Dereference of null pointer loaded from variable &apos;p&apos;</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
-// CHECK: <string>Dereference of null pointer loaded from variable &apos;p&apos;</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: </dict>
// CHECK: </array>
-// CHECK: <key>description</key><string>Dereference of null pointer loaded from variable &apos;p&apos;</string>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>location</key>
@@ -400,7 +400,7 @@ void test_null_field(void) {
// CHECK: <array>
// CHECK: <dict>
// CHECK: <key>line</key><integer>18</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
@@ -411,12 +411,12 @@ void test_null_field(void) {
// CHECK: </array>
// CHECK: </array>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Dereference of null pointer loaded from variable &apos;q&apos;</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
// CHECK: <key>message</key>
-// CHECK: <string>Dereference of null pointer loaded from variable &apos;q&apos;</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
// CHECK: </dict>
// CHECK: </array>
-// CHECK: <key>description</key><string>Dereference of null pointer loaded from variable &apos;q&apos;</string>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>location</key>
@@ -538,7 +538,7 @@ void test_null_field(void) {
// CHECK: <array>
// CHECK: <dict>
// CHECK: <key>line</key><integer>23</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
@@ -549,12 +549,12 @@ void test_null_field(void) {
// CHECK: </array>
// CHECK: </array>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Dereference of null pointer loaded from variable &apos;p&apos;</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
-// CHECK: <string>Dereference of null pointer loaded from variable &apos;p&apos;</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: </dict>
// CHECK: </array>
-// CHECK: <key>description</key><string>Dereference of null pointer loaded from variable &apos;p&apos;</string>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>location</key>
@@ -710,7 +710,7 @@ void test_null_field(void) {
// CHECK: <array>
// CHECK: <dict>
// CHECK: <key>line</key><integer>30</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
@@ -721,12 +721,12 @@ void test_null_field(void) {
// CHECK: </array>
// CHECK: </array>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Dereference of null pointer loaded from variable &apos;p&apos;</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
-// CHECK: <string>Dereference of null pointer loaded from variable &apos;p&apos;</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: </dict>
// CHECK: </array>
-// CHECK: <key>description</key><string>Dereference of null pointer loaded from variable &apos;p&apos;</string>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>location</key>
diff --git a/test/Analysis/pr4209.m b/test/Analysis/pr4209.m
index eb01015..dc1ef7b 100644
--- a/test/Analysis/pr4209.m
+++ b/test/Analysis/pr4209.m
@@ -48,16 +48,14 @@ CMProfileLocation;
@interface GBCategoryChooserPanelController : NSWindowController {
GSEbayCategory *rootCategory;
}
-- (NSMutableDictionary*)categoryDictionaryForCategoryID:(int)inID inRootTreeCategories:(NSMutableArray*)inRootTreeCategories;
--(NSString*) categoryID;
+- (NSMutableDictionary*)categoryDictionaryForCategoryID:(int)inID inRootTreeCategories:(NSMutableArray*)inRootTreeCategories; // expected-note {{method definition for 'categoryDictionaryForCategoryID:inRootTreeCategories:' not found}}
+-(NSString*) categoryID; // expected-note {{method definition for 'categoryID' not found}}
@end @interface GSEbayCategory : NSObject <NSCoding> {
}
- (int) categoryID;
- (GSEbayCategory *) parent;
- (GSEbayCategory*) subcategoryWithID:(int) inID;
-@end @implementation GBCategoryChooserPanelController + (int) chooseCategoryIDFromCategories:(NSArray*) inCategories searchRequest:(GBSearchRequest*)inRequest parentWindow:(NSWindow*) inParent { // expected-warning {{incomplete implementation}} \
-// expected-warning {{method definition for 'categoryDictionaryForCategoryID:inRootTreeCategories:' not found}} \
-// expected-warning {{method definition for 'categoryID' not found}}
+@end @implementation GBCategoryChooserPanelController + (int) chooseCategoryIDFromCategories:(NSArray*) inCategories searchRequest:(GBSearchRequest*)inRequest parentWindow:(NSWindow*) inParent { // expected-warning {{incomplete implementation}}
return 0;
}
- (void) addCategory:(EBayCategoryType*)inCategory toRootTreeCategory:(NSMutableArray*)inRootTreeCategories {
diff --git a/test/Analysis/retain-release-region-store.m b/test/Analysis/retain-release-region-store.m
index 111d4b9..db49b91 100644
--- a/test/Analysis/retain-release-region-store.m
+++ b/test/Analysis/retain-release-region-store.m
@@ -207,3 +207,19 @@ void rdar7283470_2_positive(void) {
[numbers[i] release];
}
+void pr6699(int x) {
+ CFDateRef values[2];
+ values[0] = values[1] = 0;
+
+ if (x) {
+ CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+ values[1] = CFDateCreate(0, t);
+ }
+
+ if (values[1]) {
+ // A bug in RegionStore::RemoveDeadBindings caused 'values[1]' to get prematurely
+ // pruned from the store.
+ CFRelease(values[1]); // no-warning
+ }
+}
+
diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m
index 675e9a6..3f79c0c 100644
--- a/test/Analysis/retain-release.m
+++ b/test/Analysis/retain-release.m
@@ -1268,6 +1268,7 @@ CFDateRef returnsRetainedCFDate() {
//===----------------------------------------------------------------------===//
void panic() __attribute__((noreturn));
+void panic_not_in_hardcoded_list() __attribute__((noreturn));
void test_panic_negative() {
signed z = 1;
@@ -1291,9 +1292,13 @@ void test_panic_pos_2(int x) {
signed z = 1;
CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // no-warning
if (x)
- panic();
- if (!x)
panic();
+ if (!x) {
+ // This showed up in <rdar://problem/7796563>, where we silently missed checking
+ // the function type for noreturn. "panic()" is a hard-coded known panic function
+ // that isn't always noreturn.
+ panic_not_in_hardcoded_list();
+ }
}
//===----------------------------------------------------------------------===//
diff --git a/test/Analysis/uninit-vals-ps-region.m b/test/Analysis/uninit-vals-ps-region.m
index 7e2fff9..69c1ecd 100644
--- a/test/Analysis/uninit-vals-ps-region.m
+++ b/test/Analysis/uninit-vals-ps-region.m
@@ -59,4 +59,11 @@ void testFoo(Foo *o) {
[o passVal:x]; // expected-warning{{Passed-by-value struct argument contains uninitialized data (e.g., field: 'x')}}
}
+// Test case from <rdar://problem/7780304>. That shows an uninitialized value
+// being used in the LHS of a compound assignment.
+void rdar_7780304() {
+ typedef struct s_r7780304 { int x; } s_r7780304;
+ s_r7780304 b;
+ b.x |= 1; // expected-warning{{The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage}}
+}
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
index b59e6ca..df3429e 100644
--- a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
+++ b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
@@ -40,3 +40,15 @@ namespace Test {
D::D() + D::D(); // expected-error {{ invalid operands to binary expression ('D::D' and 'D::D') }}
}
}
+
+// PR6716
+namespace test1 {
+ template <class T> class A {
+ template <class U> friend void foo(A &, U); // expected-note {{not viable: 1st argument ('A<int> const') would lose const qualifier}}
+ };
+
+ void test() {
+ const A<int> a;
+ foo(a, 10); // expected-error {{no matching function for call to 'foo'}}
+ }
+}
diff --git a/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp b/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp
new file mode 100644
index 0000000..4567c46
--- /dev/null
+++ b/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+namespace std {
+ class bad_alloc { };
+
+ typedef __SIZE_TYPE__ size_t;
+}
+
+class foo { virtual ~foo(); };
+
+void* operator new(std::size_t);
+void* operator new[](std::size_t);
+void operator delete(void*);
+void operator delete[](void*);
diff --git a/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp b/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp
index f4860bb..37a4f97 100644
--- a/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp
+++ b/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fexceptions -verify %s
int *use_new(int N) {
if (N == 1)
return new int;
@@ -19,7 +19,10 @@ namespace std {
typedef __SIZE_TYPE__ size_t;
}
-void* operator new(std::size_t) throw(std::bad_alloc);
+void* operator new(std::size_t) throw(std::bad_alloc); // expected-note{{previous declaration}}
void* operator new[](std::size_t) throw(std::bad_alloc);
-void operator delete(void*) throw();
+void operator delete(void*) throw(); // expected-note{{previous declaration}}
void operator delete[](void*) throw();
+
+void* operator new(std::size_t); // expected-warning{{'operator new' is missing exception specification 'throw(std::bad_alloc)'}}
+void operator delete(void*); // expected-warning{{'operator delete' is missing exception specification 'throw()'}}
diff --git a/test/CXX/class.access/class.access.base/p5.cpp b/test/CXX/class.access/class.access.base/p5.cpp
new file mode 100644
index 0000000..96037e7
--- /dev/null
+++ b/test/CXX/class.access/class.access.base/p5.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -faccess-control -verify %s
+
+namespace test0 {
+ struct A {
+ static int x;
+ };
+ struct B : A {};
+ struct C : B {};
+
+ int test() {
+ return A::x
+ + B::x
+ + C::x;
+ }
+}
+
+namespace test1 {
+ struct A {
+ private: static int x; // expected-note 5 {{declared private here}}
+ static int test() { return x; }
+ };
+ struct B : public A {
+ static int test() { return x; } // expected-error {{private member}}
+ };
+ struct C : private A {
+ static int test() { return x; } // expected-error {{private member}}
+ };
+
+ struct D {
+ public: static int x;
+ static int test() { return x; }
+ };
+ struct E : private D { // expected-note{{constrained by private inheritance}}
+ static int test() { return x; }
+ };
+
+ int test() {
+ return A::x // expected-error {{private member}}
+ + B::x // expected-error {{private member}}
+ + C::x // expected-error {{private member}}
+ + D::x
+ + E::x; // expected-error {{private member}}
+ }
+}
+
+namespace test2 {
+ class A {
+ protected: static int x;
+ };
+
+ class B : private A {}; // expected-note {{private inheritance}}
+ class C : private A {
+ int test(B *b) {
+ return b->x; // expected-error {{private member}}
+ }
+ };
+}
+
+namespace test3 {
+ class A {
+ protected: static int x;
+ };
+
+ class B : public A {};
+ class C : private A {
+ int test(B *b) {
+ // x is accessible at C when named in A.
+ // A is an accessible base of B at C.
+ // Therefore this succeeds.
+ return b->x;
+ }
+ };
+}
+
+// TODO: flesh out these cases
diff --git a/test/CXX/class.access/class.friend/p1.cpp b/test/CXX/class.access/class.friend/p1.cpp
index 851cd3d..22266cd 100644
--- a/test/CXX/class.access/class.friend/p1.cpp
+++ b/test/CXX/class.access/class.friend/p1.cpp
@@ -149,3 +149,46 @@ namespace test2 {
// expected-error {{'getNext' is a private member of 'test2::ilist_node'}}
};
}
+
+namespace test3 {
+ class A { protected: int x; }; // expected-note {{declared protected here}}
+
+ class B : public A {
+ friend int foo(B*);
+ };
+
+ int foo(B *p) {
+ return p->x;
+ }
+
+ int foo(const B *p) {
+ return p->x; // expected-error {{'x' is a protected member of 'test3::A'}}
+ }
+}
+
+namespace test3a {
+ class A { protected: int x; };
+
+ class B : public A {
+ friend int foo(B*);
+ };
+
+ int foo(B * const p) {
+ return p->x;
+ }
+}
+
+namespace test4 {
+ template <class T> class Holder {
+ T object;
+ friend bool operator==(Holder &a, Holder &b) {
+ return a.object == b.object; // expected-error {{invalid operands to binary expression}}
+ }
+ };
+
+ struct Inequal {};
+ bool test() {
+ Holder<Inequal> a, b;
+ return a == b; // expected-note {{requested here}}
+ }
+}
diff --git a/test/CXX/class.access/p4.cpp b/test/CXX/class.access/p4.cpp
index bc69bee..3bbdbab8 100644
--- a/test/CXX/class.access/p4.cpp
+++ b/test/CXX/class.access/p4.cpp
@@ -101,14 +101,14 @@ namespace test2 {
namespace test3 {
class A {
private:
- ~A(); // expected-note 3 {{declared private here}}
+ ~A(); // expected-note 2 {{declared private here}}
static A foo;
};
A a; // expected-error {{variable of type 'test3::A' has private destructor}}
A A::foo;
- void foo(A param) { // expected-error {{variable of type 'test3::A' has private destructor}}
+ void foo(A param) { // okay
A local; // expected-error {{variable of type 'test3::A' has private destructor}}
}
@@ -262,3 +262,68 @@ namespace test9 {
static int getX() { return x; } // expected-error {{'x' is a private member of 'test9::A'}}
};
}
+
+namespace test10 {
+ class A {
+ enum {
+ value = 10 // expected-note {{declared private here}}
+ };
+ friend class C;
+ };
+
+ class B {
+ enum {
+ value = A::value // expected-error {{'value' is a private member of 'test10::A'}}
+ };
+ };
+
+ class C {
+ enum {
+ value = A::value
+ };
+ };
+}
+
+namespace test11 {
+ class A {
+ protected: virtual ~A();
+ };
+
+ class B : public A {
+ ~B();
+ };
+
+ B::~B() {};
+}
+
+namespace test12 {
+ class A {
+ int x;
+
+ void foo() {
+ class Local {
+ int foo(A *a) {
+ return a->x;
+ }
+ };
+ }
+ };
+}
+
+namespace test13 {
+ struct A {
+ int x;
+ unsigned foo() const;
+ };
+
+ struct B : protected A {
+ using A::foo;
+ using A::x;
+ };
+
+ void test() {
+ A *d;
+ d->foo();
+ (void) d->x;
+ }
+}
diff --git a/test/CXX/class.derived/class.abstract/p4.cpp b/test/CXX/class.derived/class.abstract/p4.cpp
new file mode 100644
index 0000000..ca99bf7
--- /dev/null
+++ b/test/CXX/class.derived/class.abstract/p4.cpp
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR6631 {
+ struct A {
+ virtual void f() = 0;
+ };
+
+ struct B : virtual A { };
+
+ struct C : virtual A {
+ virtual void f();
+ };
+
+ struct D : public B, public C {
+ virtual void f();
+ };
+
+ void f() {
+ (void)new D; // okay
+ }
+}
+
+// Check cases where we have a virtual function that is pure in one
+// subobject but not pure in another subobject.
+namespace PartlyPure {
+ struct A {
+ virtual void f() = 0; // expected-note{{pure virtual function}}
+ };
+
+ struct B : A {
+ virtual void f();
+ };
+
+ struct C : virtual A { };
+
+ struct D : B, C { };
+
+ void f() {
+ (void) new D; // expected-error{{abstract type}}
+ }
+}
+
+namespace NonPureAlongOnePath {
+ struct A {
+ virtual void f() = 0;
+ };
+
+ struct B : virtual A {
+ virtual void f();
+ };
+
+ struct C : virtual A { };
+
+ struct D : B, C { };
+
+ void f() {
+ (void) new D; // okay
+ }
+}
+
+namespace NonPureAlongOnePath2 {
+ struct Aprime {
+ virtual void f() = 0;
+ };
+
+ struct A : Aprime {
+ };
+
+ struct B : virtual A {
+ virtual void f();
+ };
+
+ struct C : virtual A { };
+
+ struct D : B, C { };
+
+ void f() {
+ (void) new D; // okay
+ }
+}
diff --git a/test/CXX/class.derived/class.abstract/p5.cpp b/test/CXX/class.derived/class.abstract/p5.cpp
new file mode 100644
index 0000000..207519d
--- /dev/null
+++ b/test/CXX/class.derived/class.abstract/p5.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {
+ virtual void f() = 0; // expected-note{{pure virtual function}}
+};
+
+struct B : A {
+ virtual void f();
+};
+
+struct C : B {
+ virtual void f() = 0; // expected-note 2{{pure virtual function}}
+};
+
+struct D : C {
+};
+
+void test() {
+ (void)new A; // expected-error{{object of abstract type}}
+ (void)new B;
+ (void)new C; // expected-error{{object of abstract type}}
+ (void)new D; // expected-error{{object of abstract type}}
+}
diff --git a/test/CXX/class.derived/class.virtual/p2.cpp b/test/CXX/class.derived/class.virtual/p2.cpp
new file mode 100644
index 0000000..64d93c8
--- /dev/null
+++ b/test/CXX/class.derived/class.virtual/p2.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct A {
+ virtual void f() = 0; // expected-note 2{{overridden virtual function}}
+};
+
+struct Aprime : virtual A {
+ virtual void f();
+};
+
+struct B : Aprime {
+ virtual void f(); // expected-note 3{{final overrider of 'A::f'}}
+};
+
+struct C : virtual A {
+ virtual void f(); // expected-note{{final overrider of 'A::f'}}
+};
+
+struct D : B, C { }; // expected-error{{virtual function 'A::f' has more than one final overrider in 'D'}}
+
+struct B2 : B { };
+
+struct E : B, B2 { }; //expected-error{{virtual function 'A::f' has more than one final overrider in 'E'}}
+
+struct F : B, B2 {
+ virtual void f(); // okay
+};
+
+struct G : F { }; // okay
+
+struct H : G, A { }; // okay
+
+namespace MultipleSubobjects {
+ struct A { virtual void f(); };
+ struct B : A { virtual void f(); };
+ struct C : A { virtual void f(); };
+ struct D : B, C { }; // okay
+}
diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp
index 935f576..89e9c89 100644
--- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp
+++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s
// We have to avoid ADL for this test.
@@ -65,3 +65,44 @@ namespace Test1 {
b _2 = B::b();
}
}
+
+namespace test2 {
+ class A {
+ protected:
+ operator int();
+ operator bool();
+ };
+
+ class B : private A {
+ protected:
+ using A::operator int; // expected-note {{'declared protected here'}}
+ public:
+ using A::operator bool;
+ };
+
+ int test() {
+ bool b = B();
+ return B(); // expected-error {{'operator int' is a protected member of 'test2::B'}}
+ }
+}
+
+namespace test3 {
+ class A {
+ ~A();
+ };
+
+ class B {
+ friend class C;
+ private:
+ operator A*();
+ };
+
+ class C : public B {
+ public:
+ using B::operator A*;
+ };
+
+ void test() {
+ delete C();
+ }
+}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp
index 392888e..c530311 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp
@@ -25,8 +25,7 @@ template <> class B<int> {
};
template <> struct B<A> {
- // FIXME: the error here should be associated with the use at "void foo..."
- union Member { // expected-note 4 {{previous use is here}} expected-error {{tag type that does not match previous declaration}}
+ union Member { // expected-note 4 {{previous use is here}}
void* a;
};
};
@@ -41,10 +40,10 @@ void c2(class B<float>::Member);
void c3(union B<float>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}}
void c4(enum B<float>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}}
-void d1(struct B<int>::Member); // expected-error {{'Member' does not name a tag member in the specified scope}}
-void d2(class B<int>::Member); // expected-error {{'Member' does not name a tag member in the specified scope}}
-void d3(union B<int>::Member); // expected-error {{'Member' does not name a tag member in the specified scope}}
-void d4(enum B<int>::Member); // expected-error {{'Member' does not name a tag member in the specified scope}}
+void d1(struct B<int>::Member); // expected-error {{no struct named 'Member' in 'B<int>'}}
+void d2(class B<int>::Member); // expected-error {{no class named 'Member' in 'B<int>'}}
+void d3(union B<int>::Member); // expected-error {{no union named 'Member' in 'B<int>'}}
+void d4(enum B<int>::Member); // expected-error {{no enum named 'Member' in 'B<int>'}}
void e1(struct B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}}
void e2(class B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}}
@@ -52,7 +51,8 @@ void e3(union B<A>::Member);
void e4(enum B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}}
template <class T> struct C {
- void foo(class B<T>::Member); // expected-error{{no type named 'Member' in 'B<int>'}}
+ void foo(class B<T>::Member); // expected-error{{no class named 'Member' in 'B<int>'}} \
+ // expected-error{{use of 'Member' with tag type that does not match previous declaration}}
};
C<float> f1;
diff --git a/test/CXX/stmt.stmt/stmt.select/p3.cpp b/test/CXX/stmt.stmt/stmt.select/p3.cpp
new file mode 100644
index 0000000..e674f97
--- /dev/null
+++ b/test/CXX/stmt.stmt/stmt.select/p3.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int f();
+
+void g() {
+ if (int x = f()) { // expected-note 2{{previous definition}}
+ int x; // expected-error{{redefinition of 'x'}}
+ } else {
+ int x; // expected-error{{redefinition of 'x'}}
+ }
+}
diff --git a/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp b/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
index 83365a2..14dace8 100644
--- a/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
+++ b/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
@@ -49,9 +49,9 @@ namespace addr_of_obj_or_func {
// -- a pointer to member expressed as described in 5.3.1.
namespace bad_args {
- template <int* N> struct X0 { };
+ template <int* N> struct X0 { }; // expected-note 2{{template parameter is declared here}}
int i = 42;
X0<&i + 2> x0a; // expected-error{{non-type template argument does not refer to any declaration}}
int* iptr = &i;
- X0<iptr> x0b; // FIXME: This should not be accepted.
+ X0<iptr> x0b; // expected-error{{non-type template argument for template parameter of pointer type 'int *' must have its address taken}}
}
diff --git a/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp b/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp
index 458aff2..b0f1c46 100644
--- a/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp
+++ b/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp
@@ -7,6 +7,14 @@
// program is ill-formed.
// -- for a non-type template-parameter of integral or enumeration type,
// integral promotions (4.5) and integral conversions (4.7) are applied.
+namespace integral_parameters {
+ template<short s> struct X0 { };
+ X0<17> x0i;
+ X0<'a'> x0c;
+ template<char c> struct X1 { };
+ X1<100l> x1l;
+}
+
// -- for a non-type template-parameter of type pointer to object,
// qualification conversions (4.4) and the array-to-pointer conversion
// (4.2) are applied; if the template-argument is of type
@@ -37,12 +45,12 @@ namespace pointer_to_object_parameters {
operator int() const;
};
- template<X const *Ptr> struct A2;
+ template<X const *Ptr> struct A2; // expected-note{{template parameter is declared here}}
X *X_ptr;
X an_X;
X array_of_Xs[10];
- A2<X_ptr> *a12;
+ A2<X_ptr> *a12; // expected-error{{must have its address taken}}
A2<array_of_Xs> *a13;
A2<&an_X> *a13_2;
A2<(&an_X)> *a13_3; // expected-error{{non-type template argument cannot be surrounded by parentheses}}
@@ -52,6 +60,16 @@ namespace pointer_to_object_parameters {
template <X1*> struct X2 { };
template <X1* Value> struct X3 : X2<Value> { };
struct X4 : X3<&X1v> { };
+
+ // PR6563
+ int *bar;
+ template <int *> struct zed {}; // expected-note 2{{template parameter is declared here}}
+ void g(zed<bar>*); // expected-error{{must have its address taken}}
+
+ int baz;
+ void g2(zed<baz>*); // expected-error{{must have its address taken}}
+
+ void g3(zed<&baz>*); // okay
}
// -- For a non-type template-parameter of type reference to object, no
@@ -105,6 +123,12 @@ namespace reference_parameters {
bind<int, counter>(); // expected-note{{instantiation of}}
}
}
+
+ namespace PR6749 {
+ template <int& i> struct foo {}; // expected-note{{template parameter is declared here}}
+ int x, &y = x;
+ foo<y> f; // expected-error{{is not an object}}
+ }
}
// -- For a non-type template-parameter of type pointer to function, the
@@ -113,17 +137,69 @@ namespace reference_parameters {
// conversion (4.10) is applied. If the template-argument represents
// a set of overloaded functions (or a pointer to such), the matching
// function is selected from the set (13.4).
+namespace pointer_to_function {
+ template<int (*)(int)> struct X0 { }; // expected-note 3{{template parameter is declared here}}
+ int f(int);
+ int f(float);
+ int g(float);
+ int (*funcptr)(int);
+ void x0a(X0<f>);
+ void x0b(X0<&f>);
+ void x0c(X0<g>); // expected-error{{non-type template argument of type 'int (float)' cannot be converted to a value of type 'int (*)(int)'}}
+ void x0d(X0<&g>); // expected-error{{non-type template argument of type 'int (*)(float)' cannot be converted to a value of type 'int (*)(int)'}}
+ void x0e(X0<funcptr>); // expected-error{{must have its address taken}}
+}
+
// -- For a non-type template-parameter of type reference to function, no
// conversions apply. If the template-argument represents a set of
// overloaded functions, the matching function is selected from the set
// (13.4).
+namespace reference_to_function {
+ template<int (&)(int)> struct X0 { }; // expected-note 4{{template parameter is declared here}}
+ int f(int);
+ int f(float);
+ int g(float);
+ int (*funcptr)(int);
+ void x0a(X0<f>);
+ void x0b(X0<&f>); // expected-error{{address taken in non-type template argument for template parameter of reference type 'int (&)(int)'}}
+ void x0c(X0<g>); // expected-error{{non-type template parameter of reference type 'int (&)(int)' cannot bind to template argument of type 'int (float)'}}
+ void x0d(X0<&g>); // expected-error{{address taken in non-type template argument for template parameter of reference type 'int (&)(int)'}}
+ void x0e(X0<funcptr>); // expected-error{{non-type template parameter of reference type 'int (&)(int)' cannot bind to template argument of type 'int (*)(int)'}}
+}
// -- For a non-type template-parameter of type pointer to member function,
// if the template-argument is of type std::nullptr_t, the null member
// pointer conversion (4.11) is applied; otherwise, no conversions
// apply. If the template-argument represents a set of overloaded member
// functions, the matching member function is selected from the set
// (13.4).
+namespace pointer_to_member_function {
+ struct X { };
+ struct Y : X {
+ int f(int);
+ int g(int);
+ int g(float);
+ float h(float);
+ };
+
+ template<int (Y::*)(int)> struct X0 {}; // expected-note{{template parameter is declared here}}
+ X0<&Y::f> x0a;
+ X0<&Y::g> x0b;
+ X0<&Y::h> x0c; // expected-error{{non-type template argument of type 'float (pointer_to_member_function::Y::*)(float)' cannot be converted to a value of type 'int (pointer_to_member_function::Y::*)(int)'}}
+}
+
// -- For a non-type template-parameter of type pointer to data member,
// qualification conversions (4.4) are applied; if the template-argument
// is of type std::nullptr_t, the null member pointer conversion (4.11)
// is applied.
+namespace pointer_to_member_data {
+ struct X { int x; };
+ struct Y : X { int y; };
+
+ template<int Y::*> struct X0 {}; // expected-note{{template parameter is declared here}}
+ X0<&Y::y> x0a;
+ X0<&Y::x> x0b; // expected-error{{non-type template argument of type 'int pointer_to_member_data::X::*' cannot be converted to a value of type 'int pointer_to_member_data::Y::*'}}
+
+ // Test qualification conversions
+ template<const int Y::*> struct X1 {};
+ X1<&Y::y> x1a;
+}
diff --git a/test/CXX/temp/temp.decls/temp.friend/p1.cpp b/test/CXX/temp/temp.decls/temp.friend/p1.cpp
index f1b3c81..c9dc546 100644
--- a/test/CXX/temp/temp.decls/temp.friend/p1.cpp
+++ b/test/CXX/temp/temp.decls/temp.friend/p1.cpp
@@ -1,5 +1,6 @@
// RUN: %clang_cc1 -faccess-control -verify -emit-llvm-only %s
+namespace test0 {
template <typename T> struct Num {
T value_;
@@ -54,6 +55,7 @@ int calc2() {
Num<int> result = x * n;
return result.get();
}
+}
// Reduced from GNU <locale>
namespace test1 {
@@ -85,3 +87,132 @@ namespace test2 {
}
};
}
+
+namespace test3 {
+ class Bool;
+ template <class T> class User;
+ template <class T> T transform(class Bool, T);
+
+ class Bool {
+ friend class User<bool>;
+ friend bool transform<>(Bool, bool);
+
+ bool value; // expected-note 2 {{declared private here}}
+ };
+
+ template <class T> class User {
+ static T compute(Bool b) {
+ return b.value; // expected-error {{'value' is a private member of 'test3::Bool'}}
+ }
+ };
+
+ template <class T> T transform(Bool b, T value) {
+ if (b.value) // expected-error {{'value' is a private member of 'test3::Bool'}}
+ return value;
+ return value + 1;
+ }
+
+ template bool transform(Bool, bool);
+ template int transform(Bool, int); // expected-note {{requested here}}
+
+ template class User<bool>;
+ template class User<int>; // expected-note {{requested here}}
+}
+
+namespace test4 {
+ template <class T> class A {
+ template <class T0> friend class B;
+ bool foo(const A<T> *) const;
+ };
+
+ template <class T> class B {
+ bool bar(const A<T> *a, const A<T> *b) {
+ return a->foo(b);
+ }
+ };
+
+ template class B<int>;
+}
+
+namespace test5 {
+ template <class T, class U=int> class A {};
+ template <class T> class B {
+ template <class X, class Y> friend class A;
+ };
+ template class B<int>;
+ template class A<int>;
+}
+
+namespace Dependent {
+ template<typename T, typename Traits> class X;
+ template<typename T, typename Traits>
+ X<T, Traits> operator+(const X<T, Traits>&, const T*);
+
+ template<typename T, typename Traits> class X {
+ typedef typename Traits::value_type value_type;
+ friend X operator+<>(const X&, const value_type*);
+ };
+}
+
+namespace test7 {
+ template <class T> class A { // expected-note {{previous definition is here}}
+ friend class B;
+ int x; // expected-note {{declared private here}}
+ };
+
+ class B {
+ int foo(A<int> &a) {
+ return a.x;
+ }
+ };
+
+ class C {
+ int foo(A<int> &a) {
+ return a.x; // expected-error {{'x' is a private member of 'test7::A<int>'}}
+ }
+ };
+
+ // This shouldn't crash.
+ template <class T> class D {
+ friend class A; // expected-error {{redefinition of 'A' as different kind of symbol}}
+ };
+ template class D<int>;
+}
+
+namespace test8 {
+ template <class N> class A {
+ static int x;
+ template <class T> friend void foo();
+ };
+ template class A<int>;
+
+ template <class T> void foo() {
+ A<int>::x = 0;
+ }
+ template void foo<int>();
+}
+
+namespace test9 {
+ template <class T> class A {
+ class B; class C;
+
+ int foo(B *b) {
+ return b->x;
+ }
+
+ int foo(C *c) {
+ return c->x; // expected-error {{'x' is a private member}}
+ }
+
+ class B {
+ int x;
+ friend int A::foo(B*);
+ };
+
+ class C {
+ int x; // expected-note {{declared private here}}
+ };
+ };
+
+ template class A<int>; // expected-note {{in instantiation}}
+}
diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp
new file mode 100644
index 0000000..c27261c
--- /dev/null
+++ b/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template <int> int f(int); // expected-note 2{{candidate}}
+template <signed char> int f(int); // expected-note 2{{candidate}}
+int i1 = f<1>(0); // expected-error{{ambiguous}}
+int i2 = f<1000>(0); // expected-error{{ambiguous}}
+
+namespace PR6707 {
+ template<typename T, T Value>
+ struct X { };
+
+ template<typename T, T Value>
+ void f(X<T, Value>);
+
+ void g(X<int, 10> x) {
+ f(x);
+ }
+
+ static const unsigned char ten = 10;
+ template<typename T, T Value, typename U>
+ void f2(X<T, Value>, X<U, Value>);
+
+ void g2() {
+ f2(X<int, 10>(), X<char, ten>());
+ }
+}
diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p17.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p17.cpp
new file mode 100644
index 0000000..2a7f16d
--- /dev/null
+++ b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p17.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<int i> class A { };
+template<short s> void f(A<s>); // expected-note{{failed template argument deduction}}
+
+void k1() {
+ A<1> a;
+ f(a); // expected-error{{no matching function for call}}
+ f<1>(a);
+}
+template<const short cs> class B { };
+template<short s> void g(B<s>);
+void k2() {
+ B<1> b;
+ g(b); // OK: cv-qualifiers are ignored on template parameter types
+}
+
+template<short s> void h(int (&)[s]); // expected-note{{failed template argument deduction}}
+void k3() {
+ int array[5];
+ h(array);
+ h<5>(array);
+}
+
+template<short s> void h(int (&)[s], A<s>); // expected-note{{failed template argument deduction}}
+void k4() {
+ A<5> a;
+ int array[5];
+ h(array, a); // expected-error{{no matching function for call}}
+ h<5>(array, a);
+}
diff --git a/test/CXX/temp/temp.res/temp.local/p1.cpp b/test/CXX/temp/temp.res/temp.local/p1.cpp
index ed534a4..1ad4464 100644
--- a/test/CXX/temp/temp.res/temp.local/p1.cpp
+++ b/test/CXX/temp/temp.res/temp.local/p1.cpp
@@ -26,8 +26,7 @@ template <int N1, const int& N2, const int* N3> struct X1 {
// FIXME: Test this clause.
int i = 42;
-int* iptr = &i;
void test() {
X0<int> x0; (void)x0;
- X1<42, i, iptr> x1; (void)x1;
+ X1<42, i, &i> x1; (void)x1;
}
diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp
index f987c12..86cdcf8 100644
--- a/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp
+++ b/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp
@@ -6,7 +6,7 @@ template<typename T>
struct A { };
struct X {
- template<> friend void f<int>(int); // expected-error{{in class scope}}
+ template<> friend void f<int>(int); // expected-error{{in a friend}}
template<> friend class A<int>; // expected-error{{cannot be a friend}}
friend void f<float>(float); // okay
diff --git a/test/CodeGen/atomic.c b/test/CodeGen/atomic.c
index c201a1a..aa5aa15 100644
--- a/test/CodeGen/atomic.c
+++ b/test/CodeGen/atomic.c
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin9 > %t1
-// RUN: grep @llvm.memory.barrier %t1 | count 42
+// RUN: grep @llvm.memory.barrier %t1 | count 38
// RUN: grep @llvm.atomic.load.add.i32 %t1 | count 3
// RUN: grep @llvm.atomic.load.sub.i8 %t1 | count 2
// RUN: grep @llvm.atomic.load.min.i32 %t1
@@ -8,7 +8,7 @@
// RUN: grep @llvm.atomic.load.umax.i32 %t1
// RUN: grep @llvm.atomic.swap.i32 %t1
// RUN: grep @llvm.atomic.cmp.swap.i32 %t1 | count 4
-// RUN: grep @llvm.atomic.load.and.i32 %t1 | count 2
+// RUN: grep @llvm.atomic.load.and.i32 %t1
// RUN: grep @llvm.atomic.load.or.i8 %t1
// RUN: grep @llvm.atomic.load.xor.i8 %t1
@@ -34,14 +34,12 @@ int atomic(void)
old = __sync_fetch_and_and(&val, 0x9);
old = __sync_fetch_and_or(&val, 0xa);
old = __sync_fetch_and_xor(&val, 0xb);
- old = __sync_fetch_and_nand(&val, 0xb);
old = __sync_add_and_fetch(&val, 1);
old = __sync_sub_and_fetch(&val, 2);
old = __sync_and_and_fetch(&valc, 3);
old = __sync_or_and_fetch(&valc, 4);
old = __sync_xor_and_fetch(&valc, 5);
- old = __sync_nand_and_fetch(&valc, 5);
__sync_val_compare_and_swap((void **)0, (void *)0, (void *)0);
diff --git a/test/CodeGen/mangle.c b/test/CodeGen/mangle.c
index a087b42..93d424a 100644
--- a/test/CodeGen/mangle.c
+++ b/test/CodeGen/mangle.c
@@ -59,3 +59,7 @@ extern int func (void) __asm__ ("FUNC");
int func(void) {
return 42;
}
+
+// CHECK: @_Z4foo9Dv4_f
+typedef __attribute__(( vector_size(16) )) float float4;
+void __attribute__((__overloadable__)) foo9(float4 f) {}
diff --git a/test/CodeGen/palignr.c b/test/CodeGen/palignr.c
index 68efb41..627e309 100644
--- a/test/CodeGen/palignr.c
+++ b/test/CodeGen/palignr.c
@@ -15,5 +15,5 @@ int4 align1(int4 a, int4 b) { return _mm_alignr_epi8(a, b, 15); }
int4 align2(int4 a, int4 b) { return _mm_alignr_epi8(a, b, 16); }
// CHECK: psrldq
int4 align3(int4 a, int4 b) { return _mm_alignr_epi8(a, b, 17); }
-// CHECK: xorps
+// CHECK: xor
int4 align4(int4 a, int4 b) { return _mm_alignr_epi8(a, b, 32); }
diff --git a/test/CodeGen/regparm.c b/test/CodeGen/regparm.c
index ac37975..b60f8c7 100644
--- a/test/CodeGen/regparm.c
+++ b/test/CodeGen/regparm.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | grep inreg | count 2
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
#define FASTCALL __attribute__((regparm(2)))
@@ -8,11 +8,16 @@ typedef struct {
int ccc[200];
} foo;
+typedef void (*FType)(int, int) __attribute ((regparm (3), stdcall));
+FType bar;
+
static void FASTCALL
-reduced(char b, double c, foo* d, double e, int f) {
-}
+reduced(char b, double c, foo* d, double e, int f);
int
main(void) {
+ // CHECK: call void @reduced(i8 signext inreg 0, {{.*}} %struct.anon* inreg null
reduced(0, 0.0, 0, 0.0, 0);
+ // CHECK: call x86_stdcallcc void {{.*}}(i32 inreg 1, i32 inreg 2)
+ bar(1,2);
}
diff --git a/test/CodeGen/restrict.c b/test/CodeGen/restrict.c
new file mode 100644
index 0000000..8bbff24
--- /dev/null
+++ b/test/CodeGen/restrict.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-darwin-apple -emit-llvm %s -o - | FileCheck %s
+
+// PR6695
+
+// CHECK: define void @test0(i32* %{{.*}}, i32 %{{.*}})
+void test0(int *x, int y) {
+}
+
+// CHECK: define void @test1(i32* noalias %{{.*}}, i32 %{{.*}})
+void test1(int * restrict x, int y) {
+}
+
+// CHECK: define void @test2(i32* %{{.*}}, i32* noalias %{{.*}})
+void test2(int *x, int * restrict y) {
+}
+
+typedef int * restrict rp;
+
+// CHECK: define void @test3(i32* noalias %{{.*}}, i32 %{{.*}})
+void test3(rp x, int y) {
+}
+
+// CHECK: define void @test4(i32* %{{.*}}, i32* noalias %{{.*}})
+void test4(int *x, rp y) {
+}
+
diff --git a/test/CodeGenCXX/constructor-init.cpp b/test/CodeGenCXX/constructor-init.cpp
index a0a35fa..284b8b5 100644
--- a/test/CodeGenCXX/constructor-init.cpp
+++ b/test/CodeGenCXX/constructor-init.cpp
@@ -80,3 +80,24 @@ void f() {
// CHECK-NOT: call void @_ZN1AIsED1Ev
// CHECK: ret void
}
+
+template<typename T>
+struct X {
+ X(const X &);
+
+ T *start;
+ T *end;
+};
+
+template<typename T> struct X;
+
+// Make sure that the instantiated constructor initializes start and
+// end properly.
+// CHECK: define linkonce_odr void @_ZN1XIiEC2ERKS0_
+// CHECK: {{store.*null}}
+// CHECK: {{store.*null}}
+// CHECK: ret
+template<typename T>
+X<T>::X(const X &other) : start(0), end(0) { }
+
+X<int> get_X(X<int> x) { return x; }
diff --git a/test/CodeGenCXX/copy-constructor-synthesis.cpp b/test/CodeGenCXX/copy-constructor-synthesis.cpp
index ae8eefa..9cafd0a 100644
--- a/test/CodeGenCXX/copy-constructor-synthesis.cpp
+++ b/test/CodeGenCXX/copy-constructor-synthesis.cpp
@@ -1,7 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -S %s -o %t-64.s
-// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
-// RUN: %clang_cc1 -triple i386-apple-darwin -S %s -o %t-32.s
-// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s
extern "C" int printf(...);
@@ -24,6 +21,7 @@ struct P {
};
+// CHECK: define linkonce_odr void @_ZN1XC1ERKS_
struct X : M, N, P { // ...
X() : f1(1.0), d1(2.0), i1(3), name("HELLO"), bf1(0xff), bf2(0xabcd),
au_i1(1234), au1_4("MASKED") {}
@@ -113,10 +111,46 @@ void f(const B &b1) {
B b2(b1);
}
-// CHECK-LP64: .globl __ZN1XC1ERKS_
-// CHECK-LP64: .weak_definition __ZN1XC1ERKS_
-// CHECK-LP64: __ZN1XC1ERKS_:
+// PR6628
+namespace PR6628 {
+
+struct T {
+ T();
+ ~T();
+
+ double d;
+};
+
+struct A {
+ A(const A &other, const T &t = T(), const T& t2 = T());
+};
+
+struct B : A {
+ A a1;
+ A a2;
+ A a[10];
+};
+
+// Force the copy constructor to be synthesized.
+void f(B b1) {
+ B b2 = b1;
+}
+
+// CHECK: define linkonce_odr void @_ZN6PR66281BC2ERKS0_
+// CHECK: call void @_ZN6PR66281TC1Ev
+// CHECK: call void @_ZN6PR66281TC1Ev
+// CHECK: call void @_ZN6PR66281AC2ERKS0_RKNS_1TES5_
+// CHECK: call void @_ZN6PR66281TD1Ev
+// CHECK: call void @_ZN6PR66281TD1Ev
+// CHECK: call void @_ZN6PR66281TC1Ev
+// CHECK: call void @_ZN6PR66281TC1Ev
+// CHECK: call void @_ZN6PR66281AC1ERKS0_RKNS_1TES5_
+// CHECK: call void @_ZN6PR66281TD1Ev
+// CHECK: call void @_ZN6PR66281TD1Ev
+// CHECK: call void @_ZN6PR66281TC1Ev
+// CHECK: call void @_ZN6PR66281TC1Ev
+// CHECK: call void @_ZN6PR66281AC1ERKS0_RKNS_1TES5_
+// CHECK: call void @_ZN6PR66281TD1Ev
+// CHECK: call void @_ZN6PR66281TD1Ev
+}
-// CHECK-LP32: .globl __ZN1XC1ERKS_
-// CHECK-LP32: .weak_definition __ZN1XC1ERKS_
-// CHECK-LP32: __ZN1XC1ERKS_:
diff --git a/test/CodeGenCXX/member-expressions.cpp b/test/CodeGenCXX/member-expressions.cpp
index 720a9a7..d9fb394 100644
--- a/test/CodeGenCXX/member-expressions.cpp
+++ b/test/CodeGenCXX/member-expressions.cpp
@@ -44,3 +44,43 @@ int f() {
return A().foo();
}
}
+
+namespace test4 {
+ struct A {
+ int x;
+ };
+ struct B {
+ int x;
+ void foo();
+ };
+ struct C : A, B {
+ };
+
+ extern C *c_ptr;
+
+ // CHECK: define i32 @_ZN5test44testEv()
+ int test() {
+ // CHECK: load {{.*}} @_ZN5test45c_ptrE
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: call void @_ZN5test41B3fooEv
+ c_ptr->B::foo();
+
+ // CHECK: load {{.*}} @_ZN5test45c_ptrE
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: store i32 5
+ c_ptr->B::x = 5;
+
+ // CHECK: load {{.*}} @_ZN5test45c_ptrE
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: load i32*
+ return c_ptr->B::x;
+ }
+}
diff --git a/test/CodeGenCXX/multi-dim-operator-new.cpp b/test/CodeGenCXX/multi-dim-operator-new.cpp
new file mode 100644
index 0000000..7a235e8
--- /dev/null
+++ b/test/CodeGenCXX/multi-dim-operator-new.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s
+// PR6641
+
+extern "C" int printf(const char *, ...);
+
+struct Foo {
+ Foo() : iFoo (2) {
+ printf("%p\n", this);
+ }
+ int iFoo;
+};
+
+
+typedef Foo (*T)[3][4];
+
+T bar() {
+ return new Foo[2][3][4];
+}
+
+T bug(int i) {
+ return new Foo[i][3][4];
+}
+
+void pr(T a) {
+ for (int i = 0; i < 3; i++)
+ for (int j = 0; j < 4; j++)
+ printf("%p\n", a[i][j]);
+}
+
+Foo *test() {
+ return new Foo[5];
+}
+
+int main() {
+ T f = bar();
+ pr(f);
+ f = bug(3);
+ pr(f);
+
+ Foo * g = test();
+ for (int i = 0; i < 5; i++)
+ printf("%d\n", g[i].iFoo);
+ return 0;
+}
+
+// CHECK: call noalias i8* @_Znam
+// CHECK: call noalias i8* @_Znam
+// CHECK: call noalias i8* @_Znam
+
diff --git a/test/CodeGenCXX/references.cpp b/test/CodeGenCXX/references.cpp
index 39b5909..5a5947d 100644
--- a/test/CodeGenCXX/references.cpp
+++ b/test/CodeGenCXX/references.cpp
@@ -147,3 +147,11 @@ void f(int &a) {
struct s0;
struct s1 { struct s0 &s0; };
void f0(s1 a) { s1 b = a; }
+
+// PR6024
+// CHECK: @_Z2f2v()
+// CHECK: alloca
+// CHECK: store
+// CHECK: load
+// CHECK: ret
+const int &f2() { return 0; }
diff --git a/test/CodeGenCXX/rtti-fundamental.cpp b/test/CodeGenCXX/rtti-fundamental.cpp
new file mode 100644
index 0000000..473f48d
--- /dev/null
+++ b/test/CodeGenCXX/rtti-fundamental.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+#include <typeinfo>
+
+std::type_info foo() {
+ return typeid(void);
+}
+
+namespace __cxxabiv1 {
+ struct __fundamental_type_info {
+ virtual ~__fundamental_type_info() {}
+ };
+}
+
+// CHECK: @_ZTIv = weak_odr constant
+// CHECK: @_ZTIPv = weak_odr constant
+// CHECK: @_ZTIPKv = weak_odr constant
+// CHECK: @_ZTIDi = weak_odr constant
+// CHECK: @_ZTIPDi = weak_odr constant
+// CHECK: @_ZTIPKDi = weak_odr constant
+// CHECK: @_ZTIDs = weak_odr constant
+// CHECK: @_ZTIPDs = weak_odr constant
+// CHECK: @_ZTIPKDs = weak_odr constant
+// CHECK: @_ZTIy = weak_odr constant
+// CHECK: @_ZTIPy = weak_odr constant
+// CHECK: @_ZTIPKy = weak_odr constant
+// CHECK: @_ZTIx = weak_odr constant
+// CHECK: @_ZTIPx = weak_odr constant
+// CHECK: @_ZTIPKx = weak_odr constant
+// CHECK: @_ZTIw = weak_odr constant
+// CHECK: @_ZTIPw = weak_odr constant
+// CHECK: @_ZTIPKw = weak_odr constant
+// CHECK: @_ZTIt = weak_odr constant
+// CHECK: @_ZTIPt = weak_odr constant
+// CHECK: @_ZTIPKt = weak_odr constant
+// CHECK: @_ZTIs = weak_odr constant
+// CHECK: @_ZTIPs = weak_odr constant
+// CHECK: @_ZTIPKs = weak_odr constant
+// CHECK: @_ZTIm = weak_odr constant
+// CHECK: @_ZTIPm = weak_odr constant
+// CHECK: @_ZTIPKm = weak_odr constant
+// CHECK: @_ZTIl = weak_odr constant
+// CHECK: @_ZTIPl = weak_odr constant
+// CHECK: @_ZTIPKl = weak_odr constant
+// CHECK: @_ZTIj = weak_odr constant
+// CHECK: @_ZTIPj = weak_odr constant
+// CHECK: @_ZTIPKj = weak_odr constant
+// CHECK: @_ZTIi = weak_odr constant
+// CHECK: @_ZTIPi = weak_odr constant
+// CHECK: @_ZTIPKi = weak_odr constant
+// CHECK: @_ZTIh = weak_odr constant
+// CHECK: @_ZTIPh = weak_odr constant
+// CHECK: @_ZTIPKh = weak_odr constant
+// CHECK: @_ZTIf = weak_odr constant
+// CHECK: @_ZTIPf = weak_odr constant
+// CHECK: @_ZTIPKf = weak_odr constant
+// CHECK: @_ZTIe = weak_odr constant
+// CHECK: @_ZTIPe = weak_odr constant
+// CHECK: @_ZTIPKe = weak_odr constant
+// CHECK: @_ZTId = weak_odr constant
+// CHECK: @_ZTIPd = weak_odr constant
+// CHECK: @_ZTIPKd = weak_odr constant
+// CHECK: @_ZTIc = weak_odr constant
+// CHECK: @_ZTIPc = weak_odr constant
+// CHECK: @_ZTIPKc = weak_odr constant
+// CHECK: @_ZTIb = weak_odr constant
+// CHECK: @_ZTIPb = weak_odr constant
+// CHECK: @_ZTIPKb = weak_odr constant
+// CHECK: @_ZTIa = weak_odr constant
+// CHECK: @_ZTIPa = weak_odr constant
+// CHECK: @_ZTIPKa = weak_odr constant
diff --git a/test/CodeGenCXX/rtti-linkage.cpp b/test/CodeGenCXX/rtti-linkage.cpp
index 799c1d4..b9eb5b4 100644
--- a/test/CodeGenCXX/rtti-linkage.cpp
+++ b/test/CodeGenCXX/rtti-linkage.cpp
@@ -92,6 +92,7 @@ const std::type_info &t2() {
(void)typeid(D *);
(void)typeid(D (*)());
(void)typeid(void (*)(D));
+ (void)typeid(void (*)(D&));
// The exception specification is not part of the RTTI descriptor, so it should not have
// internal linkage.
(void)typeid(void (*)() throw (D));
diff --git a/test/CodeGenCXX/template-instantiation.cpp b/test/CodeGenCXX/template-instantiation.cpp
new file mode 100644
index 0000000..416c0a1
--- /dev/null
+++ b/test/CodeGenCXX/template-instantiation.cpp
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
+// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
+// CHECK: @_ZTVN5test018stdio_sync_filebufIwEE = constant
+
+// CHECK: define linkonce_odr void @_ZN5test21CIiEC1Ev(
+// CHECK: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_(
+// CHECK: define available_externally void @_ZN5test21CIiE6zedbarEd(
+
+namespace test0 {
+ struct basic_streambuf {
+ virtual ~basic_streambuf();
+ };
+ template<typename _CharT >
+ struct stdio_sync_filebuf : public basic_streambuf {
+ virtual void xsgetn();
+ };
+
+ // This specialization should cause the vtable to be emitted, even with
+ // the following extern template declaration.
+ template<> void stdio_sync_filebuf<wchar_t>::xsgetn() {
+ }
+ extern template class stdio_sync_filebuf<wchar_t>;
+}
+
+namespace test1 {
+ struct basic_streambuf {
+ virtual ~basic_streambuf();
+ };
+ template<typename _CharT >
+ struct stdio_sync_filebuf : public basic_streambuf {
+ virtual void xsgetn();
+ };
+
+ // Just a declaration should not force the vtable to be emitted.
+ template<> void stdio_sync_filebuf<wchar_t>::xsgetn();
+}
+
+namespace test2 {
+ template<typename T1>
+ class C {
+ virtual ~C();
+ void zedbar(double) {
+ }
+ template<typename T2>
+ void foobar(T2 foo) {
+ }
+ };
+ extern template class C<int>;
+ void g() {
+ // The extern template declaration should not prevent us from producing
+ // the implicit constructor (test at the top).
+ C<int> a;
+
+ // or foobar(test at the top).
+ a.foobar(0.0);
+
+ // But it should prevent zebbar
+ // (test at the top).
+ a.zedbar(0.0);
+ }
+}
+
+namespace test3 {
+ template<typename T>
+ class basic_fstreamXX {
+ virtual void foo(){}
+ virtual void is_open() const { }
+ };
+
+ extern template class basic_fstreamXX<char>;
+ // This template instantiation should not cause us to produce a vtable.
+ // (test at the top).
+ template void basic_fstreamXX<char>::is_open() const;
+}
diff --git a/test/CodeGenCXX/temporaries.cpp b/test/CodeGenCXX/temporaries.cpp
index cd0cf77..4aad3c0 100644
--- a/test/CodeGenCXX/temporaries.cpp
+++ b/test/CodeGenCXX/temporaries.cpp
@@ -288,3 +288,16 @@ void g() {
}
}
+
+namespace PR6648 {
+ struct B {
+ ~B();
+ };
+ B foo;
+ struct D;
+ D& zed(B);
+ void foobar() {
+ // CHECK: call %"struct.PR6648::D"* @_ZN6PR66483zedENS_1BE
+ zed(foo);
+ }
+}
diff --git a/test/CodeGenCXX/thunks.cpp b/test/CodeGenCXX/thunks.cpp
new file mode 100644
index 0000000..b91ba32
--- /dev/null
+++ b/test/CodeGenCXX/thunks.cpp
@@ -0,0 +1,137 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+namespace Test1 {
+
+// Check that we emit a non-virtual thunk for C::f.
+
+struct A {
+ virtual void f();
+};
+
+struct B {
+ virtual void f();
+};
+
+struct C : A, B {
+ virtual void c();
+
+ virtual void f();
+};
+
+// CHECK: define void @_ZThn8_N5Test11C1fEv(
+void C::f() { }
+
+}
+
+namespace Test2 {
+
+// Check that we emit a thunk for B::f since it's overriding a virtual base.
+
+struct A {
+ virtual void f();
+};
+
+struct B : virtual A {
+ virtual void b();
+ virtual void f();
+};
+
+// CHECK: define void @_ZTv0_n24_N5Test21B1fEv(
+void B::f() { }
+
+}
+
+namespace Test3 {
+
+// Check that we emit a covariant thunk for B::f.
+
+struct V1 { };
+struct V2 : virtual V1 { };
+
+struct A {
+ virtual V1 *f();
+};
+
+struct B : A {
+ virtual void b();
+
+ virtual V2 *f();
+};
+
+// CHECK: define %{{.*}}* @_ZTch0_v0_n24_N5Test31B1fEv(
+V2 *B::f() { return 0; }
+
+}
+
+namespace Test4 {
+
+// Check that the thunk for 'C::f' has the same visibility as the function itself.
+
+struct A {
+ virtual void f();
+};
+
+struct B {
+ virtual void f();
+};
+
+struct __attribute__((visibility("protected"))) C : A, B {
+ virtual void c();
+
+ virtual void f();
+};
+
+// CHECK: define protected void @_ZThn8_N5Test41C1fEv(
+void C::f() { }
+
+}
+
+// This is from Test5:
+// CHECK: define linkonce_odr void @_ZTv0_n24_N5Test51B1fEv
+
+// Check that the thunk gets internal linkage.
+namespace {
+
+struct A {
+ virtual void f();
+};
+
+struct B {
+ virtual void f();
+};
+
+struct C : A, B {
+ virtual void c();
+
+ virtual void f();
+};
+
+// CHECK: define internal void @_ZThn8_N12_GLOBAL__N_11C1fEv(
+void C::f() { }
+
+}
+
+// Force C::f to be used.
+void f() {
+ C c;
+
+ c.f();
+}
+
+namespace Test5 {
+
+// Check that the thunk for 'B::f' gets the same linkage as the function itself.
+struct A {
+ virtual void f();
+};
+
+struct B : virtual A {
+ virtual void f() { }
+};
+
+void f(B b) {
+ b.f();
+}
+}
+
+
diff --git a/test/CodeGenCXX/virt.cpp b/test/CodeGenCXX/virt.cpp
index 9d671c4..c404129 100644
--- a/test/CodeGenCXX/virt.cpp
+++ b/test/CodeGenCXX/virt.cpp
@@ -693,55 +693,3 @@ void test12_foo() {
// CHECK-LPLL64: call void %
// CHECK-LPLL64: call void @_ZN8test12_A3fooEv(%class.test14* %{{.*}})
-
-// FIXME: This is the wrong thunk, but until these issues are fixed, better
-// than nothing.
-// CHECK-LPLL64define weak %class.test8_D* @_ZTcvn16_n72_v16_n32_N8test16_D4foo1Ev(%class.test8_D*)
-// CHECK-LPLL64 %{{retval|2}} = alloca %class.test8_D*
-// CHECK-LPLL64 %.addr = alloca %class.test8_D*
-// CHECK-LPLL64 store %class.test8_D* %0, %class.test8_D** %.addr
-// CHECK-LPLL64 %{{this|3}} = load %class.test8_D** %.addr
-// CHECK-LPLL64 %{{1|4}} = bitcast %class.test8_D* %{{this|3}} to i8*
-// CHECK-LPLL64 %{{2|5}} = getelementptr inbounds i8* %{{1|4}}, i64 -16
-// CHECK-LPLL64 %{{3|6}} = bitcast i8* %{{2|5}} to %class.test8_D*
-// CHECK-LPLL64 %{{4|7}} = bitcast %class.test8_D* %{{3|6}} to i8*
-// CHECK-LPLL64 %{{5|8}} = bitcast %class.test8_D* %3 to i64**
-// CHECK-LPLL64 %{{vtable|9}} = load i64** %{{5|8}}
-// CHECK-LPLL64 %{{6|10}} = getelementptr inbounds i64* %{{vtable|9}}, i64 -9
-// CHECK-LPLL64 %{{7|11}} = load i64* %{{6|10}}
-// CHECK-LPLL64 %{{8|12}} = getelementptr i8* %{{4|7}}, i64 %{{7|11}}
-// CHECK-LPLL64 %{{9|13}} = bitcast i8* %{{8|12}} to %class.test8_D*
-// CHECK-LPLL64 %{{call|14}} = call %class.test8_D* @_ZTch0_v16_n32_N8test16_D4foo1Ev(%class.test8_D* %{{9|13}})
-// CHECK-LPLL64 store %class.test8_D* %{{call|14}}, %class.test8_D** %{{retval|2}}
-// CHECK-LPLL64 %{{10|15}} = load %class.test8_D** %{{retval|2}}
-// CHECK-LPLL64 ret %class.test8_D* %{{10|15}}
-// CHECK-LPLL64}
-
-// CHECK-LPLL64:define weak %class.test8_D* @_ZTch0_v16_n32_N8test16_D4foo1Ev(%{{class.test8_D|.*}}*)
-// CHECK-LPLL64: %{{retval|1}} = alloca %class.test8_D*
-// CHECK-LPLL64: %{{.addr|2}} = alloca %class.test8_D*
-// CHECK-LPLL64: store %class.test8_D* %0, %class.test8_D** %{{.addr|2}}
-// CHECK-LPLL64: %{{this|3}} = load %class.test8_D** %{{.addr|2}}
-// CHECK-LPLL64: %{{call|4}} = call %class.test8_D* @_ZN8test16_D4foo1Ev(%class.test8_D* %{{this|3}})
-// CHECK-LPLL64: %{{1|5}} = icmp ne %class.test8_D* %{{call|4}}, null
-// CHECK-LPLL64: br i1 %{{1|5}}, label %{{2|6}}, label %{{12|17}}
-// CHECK-LPLL64:; <label>:{{2|6}}
-// CHECK-LPLL64: %{{3|7}} = bitcast %class.test8_D* %{{call|4}} to i8*
-// CHECK-LPLL64: %{{4|8}} = getelementptr inbounds i8* %{{3|7}}, i64 16
-// CHECK-LPLL64: %{{5|9}} = bitcast i8* %4 to %class.test8_D*
-// CHECK-LPLL64: %{{6|10}} = bitcast %class.test8_D* %{{5|9}} to i8*
-// CHECK-LPLL64: %{{7|11}} = bitcast %class.test8_D* %{{5|9}} to i64**
-// CHECK-LPLL64: %{{vtable|12}} = load i64** %{{7|11}}
-// CHECK-LPLL64: %{{8|13}} = getelementptr inbounds i64* %vtable, i64 -4
-// CHECK-LPLL64: %{{9|14}} = load i64* %{{8|13}}
-// CHECK-LPLL64: %{{10|15}} = getelementptr i8* %{{6|10}}, i64 %{{9|14}}
-// CHECK-LPLL64: %{{11|16}} = bitcast i8* %{{10|15}} to %class.test8_D*
-// CHECK-LPLL64: br label %{{13|18}}
-// CHECK-LPLL64:; <label>:{{12|17}}
-// CHECK-LPLL64: br label %{{13|18}}
-// CHECK-LPLL64:; <label>:{{13|18}}
-// CHECK-LPLL64: %{{14|19}} = phi %class.test8_D* [ %{{11|16}}, %{{2|6}} ], [ %{{call|4}}, %{{12|17}} ]
-// CHECK-LPLL64: store %class.test8_D* %{{14|19}}, %class.test8_D** %{{retval|2}}
-// CHECK-LPLL64: %{{15|20}} = load %class.test8_D** %{{retval|2}}
-// CHECK-LPLL64: ret %class.test8_D* %{{15|20}}
-// CHECK-LPLL64:}
diff --git a/test/CodeGenCXX/virtual-bases.cpp b/test/CodeGenCXX/virtual-bases.cpp
index 6277175..61de315 100644
--- a/test/CodeGenCXX/virtual-bases.cpp
+++ b/test/CodeGenCXX/virtual-bases.cpp
@@ -23,3 +23,26 @@ struct C : virtual A {
// CHECK: define void @_ZN1CC1Eb(%struct.B* %this, i1 zeroext)
// CHECK: define void @_ZN1CC2Eb(%struct.B* %this, i8** %vtt, i1 zeroext)
C::C(bool) { }
+
+// PR6251
+namespace PR6251 {
+
+// Test that we don't call the A<char> constructor twice.
+
+template<typename T>
+struct A { A(); };
+
+struct B : virtual A<char> { };
+struct C : virtual A<char> { };
+
+struct D : B, C {
+ D();
+};
+
+// CHECK: define void @_ZN6PR62511DC1Ev
+// CHECK: call void @_ZN6PR62511AIcEC2Ev
+// CHECK-NOT: call void @_ZN6PR62511AIcEC2Ev
+// CHECK: ret void
+D::D() { }
+
+}
diff --git a/test/CodeGenCXX/vtable-layout-abi-examples.cpp b/test/CodeGenCXX/vtable-layout-abi-examples.cpp
index a82fca7..c01c5ef 100644
--- a/test/CodeGenCXX/vtable-layout-abi-examples.cpp
+++ b/test/CodeGenCXX/vtable-layout-abi-examples.cpp
@@ -178,7 +178,6 @@ struct C : virtual public A { int j; };
// CHECK-NEXT: 7 | vcall_offset (-16)
// CHECK-NEXT: 8 | offset_to_top (-16)
// CHECK-NEXT: 9 | Test2::D RTTI
-// CHECK-NEXT: -- (Test2::A, 16) vtable address --
// CHECK-NEXT: -- (Test2::C, 16) vtable address --
// CHECK-NEXT: 10 | [unused] void Test2::A::f()
struct D : public B, public C {
diff --git a/test/CodeGenCXX/vtable-layout.cpp b/test/CodeGenCXX/vtable-layout.cpp
index bc3d54b..3a0dae4 100644
--- a/test/CodeGenCXX/vtable-layout.cpp
+++ b/test/CodeGenCXX/vtable-layout.cpp
@@ -635,7 +635,6 @@ struct D : virtual B, virtual C { virtual void f(); };
// CHECK-NEXT: 9 | vcall_offset (-8)
// CHECK-NEXT: 10 | offset_to_top (-8)
// CHECK-NEXT: 11 | Test17::E RTTI
-// CHECK-NEXT: -- (Test17::A, 8) vtable address --
// CHECK-NEXT: -- (Test17::C, 8) vtable address --
// CHECK-NEXT: 12 | void Test17::E::f()
// CHECK-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
@@ -693,7 +692,6 @@ struct C : A, B {
// CHECK-NEXT: 19 | vcall_offset (-16)
// CHECK-NEXT: 20 | offset_to_top (-16)
// CHECK-NEXT: 21 | Test18::D RTTI
-// CHECK-NEXT: -- (Test18::A, 16) vtable address --
// CHECK-NEXT: -- (Test18::B, 16) vtable address --
// CHECK-NEXT: 22 | void Test18::D::f()
// CHECK-NEXT: [this adjustment: -8 non-virtual, -32 vcall offset offset]
@@ -725,7 +723,6 @@ struct C : A, B {
// CHECK-NEXT: 9 | vcall_offset (0)
// CHECK-NEXT: 10 | offset_to_top (-8)
// CHECK-NEXT: 11 | Test18::C RTTI
-// CHECK-NEXT: -- (Test18::A, 16) vtable address --
// CHECK-NEXT: -- (Test18::B, 16) vtable address --
// CHECK-NEXT: 12 | void Test18::B::f()
// CHECK-NEXT: 13 | [unused] void Test18::C::g()
@@ -745,7 +742,6 @@ struct C : A, B {
// CHECK-NEXT: 2 | vcall_offset (0)
// CHECK-NEXT: 3 | offset_to_top (0)
// CHECK-NEXT: 4 | Test18::B RTTI
-// CHECK-NEXT: -- (Test18::A, 16) vtable address --
// CHECK-NEXT: -- (Test18::B, 16) vtable address --
// CHECK-NEXT: 5 | void Test18::B::f()
// CHECK-NEXT: 6 | [unused] void Test18::A::g()
@@ -881,9 +877,6 @@ class E : virtual C { };
// CHECK-NEXT: 12 | vcall_offset (-8)
// CHECK-NEXT: 13 | offset_to_top (-8)
// CHECK-NEXT: 14 | Test21::F RTTI
-// CHECK-NEXT: -- (Test21::A, 8) vtable address --
-// CHECK-NEXT: -- (Test21::B, 8) vtable address --
-// CHECK-NEXT: -- (Test21::C, 8) vtable address --
// CHECK-NEXT: -- (Test21::E, 8) vtable address --
// CHECK-NEXT: 15 | [unused] void Test21::F::f()
//
@@ -1012,7 +1005,6 @@ struct C : virtual A { };
// CHECK-NEXT: 6 | vcall_offset (-8)
// CHECK-NEXT: 7 | offset_to_top (-8)
// CHECK-NEXT: 8 | Test24::D RTTI
-// CHECK-NEXT: -- (Test24::A, 8) vtable address --
// CHECK-NEXT: -- (Test24::C, 8) vtable address --
// CHECK-NEXT: 9 | [unused] void Test24::D::f()
@@ -1030,14 +1022,13 @@ struct C : virtual A { };
// CHECK-NEXT: 1 | vcall_offset (-8)
// CHECK-NEXT: 2 | offset_to_top (0)
// CHECK-NEXT: 3 | Test24::C RTTI
-// CHECK-NEXT: -- (Test24::A, 8) vtable address --
// CHECK-NEXT: -- (Test24::C, 8) vtable address --
// CHECK-NEXT: 4 | [unused] void Test24::A::f()
// CHECK-NEXT: 5 | vcall_offset (0)
-// CHECK-NEXT: 6 | offset_to_top (8)
-// CHECK-NEXT: 7 | Test24::C RTTI
-// CHECK-NEXT: -- (Test24::A, 0) vtable address --
-// CHECK-NEXT: 8 | void Test24::A::f()
+// CHECK-NEXT: 6 | offset_to_top (8)
+// CHECK-NEXT: 7 | Test24::C RTTI
+// CHECK-NEXT: -- (Test24::A, 0) vtable address --
+// CHECK-NEXT: 8 | void Test24::A::f()
struct D : B, C {
virtual void f();
};
@@ -1071,7 +1062,6 @@ struct B : virtual V { };
// CHECK-NEXT: 8 | offset_to_top (-8)
// CHECK-NEXT: 9 | Test25::C RTTI
// CHECK-NEXT: -- (Test25::B, 8) vtable address --
-// CHECK-NEXT: -- (Test25::V, 8) vtable address --
// CHECK-NEXT: 10 | [unused] void Test25::V::f()
// CHECK: Construction vtable for ('Test25::A', 0) in 'Test25::C' (5 entries).
@@ -1089,7 +1079,6 @@ struct B : virtual V { };
// CHECK-NEXT: 2 | offset_to_top (0)
// CHECK-NEXT: 3 | Test25::B RTTI
// CHECK-NEXT: -- (Test25::B, 8) vtable address --
-// CHECK-NEXT: -- (Test25::V, 8) vtable address --
// CHECK-NEXT: 4 | [unused] void Test25::V::f()
// CHECK-NEXT: 5 | vcall_offset (0)
// CHECK-NEXT: 6 | offset_to_top (8)
@@ -1284,3 +1273,33 @@ struct E : D {
void E::e() { }
}
+
+namespace Test29 {
+
+// Test that the covariant return thunk for B::f will have a virtual 'this' adjustment,
+// matching gcc.
+
+struct V1 { };
+struct V2 : virtual V1 { };
+
+struct A {
+ virtual V1 *f();
+};
+
+// CHECK: Vtable for 'Test29::B' (6 entries).
+// CHECK-NEXT: 0 | vbase_offset (0)
+// CHECK-NEXT: 1 | vcall_offset (0)
+// CHECK-NEXT: 2 | offset_to_top (0)
+// CHECK-NEXT: 3 | Test29::B RTTI
+// CHECK-NEXT: -- (Test29::A, 0) vtable address --
+// CHECK-NEXT: -- (Test29::B, 0) vtable address --
+// CHECK-NEXT: 4 | Test29::V2 *Test29::B::f()
+// CHECK-NEXT: [return adjustment: 0 non-virtual, -24 vbase offset offset]
+// CHECK-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+// CHECK-NEXT: 5 | Test29::V2 *Test29::B::f()
+struct B : virtual A {
+ virtual V2 *f();
+};
+V2 *B::f() { return 0; }
+
+}
diff --git a/test/CodeGenCXX/vtable-linkage.cpp b/test/CodeGenCXX/vtable-linkage.cpp
index 63e17431..a4ea2a1 100644
--- a/test/CodeGenCXX/vtable-linkage.cpp
+++ b/test/CodeGenCXX/vtable-linkage.cpp
@@ -84,54 +84,54 @@ void use_F(F<char> &fc) {
// CHECK: @_ZTV1B = external constant
// C has no key function, so its vtable should have weak_odr linkage.
+// CHECK: @_ZTV1C = weak_odr constant
// CHECK: @_ZTS1C = weak_odr constant
// CHECK: @_ZTI1C = weak_odr constant
-// CHECK: @_ZTV1C = weak_odr constant
// D has a key function that is defined in this translation unit so its vtable is
// defined in the translation unit.
+// CHECK: @_ZTV1D = constant
// CHECK: @_ZTS1D = constant
// CHECK: @_ZTI1D = constant
-// CHECK: @_ZTV1D = constant
// E<char> is an explicit specialization with a key function defined
// in this translation unit, so its vtable should have external
// linkage.
+// CHECK: @_ZTV1EIcE = constant
// CHECK: @_ZTS1EIcE = constant
// CHECK: @_ZTI1EIcE = constant
-// CHECK: @_ZTV1EIcE = constant
// E<short> is an explicit template instantiation with a key function
// defined in this translation unit, so its vtable should have
// weak_odr linkage.
+// CHECK: @_ZTV1EIsE = weak_odr constant
// CHECK: @_ZTS1EIsE = weak_odr constant
// CHECK: @_ZTI1EIsE = weak_odr constant
-// CHECK: @_ZTV1EIsE = weak_odr constant
// F<short> is an explicit template instantiation without a key
// function, so its vtable should have weak_odr linkage
+// CHECK: @_ZTV1FIsE = weak_odr constant
// CHECK: @_ZTS1FIsE = weak_odr constant
// CHECK: @_ZTI1FIsE = weak_odr constant
-// CHECK: @_ZTV1FIsE = weak_odr constant
// E<long> is an implicit template instantiation with a key function
// defined in this translation unit, so its vtable should have
// weak_odr linkage.
+// CHECK: @_ZTV1EIlE = weak_odr constant
// CHECK: @_ZTS1EIlE = weak_odr constant
// CHECK: @_ZTI1EIlE = weak_odr constant
-// CHECK: @_ZTV1EIlE = weak_odr constant
// F<long> is an implicit template instantiation with no key function,
// so its vtable should have weak_odr linkage.
+// CHECK: @_ZTV1FIlE = weak_odr constant
// CHECK: @_ZTS1FIlE = weak_odr constant
// CHECK: @_ZTI1FIlE = weak_odr constant
-// CHECK: @_ZTV1FIlE = weak_odr constant
// F<int> is an explicit template instantiation declaration without a
// key function, so its vtable should have weak_odr linkage.
+// CHECK: @_ZTV1FIiE = weak_odr constant
// CHECK: @_ZTS1FIiE = weak_odr constant
// CHECK: @_ZTI1FIiE = weak_odr constant
-// CHECK: @_ZTV1FIiE = weak_odr constant
// E<int> is an explicit template instantiation declaration. It has a
// key function that is not instantiated, so we should only reference
@@ -140,14 +140,14 @@ void use_F(F<char> &fc) {
// The anonymous struct for e has no linkage, so the vtable should have
// internal linkage.
+// CHECK: @"_ZTV3$_0" = internal constant
// CHECK: @"_ZTS3$_0" = internal constant
// CHECK: @"_ZTI3$_0" = internal constant
-// CHECK: @"_ZTV3$_0" = internal constant
// The A vtable should have internal linkage since it is inside an anonymous
// namespace.
+// CHECK: @_ZTVN12_GLOBAL__N_11AE = internal constant
// CHECK: @_ZTSN12_GLOBAL__N_11AE = internal constant
// CHECK: @_ZTIN12_GLOBAL__N_11AE = internal constant
-// CHECK: @_ZTVN12_GLOBAL__N_11AE = internal constant
diff --git a/test/CodeGenObjC/complex-property.m b/test/CodeGenObjC/complex-property.m
new file mode 100644
index 0000000..5a2b78b
--- /dev/null
+++ b/test/CodeGenObjC/complex-property.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s
+// rdar: // 7351147
+
+@interface A
+@property __complex int COMPLEX_PROP;
+- (__complex int)y;
+- (void) setY : (__complex int)rhs;
+@end
+
+void f0(A *a) {
+ _Complex int a1 = 25 + 10i;
+ a.COMPLEX_PROP += a1;
+ a.y += a1;
+}
+
+// CHECK-LP64: internal global [13 x i8] c"COMPLEX_PROP
+// CHECK-LP64: internal global [17 x i8] c"setCOMPLEX_PROP
+
+// rdar: // 7351147
+@interface B
+@property (assign) _Complex float f_complex_ivar;
+@end
+
+@implementation B
+
+@synthesize f_complex_ivar = _f_complex_ivar;
+-(void) unary_f_complex: (_Complex float) a0 {
+ self.f_complex_ivar = a0;
+}
+
+@end
+
diff --git a/test/CodeGenObjC/objc2-nonfragile-abi-impl.m b/test/CodeGenObjC/objc2-nonfragile-abi-impl.m
new file mode 100644
index 0000000..ff94330
--- /dev/null
+++ b/test/CodeGenObjC/objc2-nonfragile-abi-impl.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi2 -emit-llvm -o %t %s
+// rdar://7547942.
+
+@interface Base @end
+
+@interface Sub1 : Base @end
+
+@implementation Sub1 @end
+
+@implementation Base {
+@private
+ id ivar;
+}
+@end
+
diff --git a/test/Driver/nostdincxx.cpp b/test/Driver/nostdincxx.cpp
new file mode 100644
index 0000000..7e00555
--- /dev/null
+++ b/test/Driver/nostdincxx.cpp
@@ -0,0 +1,4 @@
+// RUN: %clangxx -nostdinc++ %s 2>&1 | FileCheck %s
+// XFAIL: win32
+// CHECK: file not found
+#include <vector>
diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp
index ee93755..79c294b 100644
--- a/test/FixIt/fixit.cpp
+++ b/test/FixIt/fixit.cpp
@@ -37,3 +37,6 @@ protected:
class B : public A {
A::foo; // expected-warning{{access declarations are deprecated}}
};
+
+void f() throw();
+void f(); // expected-warning{{missing exception specification}}
diff --git a/test/Headers/c89.c b/test/Headers/c89.c
new file mode 100644
index 0000000..9e01ff9
--- /dev/null
+++ b/test/Headers/c89.c
@@ -0,0 +1,10 @@
+// RUN: %clang -ccc-host-triple i386-apple-darwin10 -fsyntax-only -Xclang -verify -std=c89 %s
+
+// FIXME: Disable inclusion of mm_malloc.h, our current implementation is broken
+// on win32 since we don't generally know how to find errno.h.
+
+#define __MM_MALLOC_H
+
+// PR6658
+#include <xmmintrin.h>
+
diff --git a/test/Sema/x86-intrinsics-headers.c b/test/Headers/x86-intrinsics-headers.c
index 24c2d92..24c2d92 100644
--- a/test/Sema/x86-intrinsics-headers.c
+++ b/test/Headers/x86-intrinsics-headers.c
diff --git a/test/Index/Inputs/remap-complete-to.c b/test/Index/Inputs/remap-complete-to.c
index 9f8be2c..30199db 100644
--- a/test/Index/Inputs/remap-complete-to.c
+++ b/test/Index/Inputs/remap-complete-to.c
@@ -1 +1,6 @@
-void f0() { }
+int f0(int *pointer1, float *pointer2) {
+ return pointer2 - pointer1;
+}
+
+void g() {
+
diff --git a/test/Index/cindex-on-invalid.m b/test/Index/cindex-on-invalid.m
index 7e190eb..d2d952d 100644
--- a/test/Index/cindex-on-invalid.m
+++ b/test/Index/cindex-on-invalid.m
@@ -1,7 +1,6 @@
-// RUN: not c-index-test -test-load-source local %s > %t 2> %t.err
-// RUN: FileCheck %s < %t.err
-// CHECK: error: expected identifier or '('
-// CHECK: Unable to load translation unit!
+// RUN: c-index-test -test-load-source local %s 2>&1 | FileCheck %s
int foo;
int
+
+// CHECK: cindex-on-invalid.m:6:70: error: expected identifier or '(' \ No newline at end of file
diff --git a/test/Index/print-usrs.c b/test/Index/print-usrs.c
new file mode 100644
index 0000000..9cd64f7
--- /dev/null
+++ b/test/Index/print-usrs.c
@@ -0,0 +1,17 @@
+// RUN: c-index-test -print-usr-file %s | FileCheck %s
+// This isn't really C code; it has a .c extension to get picked up by lit.
+ObjCClass NSObject
+ObjCCategory NSObject foo
+ObjCIvar x c:objc(cs)NSObject
+ObjCMethod foo: 0 c:objc(cs)NSObject
+ObjCMethod baz:with 1 c:objc(cs)NSObject
+ObjCProperty gimme c:objc(cs)NSObject
+ObjCProtocol blah
+// CHECK: c:objc(cs)NSObject
+// CHECK: c:objc(cy)NSObject^foo
+// CHECK: c:objc(cs)NSObject@^x
+// CHECK: c:objc(cs)NSObject(cm)foo:
+// CHECK: c:objc(cs)NSObject(im)baz:with
+// CHECK: c:objc(cs)NSObject(py)gimme
+// CHECK: c:objc(pl)blah
+
diff --git a/test/Index/recover-bad-code-rdar_7487294.c b/test/Index/recover-bad-code-rdar_7487294.c
index 97bb515..e060672 100644
--- a/test/Index/recover-bad-code-rdar_7487294.c
+++ b/test/Index/recover-bad-code-rdar_7487294.c
@@ -11,4 +11,3 @@ int foo(int x) {
// CHECK: 9:3: error: use of undeclared identifier 'help'
// CHECK: help
-// CHECK: 14:102: error: expected '}'
diff --git a/test/Index/remap-complete.c b/test/Index/remap-complete.c
index 9b7de06..813d1df 100644
--- a/test/Index/remap-complete.c
+++ b/test/Index/remap-complete.c
@@ -1,5 +1,8 @@
-// RUN: c-index-test -code-completion-at=%s:1:12 -remap-file="%s;%S/Inputs/remap-complete-to.c" %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:6:2 -remap-file="%s;%S/Inputs/remap-complete-to.c" %s 2> %t.err | FileCheck %s
+// RUN: FileCheck -check-prefix=CHECK-DIAGS %s < %t.err
// XFAIL: win32
-// CHECK: FunctionDecl:{ResultType void}{TypedText f0}{LeftParen (}{RightParen )}
+// CHECK: FunctionDecl:{ResultType int}{TypedText f0}{LeftParen (}
void f() { }
+
+// CHECK-DIAGS: remap-complete.c:2:19
diff --git a/test/PCH/changed-files.c b/test/PCH/changed-files.c
index dd08bdd..d1b603b 100644
--- a/test/PCH/changed-files.c
+++ b/test/PCH/changed-files.c
@@ -5,22 +5,24 @@ const char *s2 = m0;
// FIXME: This test fails inexplicably on Windows in a manner that makes it
// look like standard error isn't getting flushed properly.
-// RUN: true
-// RUNx: echo '#define m0 ""' > %t.h
-// RUNx: %clang_cc1 -emit-pch -o %t.h.pch %t.h
-// RUNx: echo '' > %t.h
-// RUNx: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr
-// RUNx: grep "modified" %t.stderr
+// RUN: false
+// XFAIL: *
-// RUNx: echo '#define m0 000' > %t.h
-// RUNx: %clang_cc1 -emit-pch -o %t.h.pch %t.h
-// RUNx: echo '' > %t.h
-// RUNx: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr
-// RUNx: grep "modified" %t.stderr
+// RUN: echo '#define m0 ""' > %t.h
+// RUN: %clang_cc1 -emit-pch -o %t.h.pch %t.h
+// RUN: echo '' > %t.h
+// RUN: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr
+// RUN: grep "modified" %t.stderr
-// RUNx: echo '#define m0 000' > %t.h
-// RUNx: echo "#define m1 'abcd'" >> %t.h
-// RUNx: %clang_cc1 -emit-pch -o %t.h.pch %t.h
-// RUNx: echo '' > %t.h
-// RUNx: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr
-// RUNx: grep "modified" %t.stderr
+// RUN: echo '#define m0 000' > %t.h
+// RUN: %clang_cc1 -emit-pch -o %t.h.pch %t.h
+// RUN: echo '' > %t.h
+// RUN: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr
+// RUN: grep "modified" %t.stderr
+
+// RUN: echo '#define m0 000' > %t.h
+// RUN: echo "#define m1 'abcd'" >> %t.h
+// RUN: %clang_cc1 -emit-pch -o %t.h.pch %t.h
+// RUN: echo '' > %t.h
+// RUN: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr
+// RUN: grep "modified" %t.stderr
diff --git a/test/Parser/cxx-default-args.cpp b/test/Parser/cxx-default-args.cpp
new file mode 100644
index 0000000..a084fb0
--- /dev/null
+++ b/test/Parser/cxx-default-args.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR6647
+class C {
+ // After the error, the rest of the tokens inside the default arg should be
+ // skipped, avoiding a "expected ';' after class" after 'undecl'.
+ void m(int x = undecl + 0); // expected-error {{use of undeclared identifier 'undecl'}}
+};
+
diff --git a/test/Parser/objc-messaging-neg-1.m b/test/Parser/objc-messaging-neg-1.m
index 0d0cb9d..4ddadb8 100644
--- a/test/Parser/objc-messaging-neg-1.m
+++ b/test/Parser/objc-messaging-neg-1.m
@@ -1,6 +1,12 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+@interface A
++(void) foo:(int) a;
+@end
+
int main() {
id a;
[a bla:0 6:7]; // expected-error {{expected ']'}}
+ [A foo bar]; // expected-error {{expected ':'}}
+ [A foo bar bar1]; // expected-error {{expected ':'}}
}
diff --git a/test/Parser/statements.c b/test/Parser/statements.c
index a662c9b..bc7192a 100644
--- a/test/Parser/statements.c
+++ b/test/Parser/statements.c
@@ -57,3 +57,8 @@ void test6(void) {
int test7() {
return 4 // expected-error {{expected ';' after return statement}}
}
+
+void test8() {
+ // Should not skip '}' and produce a "expected '}'" error.
+ undecl // expected-error {{use of undeclared identifier 'undecl'}}
+}
diff --git a/test/Preprocessor/dependencies-and-pp.c b/test/Preprocessor/dependencies-and-pp.c
index d7bf4df..7877df3 100644
--- a/test/Preprocessor/dependencies-and-pp.c
+++ b/test/Preprocessor/dependencies-and-pp.c
@@ -1,5 +1,31 @@
+// Test -MT and -E flags, PR4063
+
// RUN: %clang -E -o %t.1 %s
// RUN: %clang -E -MD -MF %t.d -MT foo -o %t.2 %s
// RUN: diff %t.1 %t.2
// RUN: grep "foo:" %t.d
// RUN: grep "dependencies-and-pp.c" %t.d
+
+// Test -MQ flag without quoting
+
+// RUN: %clang -E -MD -MF %t.d -MQ foo -o %t %s
+// RUN: grep "foo:" %t.d
+
+// Test -MQ flag with quoting
+
+// RUN: %clang -E -MD -MF %t.d -MQ '$fo\ooo ooo\ ooo\\ ooo#oo' -o %t %s
+// RUN: fgrep '$$fo\ooo\ ooo\\\ ooo\\\\\ ooo\#oo:' %t.d
+
+// Test consecutive -MT flags
+
+// RUN: %clang -E -MD -MF %t.d -MT foo -MT bar -MT baz -o %t %s
+// RUN: diff %t.1 %t
+// RUN: fgrep "foo bar baz:" %t.d
+
+// Test consecutive -MT and -MQ flags
+
+// RUN: %clang -E -MD -MF %t.d -MT foo -MQ '$(bar)' -MT 'b az' -MQ 'qu ux' -MQ ' space' -o %t %s
+// RUN: fgrep 'foo $$(bar) b az qu\ ux \ space:' %t.d
+
+// TODO: Test default target without quoting
+// TODO: Test default target with quoting
diff --git a/test/Preprocessor/macro_disable.c b/test/Preprocessor/macro_disable.c
index d6509c3..d7859dc 100644
--- a/test/Preprocessor/macro_disable.c
+++ b/test/Preprocessor/macro_disable.c
@@ -1,5 +1,27 @@
-// RUN: %clang_cc1 -E %s | grep 'a: 2 + M_0(3)(4)(5);'
-// RUN: %clang_cc1 -E %s | grep 'b: 4 + 4 + 3 + 2 + 1 + M_0(3)(2)(1);'
+// RUN: %clang_cc1 %s -E | FileCheck -strict-whitespace %s
+// Check for C99 6.10.3.4p2.
+
+#define f(a) f(x * (a))
+#define x 2
+#define z z[0]
+f(f(z));
+// CHECK: f(2 * (f(2 * (z[0]))));
+
+
+
+#define A A B C
+#define B B C A
+#define C C A B
+A
+// CHECK: A B C A B A C A B C A
+
+
+// PR1820
+#define i(x) h(x
+#define h(x) x(void)
+extern int i(i));
+// CHECK: int i(void)
+
#define M_0(x) M_ ## x
#define M_1(x) x + M_0(0)
@@ -11,3 +33,11 @@
a: M_0(1)(2)(3)(4)(5);
b: M_0(5)(4)(3)(2)(1);
+// CHECK: a: 2 + M_0(3)(4)(5);
+// CHECK: b: 4 + 4 + 3 + 2 + 1 + M_0(3)(2)(1);
+
+#define n(v) v
+#define l m
+#define m l a
+c: n(m) X
+// CHECK: c: m a X
diff --git a/test/Preprocessor/macro_disable2.c b/test/Preprocessor/macro_disable2.c
deleted file mode 100644
index 229cf32..0000000
--- a/test/Preprocessor/macro_disable2.c
+++ /dev/null
@@ -1,8 +0,0 @@
-// RUN: %clang_cc1 -E %s | grep 'A B C A B A C A B C A'
-
-#define A A B C
-#define B B C A
-#define C C A B
-
-A
-
diff --git a/test/Preprocessor/macro_disable3.c b/test/Preprocessor/macro_disable3.c
deleted file mode 100644
index eab0a5e..0000000
--- a/test/Preprocessor/macro_disable3.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 %s -E | FileCheck -strict-whitespace %s
-// Check for C99 6.10.3.4p2.
-
-#define f(a) f(x * (a))
-#define x 2
-#define z z[0]
-f(f(z));
-
-// CHECK: f(2 * (f(2 * (z[0]))));
-
diff --git a/test/Preprocessor/macro_disable4.c b/test/Preprocessor/macro_disable4.c
deleted file mode 100644
index 820858c..0000000
--- a/test/Preprocessor/macro_disable4.c
+++ /dev/null
@@ -1,6 +0,0 @@
-// RUN: %clang_cc1 -P -E %s | grep 'int f(void)'
-// PR1820
-
-#define f(x) h(x
-#define h(x) x(void)
-extern int f(f));
diff --git a/test/Preprocessor/output_paste_avoid.c b/test/Preprocessor/output_paste_avoid.c
index 835a921..8c6173a 100644
--- a/test/Preprocessor/output_paste_avoid.c
+++ b/test/Preprocessor/output_paste_avoid.c
@@ -24,3 +24,7 @@ E: test(str)
// Should expand to L "str" not L"str"
// CHECK: E: L "str"
+// Should avoid producing >>=.
+#define equal =
+F: >>equal
+// CHECK: F: >> =
diff --git a/test/Sema/format-attribute.c b/test/Sema/attr-format.c
index 6e1bd0f..0fadf98 100644
--- a/test/Sema/format-attribute.c
+++ b/test/Sema/attr-format.c
@@ -32,3 +32,49 @@ int rdar6623513(void *, const char*, const char*, ...)
int rdar6623513_aux(int len, const char* s) {
rdar6623513(0, "hello", "%.*s", len, s);
}
+
+
+
+// same as format(printf(...))...
+void a2(const char *a, ...) __attribute__((format(printf0, 1,2))); // no-error
+void b2(const char *a, ...) __attribute__((format(printf0, 1,1))); // expected-error {{'format' attribute parameter 3 is out of bounds}}
+void c2(const char *a, ...) __attribute__((format(printf0, 0,2))); // expected-error {{'format' attribute parameter 2 is out of bounds}}
+void d2(const char *a, int c) __attribute__((format(printf0, 1,2))); // expected-error {{format attribute requires variadic function}}
+void e2(char *str, int c, ...) __attribute__((format(printf0, 2,3))); // expected-error {{format argument not a string type}}
+
+// FreeBSD usage
+#define __printf0like(fmt,va) __attribute__((__format__(__printf0__,fmt,va)))
+void null(int i, const char *a, ...) __printf0like(2,0); // no-error
+void null(int i, const char *a, ...) {
+ if (a)
+ (void)0/* vprintf(...) would go here */;
+}
+
+void callnull(void){
+ null(0, 0); // no error
+ null(0, (char*)0); // no error
+ null(0, (void*)0); // no error
+ null(0, (int*)0); // expected-warning {{incompatible pointer types}}
+}
+
+
+
+// PR4470
+int xx_vprintf(const char *, va_list);
+
+const char *foo(const char *format) __attribute__((format_arg(1)));
+
+void __attribute__((format(printf, 1, 0)))
+foo2(const char *fmt, va_list va) {
+ xx_vprintf(foo(fmt), va);
+}
+
+// PR6542
+extern void gcc_format (const char *, ...)
+ __attribute__ ((__format__(__gcc_diag__, 1, 2)));
+extern void gcc_cformat (const char *, ...)
+ __attribute__ ((__format__(__gcc_cdiag__, 1, 2)));
+extern void gcc_cxxformat (const char *, ...)
+ __attribute__ ((__format__(__gcc_cxxdiag__, 1, 2)));
+extern void gcc_tformat (const char *, ...)
+ __attribute__ ((__format__(__gcc_tdiag__, 1, 2)));
diff --git a/test/Sema/function-sentinel-attr.c b/test/Sema/attr-sentinel.c
index 9bcbec4..db90d07 100644
--- a/test/Sema/function-sentinel-attr.c
+++ b/test/Sema/attr-sentinel.c
@@ -11,9 +11,7 @@ void foo7 (int x, ...) __attribute__ ((__sentinel__(0))); // expected-note {{fun
void foo10 (int x, ...) __attribute__ ((__sentinel__(1,1)));
void foo12 (int x, ... ) ATTR; // expected-note {{function has been explicitly marked sentinel here}}
-int main ()
-{
-
+void test1() {
foo1(1, NULL); // OK
foo1(1, 0) ; // expected-warning {{missing sentinel in function call}}
foo5(1, NULL, 2); // OK
@@ -28,3 +26,23 @@ int main ()
foo12(1); // expected-warning {{not enough variable arguments in 'foo12' declaration to fit a sentinel}}
}
+
+
+void (*e) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (1,1)));
+
+void test2() {
+ void (*b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)); // expected-note {{function has been explicitly marked sentinel here}}
+ void (*z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))); // expected-note {{function has been explicitly marked sentinel here}}
+
+
+ void (*y) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (5))); // expected-note {{function has been explicitly marked sentinel here}}
+
+ b(1, "%s", (void*)0); // OK
+ b(1, "%s", 0); // expected-warning {{missing sentinel in function call}}
+ z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in function call}}
+ z(1, "%s", (void*)0, 1, 0); // OK
+
+ y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in function call}}
+
+ y(1, "%s", (void*)0,3,4,5,6,7); // OK
+}
diff --git a/test/Sema/attr-unused.c b/test/Sema/attr-unused.c
index e45ec43..2871514 100644
--- a/test/Sema/attr-unused.c
+++ b/test/Sema/attr-unused.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -Wunused-variable -fsyntax-only %s
static void (*fp0)(void) __attribute__((unused));
@@ -10,3 +10,18 @@ int f1() __attribute__((unused));
int g0 __attribute__((unused));
int f2() __attribute__((unused(1, 2))); // expected-error {{attribute requires 0 argument(s)}}
+
+struct Test0_unused {} __attribute__((unused));
+struct Test0_not_unused {};
+typedef int Int_unused __attribute__((unused));
+typedef int Int_not_unused;
+
+void test0() {
+ int x; // expected-warning {{unused variable}}
+
+ Int_not_unused i0; // expected-warning {{unused variable}}
+ Int_unused i1;
+
+ struct Test0_not_unused s0; // expected-warning {{unused variable}}
+ struct Test0_unused s1;
+}
diff --git a/test/Sema/format-attr-pr4470.c b/test/Sema/format-attr-pr4470.c
deleted file mode 100644
index 374d8b3..0000000
--- a/test/Sema/format-attr-pr4470.c
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wformat=2 %s
-
-#include <stdarg.h>
-int vprintf(const char *, va_list);
-
-const char *foo(const char *format) __attribute__((format_arg(1)));
-
-void __attribute__((format(printf, 1, 0)))
-foo2(const char *fmt, va_list va)
-{
- vprintf(foo(fmt), va);
-}
diff --git a/test/Sema/format-attribute-printf0.c b/test/Sema/format-attribute-printf0.c
deleted file mode 100644
index 33e8d40..0000000
--- a/test/Sema/format-attribute-printf0.c
+++ /dev/null
@@ -1,26 +0,0 @@
-//RUN: %clang_cc1 -fsyntax-only -verify %s
-
-#include <stdarg.h>
-
-// same as format(printf(...))...
-void a2(const char *a, ...) __attribute__((format(printf0, 1,2))); // no-error
-void b2(const char *a, ...) __attribute__((format(printf0, 1,1))); // expected-error {{'format' attribute parameter 3 is out of bounds}}
-void c2(const char *a, ...) __attribute__((format(printf0, 0,2))); // expected-error {{'format' attribute parameter 2 is out of bounds}}
-void d2(const char *a, int c) __attribute__((format(printf0, 1,2))); // expected-error {{format attribute requires variadic function}}
-void e2(char *str, int c, ...) __attribute__((format(printf0, 2,3))); // expected-error {{format argument not a string type}}
-
-// FreeBSD usage
-#define __printf0like(fmt,va) __attribute__((__format__(__printf0__,fmt,va)))
-void null(int i, const char *a, ...) __printf0like(2,0); // no-error
-void null(int i, const char *a, ...) {
- if (a)
- (void)0/* vprintf(...) would go here */;
-}
-
-void callnull(void){
- null(0, 0); // no error
- null(0, (char*)0); // no error
- null(0, (void*)0); // no error
- null(0, (int*)0); // expected-warning {{incompatible pointer types}}
-}
-
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index 4db775f..dcc4c35 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -238,3 +238,16 @@ void test_positional_arguments() {
printf("%2$*8$d", (int) 2, (int) 3); // expected-warning{{specified field width is missing a matching 'int' argument}}
}
+// PR 6697 - Handle format strings where the data argument is not adjacent to the format string
+void myprintf_PR_6697(const char *format, int x, ...) __attribute__((__format__(printf,1, 3)));
+void test_pr_6697() {
+ myprintf_PR_6697("%s\n", 1, "foo"); // no-warning
+ myprintf_PR_6697("%s\n", 1, (int)0); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}}
+ // FIXME: Not everything should clearly support positional arguments,
+ // but we need a way to identify those cases.
+ myprintf_PR_6697("%1$s\n", 1, "foo"); // no-warning
+ myprintf_PR_6697("%2$s\n", 1, "foo"); // expected-warning{{data argument position '2' exceeds the number of data arguments (1)}}
+ myprintf_PR_6697("%18$s\n", 1, "foo"); // expected-warning{{data argument position '18' exceeds the number of data arguments (1)}}
+ myprintf_PR_6697("%1$s\n", 1, (int) 0); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}}
+}
+
diff --git a/test/Sema/function-pointer-sentinel-attribute.c b/test/Sema/function-pointer-sentinel-attribute.c
deleted file mode 100644
index 5f17a26..0000000
--- a/test/Sema/function-pointer-sentinel-attribute.c
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-void (*e) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (1,1)));
-
-int main() {
- void (*b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)); // expected-note {{function has been explicitly marked sentinel here}}
- void (*z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))); // expected-note {{function has been explicitly marked sentinel here}}
-
-
- void (*y) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (5))); // expected-note {{function has been explicitly marked sentinel here}}
-
- b(1, "%s", (void*)0); // OK
- b(1, "%s", 0); // expected-warning {{missing sentinel in function call}}
- z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in function call}}
- z(1, "%s", (void*)0, 1, 0); // OK
-
- y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in function call}}
-
- y(1, "%s", (void*)0,3,4,5,6,7); // OK
-}
diff --git a/test/Sema/init.c b/test/Sema/init.c
index c271248..b9867cf 100644
--- a/test/Sema/init.c
+++ b/test/Sema/init.c
@@ -75,7 +75,8 @@ int sym_fw1a_scr[] = {
};
// PR3001
-struct s1 s2 = {
+struct s1 s2 = { // expected-error {{variable has incomplete type 'struct s1'}} \
+ // expected-note {{forward declaration of 'struct s1'}}
.a = sizeof(struct s3), // expected-error {{invalid application of 'sizeof'}} \
// expected-note{{forward declaration of 'struct s3'}}
.b = bogus // expected-error {{use of undeclared identifier 'bogus'}}
diff --git a/test/Sema/nested-redef.c b/test/Sema/nested-redef.c
index 6a19921..bbc4859 100644
--- a/test/Sema/nested-redef.c
+++ b/test/Sema/nested-redef.c
@@ -1,7 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct X { // expected-note{{previous definition is here}}
- struct X { } x; // expected-error{{nested redefinition of 'X'}} \
- // expected-error{{field has incomplete type}}
+ struct X { } x; // expected-error{{nested redefinition of 'X'}}
};
struct Y { };
diff --git a/test/Sema/return.c b/test/Sema/return.c
index 3ab23f4..fab6a82 100644
--- a/test/Sema/return.c
+++ b/test/Sema/return.c
@@ -222,3 +222,20 @@ void test32() {
void test33() {
if (j) while (1) { }
}
+
+// Test that 'static inline' functions are only analyzed for CFG-based warnings
+// when they are used.
+static inline int si_has_missing_return() {} // no-warning
+static inline int si_has_missing_return_2() {}; // expected-warning{{control reaches end of non-void function}}
+static inline int si_forward();
+static inline int si_has_missing_return_3(int x) {
+ if (x)
+ return si_has_missing_return_3(x+1);
+} // expected-warning{{control may reach end of non-void function}}
+
+int test_static_inline(int x) {
+ si_forward();
+ return x ? si_has_missing_return_2() : si_has_missing_return_3(x);
+}
+static inline int si_forward() {} // expected-warning{{control reaches end of non-void function}}
+
diff --git a/test/Sema/struct-packed-align.c b/test/Sema/struct-packed-align.c
index 60a9feb..2b94567 100644
--- a/test/Sema/struct-packed-align.c
+++ b/test/Sema/struct-packed-align.c
@@ -37,6 +37,14 @@ struct __attribute__((packed)) packed_fas {
extern int d1[sizeof(struct packed_fas) == 1 ? 1 : -1];
extern int d2[__alignof(struct packed_fas) == 1 ? 1 : -1];
+struct packed_after_fas {
+ char a;
+ int b[];
+} __attribute__((packed));
+
+extern int d1_2[sizeof(struct packed_after_fas) == 1 ? 1 : -1];
+extern int d2_2[__alignof(struct packed_after_fas) == 1 ? 1 : -1];
+
// Alignment
struct __attribute__((aligned(8))) as1 {
diff --git a/test/Sema/warn-gnu-designators.c b/test/Sema/warn-gnu-designators.c
new file mode 100644
index 0000000..d5ac8cf
--- /dev/null
+++ b/test/Sema/warn-gnu-designators.c
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -Wno-gnu-designator -verify %s
+struct { int x, y, z[12] } value = { x:17, .z [3 ... 5] = 7 };
diff --git a/test/Sema/warn-shadow.c b/test/Sema/warn-shadow.c
index c9a783b..a112210 100644
--- a/test/Sema/warn-shadow.c
+++ b/test/Sema/warn-shadow.c
@@ -43,3 +43,8 @@ void test3(void) {
void test4(int i) { // expected-warning {{declaration shadows a variable in the global scope}}
}
+
+// Don't warn about shadowing for function declarations.
+void test5(int i);
+void test6(void (*f)(int i)) {}
+void test7(void *context, void (*callback)(void *context)) {}
diff --git a/test/SemaCXX/PR6618.cpp b/test/SemaCXX/PR6618.cpp
new file mode 100644
index 0000000..10d4dc8
--- /dev/null
+++ b/test/SemaCXX/PR6618.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class bar; // expected-note {{forward declaration of 'bar'}}
+struct zed {
+ bar g; // expected-error {{field has incomplete type}}
+};
+class baz {
+ zed h;
+};
+void f() {
+ enum {
+ e = sizeof(baz)
+ };
+}
diff --git a/test/SemaCXX/class-base-member-init.cpp b/test/SemaCXX/class-base-member-init.cpp
index 1c6e790..7095d92 100644
--- a/test/SemaCXX/class-base-member-init.cpp
+++ b/test/SemaCXX/class-base-member-init.cpp
@@ -6,14 +6,48 @@ public:
};
struct D : S {
- D() : b1(0), b2(1), b1(0), S(), S() {} // expected-error {{multiple initializations given for non-static member 'b1'}} \
- // expected-note {{previous initialization is here}} \
- // expected-error {{multiple initializations given for base 'S'}} \
- // expected-note {{previous initialization is here}}
-
+ D() :
+ b1(0), // expected-note {{previous initialization is here}}
+ b2(1),
+ b1(0), // expected-error {{multiple initializations given for non-static member 'b1'}}
+ S(), // expected-note {{previous initialization is here}}
+ S() // expected-error {{multiple initializations given for base 'S'}}
+ {}
int b1;
int b2;
+};
+struct A {
+ struct {
+ int a;
+ int b;
+ };
+ A();
};
+A::A() : a(10), b(20) { }
+
+namespace Test1 {
+ template<typename T> struct A {};
+ template<typename T> struct B : A<T> {
+
+ B() : A<T>(), // expected-note {{previous initialization is here}}
+ A<T>() { } // expected-error {{multiple initializations given for base 'A<T>'}}
+ };
+}
+
+namespace Test2 {
+ template<typename T> struct A : T {
+ A() : T(), // expected-note {{previous initialization is here}}
+ T() { } // expected-error {{multiple initializations given for base 'T'}}
+ };
+}
+namespace Test3 {
+ template<typename T> struct A {
+ T t;
+
+ A() : t(1), // expected-note {{previous initialization is here}}
+ t(2) { } // expected-error {{multiple initializations given for non-static member 't'}}
+ };
+}
diff --git a/test/SemaCXX/class-layout.cpp b/test/SemaCXX/class-layout.cpp
index 2b8d1d3..f3c75f4 100644
--- a/test/SemaCXX/class-layout.cpp
+++ b/test/SemaCXX/class-layout.cpp
@@ -48,6 +48,13 @@ struct H : G { };
SA(6, sizeof(H) == 1);
+struct I {
+ char b;
+ int a;
+} __attribute__((packed));
+
+SA(6_1, sizeof(I) == 5);
+
// PR5580
namespace PR5580 {
diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp
index accc8db..e2a966bd 100644
--- a/test/SemaCXX/conditional-expr.cpp
+++ b/test/SemaCXX/conditional-expr.cpp
@@ -7,7 +7,8 @@
struct ToBool { explicit operator bool(); };
struct B;
-struct A { A(); A(const B&); }; // expected-note 2 {{candidate constructor}}
+struct A { A(); A(const B&); }; // expected-note 2 {{candidate constructor}} \
+ // expected-note 2 {{candidate is the implicit copy constructor}}
struct B { operator A() const; }; // expected-note 2 {{candidate function}}
struct I { operator int(); };
struct J { operator I(); };
@@ -197,3 +198,18 @@ void test()
// *must* create a separate temporary copy of class objects. This can only
// be properly tested at runtime, though.
}
+
+namespace PR6595 {
+ struct String {
+ String(const char *);
+ operator const char*() const;
+ };
+
+ void f(bool Cond, String S) {
+ (void)(Cond? S : "");
+ (void)(Cond? "" : S);
+ const char a[1] = {'a'};
+ (void)(Cond? S : a);
+ (void)(Cond? a : S);
+ }
+}
diff --git a/test/SemaCXX/destructor.cpp b/test/SemaCXX/destructor.cpp
index 7010d2e..ae3dc86 100644
--- a/test/SemaCXX/destructor.cpp
+++ b/test/SemaCXX/destructor.cpp
@@ -78,3 +78,8 @@ namespace PR6421 {
}
};
}
+
+namespace PR6709 {
+ template<class T> class X { T v; ~X() { ++*v; } };
+ void a(X<int> x) {}
+}
diff --git a/test/SemaCXX/exception-spec.cpp b/test/SemaCXX/exception-spec.cpp
index 782cf83..498611e 100644
--- a/test/SemaCXX/exception-spec.cpp
+++ b/test/SemaCXX/exception-spec.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fms-extensions %s
// Straight from the standard:
// Plain function with spec
@@ -50,7 +50,7 @@ void r4() throw(int, float);
void r4() throw(float, int);
void r5() throw(int); // expected-note {{previous declaration}}
-void r5(); // expected-error {{exception specification in declaration does not match}}
+void r5(); // expected-warning {{missing exception specification}}
void r6() throw(...); // expected-note {{previous declaration}}
void r6() throw(int); // expected-error {{exception specification in declaration does not match}}
@@ -170,7 +170,7 @@ void fnptrs()
// Member function stuff
struct Str1 { void f() throw(int); }; // expected-note {{previous declaration}}
-void Str1::f() // expected-error {{does not match previous declaration}}
+void Str1::f() // expected-warning {{missing exception specification}}
{
}
diff --git a/test/SemaCXX/invalid-member-expr.cpp b/test/SemaCXX/invalid-member-expr.cpp
index 7b17afb..7307a47 100644
--- a/test/SemaCXX/invalid-member-expr.cpp
+++ b/test/SemaCXX/invalid-member-expr.cpp
@@ -19,3 +19,21 @@ void test2() {
x->operator; // expected-error{{missing type specifier after 'operator'}}
x->operator typedef; // expected-error{{missing type specifier after 'operator'}}
}
+
+// PR6327
+namespace test3 {
+ template <class A, class B> struct pair {};
+
+ void test0() {
+ pair<int, int> z = minmax({}); // expected-error {{expected expression}}
+ }
+
+ struct string {
+ class iterator {};
+ };
+
+ void test1() {
+ string s;
+ string::iterator i = s.foo(); // expected-error {{no member named 'foo'}}
+ }
+}
diff --git a/test/SemaCXX/namespace-alias.cpp b/test/SemaCXX/namespace-alias.cpp
index 06114c3..3ea1ccf 100644
--- a/test/SemaCXX/namespace-alias.cpp
+++ b/test/SemaCXX/namespace-alias.cpp
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-namespace N { };
+namespace N { struct X { }; };
namespace A = N;
@@ -83,3 +83,11 @@ namespace K {
KC::func(); // expected-error {{undeclared identifier 'KC'}}
}
}
+
+// PR6341
+namespace A = N;
+namespace N { }
+namespace A = N;
+
+A::X nx;
+
diff --git a/test/SemaCXX/namespace.cpp b/test/SemaCXX/namespace.cpp
index 2a9d31f..d47b707 100644
--- a/test/SemaCXX/namespace.cpp
+++ b/test/SemaCXX/namespace.cpp
@@ -68,3 +68,25 @@ namespace foo {
static foo::x test1; // ok
static foo::X test2; // typo: expected-error {{no type named 'X' in}}
+
+namespace PR6620 {
+ namespace numeric {
+ namespace op {
+ struct greater {};
+ }
+ namespace {
+ extern op::greater const greater;
+ }
+ }
+
+ namespace numeric {
+ namespace {
+ op::greater const greater = op::greater();
+ }
+
+ template<typename T, typename U>
+ int f(T& l, U& r)
+ { numeric::greater(l, r); }
+
+ }
+}
diff --git a/test/SemaCXX/nested-name-spec.cpp b/test/SemaCXX/nested-name-spec.cpp
index 8657c0d..9a611c3 100644
--- a/test/SemaCXX/nested-name-spec.cpp
+++ b/test/SemaCXX/nested-name-spec.cpp
@@ -64,7 +64,7 @@ void f2() {
A::C c1;
struct A::C c2;
struct S : public A::C {};
-struct A::undef; // expected-error {{'undef' does not name a tag member in the specified scope}}
+struct A::undef; // expected-error {{no struct named 'undef' in namespace 'A'}}
namespace A2 {
typedef int INT;
diff --git a/test/SemaCXX/new-delete-predefined-decl-2.cpp b/test/SemaCXX/new-delete-predefined-decl-2.cpp
new file mode 100644
index 0000000..981476d
--- /dev/null
+++ b/test/SemaCXX/new-delete-predefined-decl-2.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DQUALIFIED -fsyntax-only -verify %s
+
+// PR5904
+void f0(int *ptr) {
+#ifndef QUALIFIED
+ operator delete(ptr);
+#endif
+}
+
+void f1(int *ptr) {
+ ::operator delete[](ptr);
+}
diff --git a/test/SemaCXX/qual-id-test.cpp b/test/SemaCXX/qual-id-test.cpp
index 54d41b8..4846e72 100644
--- a/test/SemaCXX/qual-id-test.cpp
+++ b/test/SemaCXX/qual-id-test.cpp
@@ -138,3 +138,12 @@ struct a {
a a;
int a::sa = a.a; // expected-error {{invalid use of nonstatic data member 'a'}}
+
+
+namespace PR6645 {
+ typedef int foo;
+ namespace Inner {
+ typedef int PR6645::foo; // expected-error{{typedef declarator cannot be qualified}} \
+ // expected-error{{definition or redeclaration of 'foo' not in a namespace enclosing 'PR6645'}}
+ }
+}
diff --git a/test/SemaCXX/static-cast.cpp b/test/SemaCXX/static-cast.cpp
index 2630278..a5dd7e2 100644
--- a/test/SemaCXX/static-cast.cpp
+++ b/test/SemaCXX/static-cast.cpp
@@ -60,7 +60,7 @@ void t_529_2()
(void)static_cast<A*>((H*)0); // expected-error {{ambiguous conversion}}
(void)static_cast<int>((int*)0); // expected-error {{static_cast from 'int *' to 'int' is not allowed}}
(void)static_cast<A**>((B**)0); // expected-error {{static_cast from 'B **' to 'A **' is not allowed}}
- (void)static_cast<char&>(i); // expected-error {{non-const lvalue reference to type 'char' cannot be initialized with a value of type 'int'}}
+ (void)static_cast<char&>(i); // expected-error {{non-const lvalue reference to type 'char' cannot bind to a value of unrelated type 'int'}}
}
// Anything to void
@@ -91,7 +91,7 @@ void t_529_5_8()
(void)static_cast<H*>((A*)0); // expected-error {{ambiguous cast from base 'A' to derived 'H':\n struct A -> struct B -> struct G1 -> struct H\n struct A -> struct B -> struct G2 -> struct H}}
(void)static_cast<H&>(*((A*)0)); // expected-error {{ambiguous cast from base 'A' to derived 'H':\n struct A -> struct B -> struct G1 -> struct H\n struct A -> struct B -> struct G2 -> struct H}}
(void)static_cast<E*>((B*)0); // expected-error {{static_cast from 'B *' to 'E *' is not allowed}}
- (void)static_cast<E&>(*((B*)0)); // expected-error {{non-const lvalue reference to type 'E' cannot be initialized with a value of type 'B'}}
+ (void)static_cast<E&>(*((B*)0)); // expected-error {{non-const lvalue reference to type 'E' cannot bind to a value of unrelated type 'B'}}
// TODO: Test inaccessible base in context where it's accessible, i.e.
// member function and friend.
diff --git a/test/SemaCXX/warn-reorder-ctor-initialization.cpp b/test/SemaCXX/warn-reorder-ctor-initialization.cpp
index 2634202..f419156 100644
--- a/test/SemaCXX/warn-reorder-ctor-initialization.cpp
+++ b/test/SemaCXX/warn-reorder-ctor-initialization.cpp
@@ -87,3 +87,15 @@ class Anon3 {
union {int a,b;};
Anon3() : b(1) {}
};
+
+namespace T1 {
+
+struct S1 { };
+struct S2: virtual S1 { };
+struct S3 { };
+
+struct S4: virtual S3, S2 {
+ S4() : S2(), // expected-warning {{base class 'T1::S2' will be initialized after}}
+ S3() { }; // expected-note {{base 'T1::S3'}}
+};
+}
diff --git a/test/SemaObjC/block-type-safety.m b/test/SemaObjC/block-type-safety.m
index dab0af4..b40f9b0 100644
--- a/test/SemaObjC/block-type-safety.m
+++ b/test/SemaObjC/block-type-safety.m
@@ -34,11 +34,11 @@ void test1() {
r0(^Super* () { return 0; }); // OK
r0(^Sub* () { return 0; }); // OK, variable of type Super* gets return value of type Sub*
- r0(^id () { return 0; }); // expected-error {{incompatible block pointer types passing 'id (^)(void)', expected 'Super *(^)()'}}
+ r0(^id () { return 0; });
r1(^Super* () { return 0; }); // expected-error {{incompatible block pointer types passing 'Super *(^)(void)', expected 'Sub *(^)()'}}
r1(^Sub* () { return 0; }); // OK
- r1(^id () { return 0; }); // expected-error {{incompatible block pointer types passing 'id (^)(void)', expected 'Sub *(^)()'}}
+ r1(^id () { return 0; });
r2(^id<NSObject>() { return 0; });
}
@@ -60,7 +60,7 @@ void f1(void (^f)(id x)) {
void test2(void)
{
f0(^(id a) { }); // OK
- f1(^(A* a) { }); // expected-error {{incompatible block pointer types passing 'void (^)(A *)', expected 'void (^)(id)'}}
+ f1(^(A* a) { });
f1(^(id<NSObject> a) { }); // OK
}
@@ -80,7 +80,7 @@ void test2(void)
// programmer wants to write this:
-printMyThings1 {
- [myThings enumerateObjectsWithBlock: ^(MyThing *obj) { // expected-error {{incompatible block pointer types sending 'void (^)(MyThing *)', expected 'void (^)(id)'}}
+ [myThings enumerateObjectsWithBlock: ^(MyThing *obj) {
[obj printThing];
}];
}
diff --git a/test/SemaObjC/category-1.m b/test/SemaObjC/category-1.m
index 24324f8..18cbb83 100644
--- a/test/SemaObjC/category-1.m
+++ b/test/SemaObjC/category-1.m
@@ -62,16 +62,16 @@
// <rdar://problem/7249233>
@protocol MultipleCat_P
--(void) im0;
+-(void) im0; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
@end
-@interface MultipleCat_I @end
+@interface MultipleCat_I @end // expected-note {{required for direct or indirect protocol 'MultipleCat_P'}}
@interface MultipleCat_I() @end
@interface MultipleCat_I() <MultipleCat_P> @end
-@implementation MultipleCat_I // expected-warning {{incomplete implementation}}, expected-warning {{method definition for 'im0' not found}}
+@implementation MultipleCat_I // expected-warning {{incomplete implementation}}
@end
// <rdar://problem/7680391> - Handle nameless categories with no name that refer
diff --git a/test/SemaObjC/compare-qualified-id.m b/test/SemaObjC/compare-qualified-id.m
index 497a1b6..08fb366 100644
--- a/test/SemaObjC/compare-qualified-id.m
+++ b/test/SemaObjC/compare-qualified-id.m
@@ -5,7 +5,7 @@ typedef unsigned int NSUInteger;
typedef struct _NSZone NSZone;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
@protocol NSObject - (BOOL)isEqual:(id)object; @end
-@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end // expected-warning {{method in protocol not implemented [-Wprotocol]}}
@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
@interface NSObject <NSObject> {} @end
@@ -15,7 +15,7 @@ typedef struct {} NSFastEnumerationState;
@interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey; @end
extern NSString * const NSTaskDidTerminateNotification;
-@interface XCPropertyExpansionContext : NSObject <NSCopying> {
+@interface XCPropertyExpansionContext : NSObject <NSCopying> { // expected-note {{required for direct or indirect protocol 'NSCopying'}}
NSMutableDictionary * _propNamesToPropValuesCache;
} @end
@@ -23,8 +23,7 @@ extern NSString * const NSTaskDidTerminateNotification;
- (NSString *)evaluateAsStringInContext:(XCPropertyExpansionContext *)context withNestingState:(const void *)state;
@end
-@implementation XCPropertyExpansionContext // expected-warning {{method definition for 'copyWithZone:' not found}} \
- // expected-warning {{incomplete implementation}}
+@implementation XCPropertyExpansionContext // expected-warning {{incomplete implementation}}
- (NSString *)expandedValueForProperty:(NSString *)property {
id <XCPropertyValues> cachedValueNode = [_propNamesToPropValuesCache objectForKey:property]; // expected-warning {{method '-objectForKey:' not found (return type defaults to 'id')}}
if (cachedValueNode == ((void *)0)) { }
diff --git a/test/SemaObjC/comptypes-7.m b/test/SemaObjC/comptypes-7.m
index fedad1b..2519c41 100644
--- a/test/SemaObjC/comptypes-7.m
+++ b/test/SemaObjC/comptypes-7.m
@@ -66,5 +66,10 @@ int main()
if (obj_C == j) foo() ; // expected-warning {{comparison of distinct pointer types ('Class' and 'int *')}}
if (j == obj_C) foo() ; // expected-warning {{comparison of distinct pointer types ('int *' and 'Class')}}
+ Class bar1 = Nil;
+ Class <MyProtocol> bar = Nil;
+ bar = bar1;
+ bar1 = bar;
+
return 0;
}
diff --git a/test/SemaObjC/conditional-expr.m b/test/SemaObjC/conditional-expr.m
index 914e3ca..1436f7e 100644
--- a/test/SemaObjC/conditional-expr.m
+++ b/test/SemaObjC/conditional-expr.m
@@ -21,10 +21,10 @@
@end
@interface DTFilterOutputStream2
-- nextOutputStream;
+- nextOutputStream; // expected-note {{{{method definition for 'nextOutputStream' not found}}
@end
-@implementation DTFilterOutputStream2 // expected-warning {{incomplete implementation}} expected-warning {{method definition for 'nextOutputStream' not found}}
+@implementation DTFilterOutputStream2 // expected-warning {{incomplete implementation}}
- (id)initWithNextOutputStream:(id <DTOutputStreams>) outputStream {
id <DTOutputStreams> nextOutputStream = [self nextOutputStream];
self = nextOutputStream; // expected-warning {{incompatible type assigning 'id<DTOutputStreams>', expected 'DTFilterOutputStream2 *'}}
diff --git a/test/SemaObjC/gcc-cast-ext.m b/test/SemaObjC/gcc-cast-ext.m
index 28abfbc..599e37d 100644
--- a/test/SemaObjC/gcc-cast-ext.m
+++ b/test/SemaObjC/gcc-cast-ext.m
@@ -5,8 +5,8 @@ typedef struct _NSRange { } NSRange;
@class PBXFileReference;
@interface PBXDocBookmark
-+ alloc;
-- autorelease;
++ alloc; // expected-note {{{{method definition for 'alloc' not found}}
+- autorelease; // expected-note {{{{method definition for 'autorelease' not found}}
@end
// GCC allows pointer expressions in integer constant expressions.
@@ -14,7 +14,7 @@ struct {
char control[((int)(char *)2)];
} xx;
-@implementation PBXDocBookmark // expected-warning {{incomplete implementation}} expected-warning {{method definition for 'autorelease' not found}} expected-warning {{method definition for 'alloc' not found}}
+@implementation PBXDocBookmark // expected-warning {{incomplete implementation}}
+ (id)bookmarkWithFileReference:(PBXFileReference *)fileRef gylphRange:(NSRange)range anchor:(NSString *)htmlAnchor
{
diff --git a/test/SemaObjC/ivar-in-class-extension-error.m b/test/SemaObjC/ivar-in-class-extension-error.m
new file mode 100644
index 0000000..ffc0e8b
--- /dev/null
+++ b/test/SemaObjC/ivar-in-class-extension-error.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar:// 6812436
+
+@interface A @end
+
+@interface A () { // expected-error {{ivars may not be placed in class extension}}
+ int _p0;
+}
+@property int p0;
+@end
+
+@interface A(CAT) { // expected-error {{ivars may not be placed in categories}}
+ int _p1;
+}
+@end
diff --git a/test/SemaObjC/ivar-in-implementations.m b/test/SemaObjC/ivar-in-implementations.m
index 32d3c35..4060526 100644
--- a/test/SemaObjC/ivar-in-implementations.m
+++ b/test/SemaObjC/ivar-in-implementations.m
@@ -11,12 +11,29 @@
@implementation INTFSTANDALONE : Super // expected-warning {{class implementation may not have super class}}
{
-@private
- id IVAR1;
+ id PRIV_IVAR;
@protected
- id IVAR2; // expected-error {{only private ivars may be declared in implementation}}
+ id PRTCTD;
@private
id IVAR3;
int IVAR; // expected-error {{instance variable is already declared}}
+@public
+ id IVAR4;
}
@end
+
+@interface Base @end
+
+@implementation Base {
+ int ivar1;
+@public
+ int ivar2;
+}
+@end
+
+id fn1(INTFSTANDALONE *b) { return b->PRIV_IVAR; } // expected-error {{instance variable 'PRIV_IVAR' is private}}
+
+id fn2(INTFSTANDALONE *b) { return b->PRTCTD; } // expected-error {{instance variable 'PRTCTD' is protected}}
+
+id fn4(INTFSTANDALONE *b) { return b->IVAR4; }
+
diff --git a/test/SemaObjC/ivar-sem-check-1.m b/test/SemaObjC/ivar-sem-check-1.m
index 099a7a6..de038f5 100644
--- a/test/SemaObjC/ivar-sem-check-1.m
+++ b/test/SemaObjC/ivar-sem-check-1.m
@@ -9,8 +9,7 @@ typedef int FOO();
int arr[]; // expected-error {{field has incomplete type}}
struct S IC; // expected-error {{field has incomplete type}}
struct T { // expected-note {{previous definition is here}}
- struct T {} X; // expected-error {{nested redefinition of 'T'}} \
- // expected-error {{field has incomplete type}}
+ struct T {} X; // expected-error {{nested redefinition of 'T'}}
}YYY;
FOO BADFUNC; // expected-error {{field 'BADFUNC' declared as a function}}
int kaka; // expected-note {{previous declaration is here}}
diff --git a/test/SemaObjC/method-arg-decay.m b/test/SemaObjC/method-arg-decay.m
index f600029..012a3ee 100644
--- a/test/SemaObjC/method-arg-decay.m
+++ b/test/SemaObjC/method-arg-decay.m
@@ -56,7 +56,7 @@ PBXFindMatchContains, PBXFindMatchStartsWith, PBXFindMatchWholeWords,
@interface PBXProjectModule : PBXModule <PBXFindableText> {
}
@end @class PBXBookmark;
-@protocol PBXSelectionTarget - (NSObject <PBXSelectionTarget> *) performAction:(id)action withSelection:(NSArray *)selection;
+@protocol PBXSelectionTarget - (NSObject <PBXSelectionTarget> *) performAction:(id)action withSelection:(NSArray *)selection; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
@end @class XCPropertyDictionary, XCPropertyCondition, XCPropertyConditionSet, XCMutablePropertyConditionSet;
extern NSMutableArray *XCFindPossibleKeyModules(PBXModule *module, BOOL useExposedModulesOnly);
@interface NSString (StringUtilities) - (NSString *) trimToLength:(NSInteger)length preserveRange:(NSRange)range;
@@ -67,14 +67,12 @@ extern NSMutableArray *XCFindPossibleKeyModules(PBXModule *module, BOOL useExpos
@interface XCExtendedTabView : NSTabView <XCDockViewHeader> {
}
@end @class PBXProjectDocument, PBXFileReference, PBXModule, XCWindowTool;
-@interface XCPerspectiveModule : PBXProjectModule <PBXSelectionTarget> {
+@interface XCPerspectiveModule : PBXProjectModule <PBXSelectionTarget> { // expected-note {{required for direct or indirect protocol 'PBXSelectionTarget'}}
XCExtendedTabView *_perspectivesTabView;
}
-- (PBXModule *) moduleForTab:(NSTabViewItem *)item;
+- (PBXModule *) moduleForTab:(NSTabViewItem *)item; // expected-note {{method definition for 'moduleForTab:' not found}}
@end
-@implementation XCPerspectiveModule // expected-warning {{method definition for 'moduleForTab:' not found}} \
- // expected-warning {{method definition for 'performAction:withSelection:' not found}} \
- // expected-warning {{incomplete implementation}}
+@implementation XCPerspectiveModule // expected-warning {{incomplete implementation}}
+ (void) openForProjectDocument:(PBXProjectDocument *)projectDocument {
}
- (PBXModule *) type:(Class)type inPerspective:(id)perspectiveIdentifer matchingFunction:(BOOL (void *, void *))comparator usingData:(void *)data {
diff --git a/test/SemaObjC/method-undef-category-warn-1.m b/test/SemaObjC/method-undef-category-warn-1.m
index 75ca5b5..b367801 100644
--- a/test/SemaObjC/method-undef-category-warn-1.m
+++ b/test/SemaObjC/method-undef-category-warn-1.m
@@ -1,30 +1,26 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-@interface MyClass1
+@interface MyClass1
@end
@protocol P
-- (void) Pmeth;
-- (void) Pmeth1;
+- (void) Pmeth; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+- (void) Pmeth1; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
@end
-@interface MyClass1(CAT) <P>
-- (void) meth2;
+@interface MyClass1(CAT) <P> // expected-note {{required for direct or indirect protocol 'P'}}
+- (void) meth2; // expected-note {{method definition for 'meth2' not found}}
@end
-@implementation MyClass1(CAT) // expected-warning {{incomplete implementation}} \
- expected-warning {{method definition for 'meth2' not found}} \
- expected-warning {{method definition for 'Pmeth' not found}}
+@implementation MyClass1(CAT) // expected-warning {{incomplete implementation}}
- (void) Pmeth1{}
@end
-@interface MyClass1(DOG) <P>
-- (void)ppp;
+@interface MyClass1(DOG) <P> // expected-note {{required for direct or indirect protocol 'P'}}
+- (void)ppp; // expected-note {{method definition for 'ppp' not found}}
@end
-@implementation MyClass1(DOG) // expected-warning {{incomplete implementation}} \
- expected-warning {{method definition for 'ppp' not found}} \
- expected-warning {{method definition for 'Pmeth1' not found}}
+@implementation MyClass1(DOG) // expected-warning {{incomplete implementation}}
- (void) Pmeth {}
@end
diff --git a/test/SemaObjC/method-undef-extension-warn-1.m b/test/SemaObjC/method-undef-extension-warn-1.m
index fc27870..1addcf7 100644
--- a/test/SemaObjC/method-undef-extension-warn-1.m
+++ b/test/SemaObjC/method-undef-extension-warn-1.m
@@ -1,16 +1,16 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-@interface MyClass
+@interface MyClass // expected-note {{required for direct or indirect protocol 'P'}}
@end
@protocol P
- (void)Pmeth;
-- (void)Pmeth1;
+- (void)Pmeth1; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
@end
// Class extension
@interface MyClass () <P>
-- (void)meth2;
+- (void)meth2; // expected-note {{method definition for 'meth2' not found}}
@end
// Add a category to test that clang does not emit warning for this method.
@@ -18,8 +18,6 @@
- (void)categoryMethod;
@end
-@implementation MyClass // expected-warning {{incomplete implementation}} \
- expected-warning {{method definition for 'meth2' not found}} \
- expected-warning {{method definition for 'Pmeth1' not found}}
+@implementation MyClass // expected-warning {{incomplete implementation}}
- (void)Pmeth {}
@end
diff --git a/test/SemaObjC/method-undefined-warn-1.m b/test/SemaObjC/method-undefined-warn-1.m
index cfe1d56..1ebc59e 100644
--- a/test/SemaObjC/method-undefined-warn-1.m
+++ b/test/SemaObjC/method-undefined-warn-1.m
@@ -3,12 +3,12 @@
@interface INTF
- (void) meth;
- (void) meth : (int) arg1;
-- (int) int_meth;
-+ (int) cls_meth;
-+ (void) cls_meth1 : (int) arg1;
+- (int) int_meth; // expected-note {{method definition for 'int_meth' not found}}
++ (int) cls_meth; // expected-note {{method definition for 'cls_meth' not found}}
++ (void) cls_meth1 : (int) arg1; // expected-note {{method definition for 'cls_meth1:' not found}}
@end
-@implementation INTF // expected-warning {{incomplete implementation}} expected-warning {{method definition for 'int_meth' not found}} expected-warning {{method definition for 'cls_meth' not found}} expected-warning {{method definition for 'cls_meth1:' not found}}
+@implementation INTF // expected-warning {{incomplete implementation}}
- (void) meth {}
- (void) meth : (int) arg2{}
- (void) cls_meth1 : (int) arg2{}
@@ -17,12 +17,12 @@
@interface INTF1
- (void) meth;
- (void) meth : (int) arg1;
-- (int) int_meth;
-+ (int) cls_meth;
-+ (void) cls_meth1 : (int) arg1;
+- (int) int_meth; // expected-note {{method definition for 'int_meth' not found}}
++ (int) cls_meth; // expected-note {{method definition for 'cls_meth' not found}}
++ (void) cls_meth1 : (int) arg1; // expected-note {{method definition for 'cls_meth1:' not found}}
@end
-@implementation INTF1 // expected-warning {{incomplete implementation}} expected-warning {{method definition for 'int_meth' not found}} expected-warning {{method definition for 'cls_meth' not found}} expected-warning {{method definition for 'cls_meth1:' not found}}
+@implementation INTF1 // expected-warning {{incomplete implementation}}
- (void) meth {}
- (void) meth : (int) arg2{}
- (void) cls_meth1 : (int) arg2{}
diff --git a/test/SemaObjC/method-warn-unused-attribute.m b/test/SemaObjC/method-warn-unused-attribute.m
index d9dcf99..042f442 100644
--- a/test/SemaObjC/method-warn-unused-attribute.m
+++ b/test/SemaObjC/method-warn-unused-attribute.m
@@ -1,8 +1,16 @@
// RUN: %clang_cc1 -fsyntax-only -Wunused-value -verify %s
@interface INTF
-// Currently this is rejected by both GCC and Clang (and Clang was crashing on it).
-- (id) foo __attribute__((warn_unused_result)); // expected-warning{{warning: 'warn_unused_result' attribute only applies to function types}}
+- (id) foo __attribute__((warn_unused_result));
+- (void) garf __attribute__((warn_unused_result)); // expected-warning {{attribute 'warn_unused_result' cannot be applied to Objective-C method without return value}}
+- (int) fee __attribute__((warn_unused_result));
++ (int) c __attribute__((warn_unused_result));
@end
+void foo(INTF *a) {
+ [a garf];
+ [a fee]; // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
+ [INTF c]; // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
+}
+
diff --git a/test/SemaObjC/no-protocol-option-tests.m b/test/SemaObjC/no-protocol-option-tests.m
new file mode 100644
index 0000000..5d2da0a
--- /dev/null
+++ b/test/SemaObjC/no-protocol-option-tests.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -Wno-protocol -verify %s
+// rdar: // 7056600
+
+@protocol P
+- PMeth;
+@end
+
+// Test1
+@interface I <P> @end
+@implementation I @end // no warning with -Wno-protocol
+
+// Test2
+@interface C -PMeth; @end
+@interface C (Category) <P> @end
+@implementation C (Category) @end // no warning with -Wno-protocol
+
+// Test2
+@interface super - PMeth; @end
+@interface J : super <P>
+- PMeth; // expected-note {{ method definition for 'PMeth' not found}}
+@end
+@implementation J @end // expected-warning {{incomplete implementation}}
+
+// Test3
+@interface K : super <P>
+@end
+@implementation K @end // no warning with -Wno-protocol
+
+// Test4
+@interface Root @end
+@interface L : Root<P> @end
+@implementation L @end // no warning with -Wno-protocol
diff --git a/test/SemaObjC/nsobject-attribute.m b/test/SemaObjC/nsobject-attribute.m
index fdf9e35..13a4929 100644
--- a/test/SemaObjC/nsobject-attribute.m
+++ b/test/SemaObjC/nsobject-attribute.m
@@ -7,11 +7,16 @@ static CGColorRef tmp = 0;
typedef struct S1 __attribute__ ((NSObject)) CGColorRef1; // expected-error {{__attribute ((NSObject)) is for pointer types only}}
typedef void * __attribute__ ((NSObject)) CGColorRef2; // expected-error {{__attribute ((NSObject)) is for pointer types only}}
+
@interface HandTested {
@public
CGColorRef x;
}
+
@property(copy) CGColorRef x;
+// rdar: // 7809460
+typedef struct CGColor *CGColorRefNoNSObject;
+@property (nonatomic, retain) __attribute__((NSObject)) CGColorRefNoNSObject color;
@end
void setProperty(id self, id value) {
@@ -24,6 +29,7 @@ id getProperty(id self) {
@implementation HandTested
@synthesize x=x;
+@dynamic color;
@end
int main(int argc, char *argv[]) {
diff --git a/test/SemaObjC/property-expression-error.m b/test/SemaObjC/property-expression-error.m
index b59c1b1..6b5cf04 100644
--- a/test/SemaObjC/property-expression-error.m
+++ b/test/SemaObjC/property-expression-error.m
@@ -16,3 +16,8 @@ int main() {
&object.index; // expected-error {{address of property expression requested}}
return 0;
}
+
+typedef int Foo;
+void test() {
+ Foo.x; // expected-error {{expected identifier or '('}}
+}
diff --git a/test/SemaObjC/property-in-class-extension.m b/test/SemaObjC/property-in-class-extension.m
new file mode 100644
index 0000000..3f252d0
--- /dev/null
+++ b/test/SemaObjC/property-in-class-extension.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar: // 7766184
+
+@interface Foo @end
+
+@interface Foo ()
+ @property (readonly) int bar;
+@end
+
+void FUNC () {
+ Foo *foo;
+ foo.bar = 0; // expected-error {{assigning to property with 'readonly' attribute not allowed}}
+}
+
+
diff --git a/test/SemaObjC/property-ivar-mismatch.m b/test/SemaObjC/property-ivar-mismatch.m
index ea3acfc..16ff338 100644
--- a/test/SemaObjC/property-ivar-mismatch.m
+++ b/test/SemaObjC/property-ivar-mismatch.m
@@ -3,12 +3,12 @@
@interface Test4
{
- char ivar;
+ char ivar; // expected-note{{ivar is declared here}}
}
@property int prop;
@end
@implementation Test4
-@synthesize prop = ivar; // expected-error {{type of property 'prop' does not match type of ivar 'ivar'}}
+@synthesize prop = ivar; // expected-error {{type of property 'prop' ('int') does not match type of ivar 'ivar' ('char')}}
@end
diff --git a/test/SemaObjC/property.m b/test/SemaObjC/property.m
index b7f0fca..4d00bd2 100644
--- a/test/SemaObjC/property.m
+++ b/test/SemaObjC/property.m
@@ -2,7 +2,7 @@
@interface I
{
- int IVAR;
+ int IVAR; // expected-note{{ivar is declared here}}
int name;
}
@property int d1;
@@ -19,7 +19,7 @@
@synthesize d1; // expected-error {{synthesized property 'd1' must either be named the same as}}
@dynamic bad; // expected-error {{property implementation must have its declaration in interface 'I'}}
@synthesize prop_id; // expected-error {{synthesized property 'prop_id' must either be named the same}} // expected-note {{previous declaration is here}}
-@synthesize prop_id = IVAR; // expected-error {{type of property 'prop_id' does not match type of ivar 'IVAR'}} // expected-error {{property 'prop_id' is already implemented}}
+@synthesize prop_id = IVAR; // expected-error {{type of property 'prop_id' ('id') does not match type of ivar 'IVAR' ('int')}} // expected-error {{property 'prop_id' is already implemented}}
@synthesize name; // OK! property with same name as an accessible ivar of same name
@end
diff --git a/test/SemaObjC/undef-protocol-methods-1.m b/test/SemaObjC/undef-protocol-methods-1.m
index 9a35ef7..cbef3e5 100644
--- a/test/SemaObjC/undef-protocol-methods-1.m
+++ b/test/SemaObjC/undef-protocol-methods-1.m
@@ -1,40 +1,34 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
@protocol P1
-- (void) P1proto;
-+ (void) ClsP1Proto;
+- (void) P1proto; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
++ (void) ClsP1Proto; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
- (void) DefP1proto;
@end
@protocol P2
-- (void) P2proto;
-+ (void) ClsP2Proto;
+- (void) P2proto; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
++ (void) ClsP2Proto; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
@end
@protocol P3<P2>
-- (void) P3proto;
-+ (void) ClsP3Proto;
+- (void) P3proto; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
++ (void) ClsP3Proto; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+ (void) DefClsP3Proto;
@end
@protocol PROTO<P1, P3>
-- (void) meth;
-- (void) meth : (int) arg1;
-+ (void) cls_meth : (int) arg1;
+- (void) meth; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+- (void) meth : (int) arg1; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
++ (void) cls_meth : (int) arg1; // expected-warning {{method in protocol not implemented [-Wprotocol]}}
@end
-@interface INTF <PROTO>
+@interface INTF <PROTO> // expected-note 3 {{required for direct or indirect protocol 'PROTO'}} \
+ // expected-note 2 {{required for direct or indirect protocol 'P1'}} \
+ // expected-note 2 {{required for direct or indirect protocol 'P3'}} \
+ // expected-note 2 {{required for direct or indirect protocol 'P2'}}
@end
-@implementation INTF // expected-warning {{incomplete implementation}} \
- expected-warning {{method definition for 'meth' not found}} \
- expected-warning {{method definition for 'meth:' not found}} \
- expected-warning {{method definition for 'cls_meth:' not found}} \
- expected-warning {{method definition for 'P3proto' not found}} \
- expected-warning {{method definition for 'ClsP3Proto' not found}} \
- expected-warning {{method definition for 'P2proto' not found}} \
- expected-warning {{method definition for 'ClsP2Proto' not found}} \
- expected-warning {{method definition for 'ClsP1Proto' not found}} \
- expected-warning {{method definition for 'P1proto' not found}}
+@implementation INTF // expected-warning {{incomplete implementation}}
- (void) DefP1proto{}
+ (void) DefClsP3Proto{}
diff --git a/test/SemaTemplate/dependent-base-classes.cpp b/test/SemaTemplate/dependent-base-classes.cpp
index 600115b..d0dd9c9 100644
--- a/test/SemaTemplate/dependent-base-classes.cpp
+++ b/test/SemaTemplate/dependent-base-classes.cpp
@@ -55,7 +55,7 @@ namespace PR6031 {
template<typename T>
struct NoDepBase {
int foo() {
- class NoDepBase::Nested nested; // expected-error{{'Nested' does not name a tag member in the specified scope}}
+ class NoDepBase::Nested nested; // expected-error{{no class named 'Nested' in 'NoDepBase<T>'}}
typedef typename NoDepBase::template MemberTemplate<T>::type type; // expected-error{{'MemberTemplate' following the 'template' keyword does not refer to a template}} \
// FIXME: expected-error{{unqualified-id}}
return NoDepBase::a; // expected-error{{no member named 'a' in 'NoDepBase<T>'}}
diff --git a/test/SemaTemplate/friend-template.cpp b/test/SemaTemplate/friend-template.cpp
index 8bc2631..6ee30aa 100644
--- a/test/SemaTemplate/friend-template.cpp
+++ b/test/SemaTemplate/friend-template.cpp
@@ -74,12 +74,16 @@ namespace test3 {
template<typename T>
class X3 {
template<typename U, U Value> friend struct X2a;
- template<typename U, T Value> friend struct X2b;
+
+ // FIXME: the redeclaration note ends up here because redeclaration
+ // lookup ends up finding the friend target from X3<int>.
+ template<typename U, T Value> friend struct X2b; // expected-error {{template non-type parameter has a different type 'long' in template redeclaration}} \
+ // expected-note {{previous non-type template parameter with type 'int' is here}}
};
X3<int> x3i; // okay
- X3<long> x3l; // FIXME: should cause an instantiation-time failure
+ X3<long> x3l; // expected-note {{in instantiation}}
}
// PR5716
diff --git a/test/SemaTemplate/instantiate-declref.cpp b/test/SemaTemplate/instantiate-declref.cpp
index f883b93..2d27075 100644
--- a/test/SemaTemplate/instantiate-declref.cpp
+++ b/test/SemaTemplate/instantiate-declref.cpp
@@ -36,7 +36,7 @@ namespace N {
typedef int INT;
template struct N::Outer::Inner::InnerTemplate<INT>::VeryInner;
-template struct N::Outer::Inner::InnerTemplate<INT>::UeberInner; // expected-error{{'UeberInner' does not name a tag member}}
+template struct N::Outer::Inner::InnerTemplate<INT>::UeberInner; // expected-error{{no struct named 'UeberInner' in 'N::Outer::Inner::InnerTemplate<int>'}}
namespace N2 {
struct Outer2 {
diff --git a/test/SemaTemplate/instantiate-elab-type-specifier.cpp b/test/SemaTemplate/instantiate-elab-type-specifier.cpp
new file mode 100644
index 0000000..e5e10a8
--- /dev/null
+++ b/test/SemaTemplate/instantiate-elab-type-specifier.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR5681
+template <class T> struct Base {
+ struct foo {};
+ int foo;
+};
+
+template <class T> struct Derived : Base<T> {
+ typedef struct Base<T>::foo type;
+};
+
+template struct Derived<int>;
diff --git a/test/SemaTemplate/instantiate-expr-4.cpp b/test/SemaTemplate/instantiate-expr-4.cpp
index 92915c7..8cd7342 100644
--- a/test/SemaTemplate/instantiate-expr-4.cpp
+++ b/test/SemaTemplate/instantiate-expr-4.cpp
@@ -43,6 +43,19 @@ struct Temporaries0 {
template struct Temporaries0<5, 7>;
+// Ensure that both the constructor and the destructor are instantiated by
+// checking for parse errors from each.
+template<int N> struct BadX {
+ BadX() { int a[-N]; } // expected-error {{array size is negative}}
+ ~BadX() { int a[-N]; } // expected-error {{array size is negative}}
+};
+
+template<int N>
+struct PR6671 {
+ void f() { (void)BadX<1>(); } // expected-note 2 {{instantiation}}
+};
+template struct PR6671<1>;
+
// ---------------------------------------------------------------------
// new/delete expressions
// ---------------------------------------------------------------------
diff --git a/test/SemaTemplate/instantiate-function-params.cpp b/test/SemaTemplate/instantiate-function-params.cpp
new file mode 100644
index 0000000..ea8dd70
--- /dev/null
+++ b/test/SemaTemplate/instantiate-function-params.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR6619
+template<bool C> struct if_c { };
+template<typename T1> struct if_ {
+ typedef if_c< static_cast<bool>(T1::value)> almost_type_; // expected-note 7{{in instantiation}}
+};
+template <class Model, void (Model::*)()> struct wrap_constraints { };
+template <class Model>
+inline char has_constraints_(Model* , // expected-note 4{{while substituting deduced template arguments into function template 'has_constraints_' [with }} \
+ // expected-note 3{{candidate template ignored}}
+ wrap_constraints<Model,&Model::constraints>* = 0); // expected-note 4{{in instantiation}}
+
+template <class Model> struct not_satisfied {
+ static const bool value = sizeof( has_constraints_((Model*)0) == 1); // expected-error 3{{no matching function}}
+};
+template <class ModelFn> struct requirement_;
+template <void(*)()> struct instantiate {
+};
+template <class Model> struct requirement_<void(*)(Model)> : if_< not_satisfied<Model> >::type { // expected-error 3{{no type named}} \
+ // expected-note 7{{in instantiation}}
+};
+template <class Model> struct usage_requirements {
+};
+template < typename TT > struct InputIterator {
+ typedef instantiate< & requirement_<void(*)(usage_requirements<InputIterator> x)>::failed> boost_concept_check1; // expected-note 2{{in instantiation}}
+};
+template < typename TT > struct ForwardIterator : InputIterator<TT> { // expected-note 2{{in instantiation}}
+ typedef instantiate< & requirement_<void(*)(usage_requirements<ForwardIterator> x)>::failed> boost_concept_check2; // expected-note 2 {{in instantiation}}
+
+};
+typedef instantiate< &requirement_<void(*)(ForwardIterator<char*> x)>::failed> boost_concept_checkX; // expected-error{{no member named}} \
+// expected-note 6{{in instantiation}}
+
+template<typename T> struct X0 { };
+template<typename R, typename A1> struct X0<R(A1 param)> { };
+
+template<typename T, typename A1, typename A2>
+void instF0(X0<T(A1)> x0a, X0<T(A2)> x0b) {
+ X0<T(A1)> x0c;
+ X0<T(A2)> x0d;
+}
+
+template void instF0<int, int, float>(X0<int(int)>, X0<int(float)>);
+
+template<typename R, typename A1, R (*ptr)(A1)> struct FuncPtr { };
+template<typename A1, int (*ptr)(A1)> struct FuncPtr<int, A1, ptr> { };
+
+template<typename R, typename A1> R unary_func(A1);
+
+template<typename R, typename A1, typename A2>
+void use_func_ptr() {
+ FuncPtr<R, A1, &unary_func<R, A1> > fp1;
+ FuncPtr<R, A2, &unary_func<R, A2> > fp2;
+};
+
+template void use_func_ptr<int, float, double>();
diff --git a/test/SemaTemplate/instantiate-init.cpp b/test/SemaTemplate/instantiate-init.cpp
index 16ecc47..e292aa3 100644
--- a/test/SemaTemplate/instantiate-init.cpp
+++ b/test/SemaTemplate/instantiate-init.cpp
@@ -37,3 +37,21 @@ namespace PR6457 {
};
B<int> b;
}
+
+namespace PR6657 {
+ struct X
+ {
+ X (int, int) { }
+ };
+
+ template <typename>
+ void f0()
+ {
+ X x = X(0, 0);
+ }
+
+ void f1()
+ {
+ f0<int>();
+ }
+}
diff --git a/test/SemaTemplate/instantiate-member-class.cpp b/test/SemaTemplate/instantiate-member-class.cpp
index 5d69b50..44f396e 100644
--- a/test/SemaTemplate/instantiate-member-class.cpp
+++ b/test/SemaTemplate/instantiate-member-class.cpp
@@ -50,3 +50,33 @@ namespace test1 {
Registry<int>::node node(0);
}
}
+
+// Redeclarations during explicit instantiations.
+namespace test2 {
+ template <typename T> class A {
+ class Foo;
+ class Foo {
+ int foo();
+ };
+ };
+ template class A<int>;
+
+ template <typename T> class B {
+ class Foo;
+ class Foo {
+ typedef int X;
+ };
+ typename Foo::X x;
+ class Foo;
+ };
+ template class B<int>;
+
+ template <typename T> class C {
+ class Foo;
+ class Foo;
+ };
+ template <typename T> class C<T>::Foo {
+ int x;
+ };
+ template class C<int>;
+}
diff --git a/test/SemaTemplate/instantiate-member-initializers.cpp b/test/SemaTemplate/instantiate-member-initializers.cpp
index eecb445..e059434 100644
--- a/test/SemaTemplate/instantiate-member-initializers.cpp
+++ b/test/SemaTemplate/instantiate-member-initializers.cpp
@@ -10,14 +10,14 @@ A<int> a0;
A<void*> a1; // expected-note{{in instantiation of member function 'A<void *>::A' requested here}}
template<typename T> struct B {
- // FIXME: This should warn about initialization order
- B() : b(1), a(2) { }
+ B() : b(1), // expected-warning {{member 'b' will be initialized after}}
+ a(2) { } // expected-note {{field a}}
int a;
int b;
};
-B<int> b0;
+B<int> b0; // expected-note {{in instantiation of member function 'B<int>::B' requested here}}
template <class T> struct AA { AA(int); };
template <class T> class BB : public AA<T> {
diff --git a/test/SemaTemplate/instantiation-default-2.cpp b/test/SemaTemplate/instantiation-default-2.cpp
index 4d6756e..5a744a0 100644
--- a/test/SemaTemplate/instantiation-default-2.cpp
+++ b/test/SemaTemplate/instantiation-default-2.cpp
@@ -13,6 +13,6 @@ Constant<int*, &x> *c3;
Constant<float (*)(int, double), f> *c4;
Constant<float (*)(int, double), &f> *c5;
-Constant<float (*)(int, int), f> *c6; // expected-error{{non-type template argument of type 'float (*)(int, double)' cannot be converted to a value of type 'float (*)(int, int)'}}
+Constant<float (*)(int, int), f> *c6; // expected-error{{non-type template argument of type 'float (int, double)' cannot be converted to a value of type 'float (*)(int, int)'}}
Constant<float, 0> *c7; // expected-note{{while substituting}}
diff --git a/test/SemaTemplate/temp_arg_nontype.cpp b/test/SemaTemplate/temp_arg_nontype.cpp
index 9c20f2a..6e4f751 100644
--- a/test/SemaTemplate/temp_arg_nontype.cpp
+++ b/test/SemaTemplate/temp_arg_nontype.cpp
@@ -47,10 +47,8 @@ A3<h> *a14_1;
A3<&h> *a14_2;
A3<f> *a14_3;
A3<&f> *a14_4;
-A3<h2> *a14_6; // expected-error{{non-type template argument of type 'float (*)(float)' cannot be converted to a value of type 'int (*)(int)'}}
-A3<g> *a14_7; // expected-error{{non-type template argument of type '<overloaded function type>' cannot be converted to a value of type 'int (*)(int)'}}
-// FIXME: the first error includes the string <overloaded function
-// type>, which makes Doug slightly unhappy.
+A3<h2> *a14_6; // expected-error{{non-type template argument of type 'float (float)' cannot be converted to a value of type 'int (*)(int)'}}
+A3<g> *a14_7; // expected-error{{overloaded function cannot be resolved to a non-type template parameter of type 'int (*)(int)'}}
struct Y { } y;
@@ -59,17 +57,15 @@ volatile X * X_volatile_ptr;
template<X const &AnX> struct A4; // expected-note 2{{template parameter is declared here}}
X an_X;
A4<an_X> *a15_1; // okay
-A4<*X_volatile_ptr> *a15_2; // expected-error{{reference binding of non-type template parameter of type 'X const &' to template argument of type 'X volatile' ignores qualifiers}}
+A4<*X_volatile_ptr> *a15_2; // expected-error{{non-type template argument does not refer to any declaration}}
A4<y> *15_3; // expected-error{{non-type template parameter of reference type 'X const &' cannot bind to template argument of type 'struct Y'}} \
// FIXME: expected-error{{expected unqualified-id}}
template<int (&fr)(int)> struct A5; // expected-note 2{{template parameter is declared here}}
A5<h> *a16_1;
A5<f> *a16_3;
-A5<h2> *a16_6; // expected-error{{non-type template argument of type 'float (float)' cannot be converted to a value of type 'int (&)(int)'}}
-A5<g> *a14_7; // expected-error{{non-type template argument of type '<overloaded function type>' cannot be converted to a value of type 'int (&)(int)'}}
-// FIXME: the first error includes the string <overloaded function
-// type>, which makes Doug slightly unhappy.
+A5<h2> *a16_6; // expected-error{{non-type template parameter of reference type 'int (&)(int)' cannot bind to template argument of type 'float (float)'}}
+A5<g> *a14_7; // expected-error{{overloaded function cannot be resolved to a non-type template parameter of type 'int (&)(int)'}}
struct Z {
int foo(int);
@@ -97,21 +93,21 @@ template<unsigned char C> struct Overflow; // expected-note{{template parameter
Overflow<5> *overflow1; // okay
Overflow<255> *overflow2; // okay
-Overflow<256> *overflow3; // expected-error{{non-type template argument value '256' is too large for template parameter of type 'unsigned char'}}
+Overflow<256> *overflow3; // expected-warning{{non-type template argument value '256' truncated to '0' for template parameter of type 'unsigned char'}}
template<unsigned> struct Signedness; // expected-note{{template parameter is declared here}}
Signedness<10> *signedness1; // okay
-Signedness<-10> *signedness2; // expected-error{{non-type template argument provides negative value '-10' for unsigned template parameter of type 'unsigned int'}}
+Signedness<-10> *signedness2; // expected-warning{{non-type template argument with value '-10' converted to '4294967286' for unsigned template parameter of type 'unsigned int'}}
template<signed char C> struct SignedOverflow; // expected-note 3 {{template parameter is declared here}}
SignedOverflow<1> *signedoverflow1;
SignedOverflow<-1> *signedoverflow2;
SignedOverflow<-128> *signedoverflow3;
-SignedOverflow<-129> *signedoverflow4; // expected-error{{non-type template argument value '-129' is too large for template parameter of type 'signed char'}}
+SignedOverflow<-129> *signedoverflow4; // expected-warning{{non-type template argument value '-129' truncated to '127' for template parameter of type 'signed char'}}
SignedOverflow<127> *signedoverflow5;
-SignedOverflow<128> *signedoverflow6; // expected-error{{non-type template argument value '128' is too large for template parameter of type 'signed char'}}
-SignedOverflow<(unsigned char)128> *signedoverflow7; // expected-error{{non-type template argument value '128' is too large for template parameter of type 'signed char'}}
+SignedOverflow<128> *signedoverflow6; // expected-warning{{non-type template argument value '128' truncated to '-128' for template parameter of type 'signed char'}}
+SignedOverflow<(unsigned char)128> *signedoverflow7; // expected-warning{{non-type template argument value '128' truncated to '-128' for template parameter of type 'signed char'}}
// Check canonicalization of template arguments.
template<int (*)(int, int)> struct FuncPtr0;
@@ -171,3 +167,12 @@ namespace pr6249 {
int h();
template int f<int, h>();
}
+
+namespace PR6723 {
+ template<unsigned char C> void f(int (&a)[C]); // expected-note 2{{candidate template ignored}}
+ void g() {
+ int arr512[512];
+ f(arr512); // expected-error{{no matching function for call}}
+ f<512>(arr512); // expected-error{{no matching function for call}}
+ }
+}
OpenPOWER on IntegriCloud