summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2012-02-29 10:24:19 +0000
committerJames Molloy <james.molloy@arm.com>2012-02-29 10:24:19 +0000
commit6f8780bed1549ce1a292d7c204172d869a4f3f32 (patch)
treec34d00545762f9622a8e1b3efe25a60b6a460f11 /clang/test
parent64aea6524d2249d89b8df31a7c0f9357e0a908f3 (diff)
downloadbcm5719-llvm-6f8780bed1549ce1a292d7c204172d869a4f3f32.tar.gz
bcm5719-llvm-6f8780bed1549ce1a292d7c204172d869a4f3f32.zip
Reapply r151638 and r151641.
The bug that was caught by Apple's internal buildbots was valid and also showed another bug in my implementation. These are now fixed, with regression tests added to catch them both (not Darwin-specific). Original log: ==================== Revert r151638 because it causes assertion hit on PCH creation for Cocoa.h Original log: --------------------- Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped. This fixes code such as: enum e {x, y}; int f(enum {y, x} n) { return 0; } This finally fixes PR5464 and PR5477. --------------------- I also reverted r151641 which was enhancement on top of r151638. ==================== llvm-svn: 151712
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CodeGen/decl-in-prototype.c21
-rw-r--r--clang/test/Misc/warning-flags.c3
-rw-r--r--clang/test/Sema/decl-in-prototype.c33
-rw-r--r--clang/test/Sema/fn-ptr-as-fn-prototype.c15
4 files changed, 70 insertions, 2 deletions
diff --git a/clang/test/CodeGen/decl-in-prototype.c b/clang/test/CodeGen/decl-in-prototype.c
new file mode 100644
index 00000000000..949793da445
--- /dev/null
+++ b/clang/test/CodeGen/decl-in-prototype.c
@@ -0,0 +1,21 @@
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck %s
+
+const int AA = 5;
+
+// CHECK: define i32 @f1
+int f1(enum {AA,BB} E) {
+ // CHECK: ret i32 1
+ return BB;
+}
+
+// CHECK: define i32 @f2
+int f2(enum {AA=7,BB} E) {
+ // CHECK: ret i32 7
+ return AA;
+}
+
+// Check nested function declarators work.
+int f(void (*g)(), enum {AA,BB} h) {
+ // CHECK: ret i32 0
+ return AA;
+}
diff --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c
index 6621f08fcf7..5c0e80055a3 100644
--- a/clang/test/Misc/warning-flags.c
+++ b/clang/test/Misc/warning-flags.c
@@ -17,7 +17,7 @@ This test serves two purposes:
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (257):
+CHECK: Warnings without flags (256):
CHECK-NEXT: ext_anonymous_struct_union_qualified
CHECK-NEXT: ext_binary_literal
CHECK-NEXT: ext_cast_fn_obj
@@ -137,7 +137,6 @@ CHECK-NEXT: warn_conv_to_base_not_used
CHECK-NEXT: warn_conv_to_self_not_used
CHECK-NEXT: warn_conv_to_void_not_used
CHECK-NEXT: warn_cxx0x_right_shift_in_template_arg
-CHECK-NEXT: warn_decl_in_param_list
CHECK-NEXT: warn_delete_array_type
CHECK-NEXT: warn_division_by_zero
CHECK-NEXT: warn_double_const_requires_fp64
diff --git a/clang/test/Sema/decl-in-prototype.c b/clang/test/Sema/decl-in-prototype.c
new file mode 100644
index 00000000000..05b8e0a1c3b
--- /dev/null
+++ b/clang/test/Sema/decl-in-prototype.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1_only -verify %s
+
+const int AA = 5;
+
+int f1(enum {AA,BB} E) {
+ return BB;
+}
+
+int f2(enum {AA=7,BB} E) {
+ return AA;
+}
+
+struct a {
+};
+
+int f3(struct a { } *); // expected-warning {{will not be visible outside of this function}}
+
+struct A { struct b { int j; } t; }; // expected-note {{previous definition is here}}
+
+int f4(struct A { struct b { int j; } t; } *); // expected-warning {{declaration of 'struct A' will not be visible outside of this function}} expected-warning {{redefinition of 'b' will not be visible outside of this function}}
+
+struct aA {
+ struct ab { // expected-note {{previous definition is here}} expected-note {{previous definition is here}}
+ int j;
+ } b;
+};
+
+int f5(struct aA { struct ab { int j; } b; struct ab { char glorx; } glorx; } *); // expected-warning {{declaration of 'struct aA' will not be visible}} expected-warning {{redefinition of 'ab' will not be visible}} expected-warning {{redefinition of 'ab' will not be visible}}
+
+void f6(struct z {int b;} c) { // expected-warning {{declaration of 'struct z' will not be visible outside of this function}}
+ struct z d;
+ d.b = 4;
+}
diff --git a/clang/test/Sema/fn-ptr-as-fn-prototype.c b/clang/test/Sema/fn-ptr-as-fn-prototype.c
new file mode 100644
index 00000000000..cf95c977468
--- /dev/null
+++ b/clang/test/Sema/fn-ptr-as-fn-prototype.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1_only -ast-print %s | FileCheck %s
+
+// This testcase checks the functionality of
+// Sema::ActOn{Start,End}FunctionDeclarator, specifically checking that
+// ActOnEndFunctionDeclarator is called after the typedef so the enum
+// is in the global scope, not the scope of f().
+
+// CHECK: typedef void (*g)();
+typedef void (*g) ();
+// CHECK: enum {
+enum {
+ k = -1
+};
+// CHECK: void f() {
+void f() {}
OpenPOWER on IntegriCloud