[cfe-commits] r55178 - in /cfe/trunk/test: Sema/class-names.cpp Sema/default1.cpp Sema/default2.cpp Sema/inherit.cpp Sema/return-stack-addr.cpp SemaCXX/class-names.cpp SemaCXX/default1.cpp SemaCXX/default2.cpp SemaCXX/inherit.cpp SemaCXX/return-stack-addr.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Fri Aug 22 08:43:54 PDT 2008


Author: akirtzidis
Date: Fri Aug 22 10:43:49 2008
New Revision: 55178

URL: http://llvm.org/viewvc/llvm-project?rev=55178&view=rev
Log:
Move the rest of the Sema C++ tests into the SemaCXX test directory.

Added:
    cfe/trunk/test/SemaCXX/class-names.cpp
    cfe/trunk/test/SemaCXX/default1.cpp
    cfe/trunk/test/SemaCXX/default2.cpp
    cfe/trunk/test/SemaCXX/inherit.cpp
    cfe/trunk/test/SemaCXX/return-stack-addr.cpp
Removed:
    cfe/trunk/test/Sema/class-names.cpp
    cfe/trunk/test/Sema/default1.cpp
    cfe/trunk/test/Sema/default2.cpp
    cfe/trunk/test/Sema/inherit.cpp
    cfe/trunk/test/Sema/return-stack-addr.cpp

Removed: cfe/trunk/test/Sema/class-names.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/class-names.cpp?rev=55177&view=auto

==============================================================================
--- cfe/trunk/test/Sema/class-names.cpp (original)
+++ cfe/trunk/test/Sema/class-names.cpp (removed)
@@ -1,52 +0,0 @@
-// RUN: clang -fsyntax-only -verify %s
-class C { };
-
-C c;
-
-void D(int);
-
-class D {}; // expected-error{{previous use is here}}
-
-void foo()
-{
-  D(5);
-  class D d;
-}
-
-class D; 
-
-enum D; // expected-error{{use of 'D' with tag type that does not match previous declaration}}
-
-class A * A;
-
-class A * a2;
-
-void bar()
-{
-  A = 0;
-}
-
-void C(int);
-
-void bar2()
-{
-  C(17);
-}
-
-extern int B;
-class B;
-class B {};
-int B;
-
-enum E { e1_val };
-E e1;
-
-void E(int);
-
-void bar3() {
-  E(17);
-}
-
-enum E e2;
-
-enum E2 { E2 };

Removed: cfe/trunk/test/Sema/default1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/default1.cpp?rev=55177&view=auto

==============================================================================
--- cfe/trunk/test/Sema/default1.cpp (original)
+++ cfe/trunk/test/Sema/default1.cpp (removed)
@@ -1,17 +0,0 @@
-// RUN: clang -fsyntax-only -verify %s
-void f(int i);
-void f(int i = 0); // expected-error {{previous definition is here}}
-void f(int i = 17); // expected-error {{redefinition of default argument}}
-
-
-void g(int i, int j, int k = 3);
-void g(int i, int j = 2, int k);
-void g(int i = 1, int j, int k);
-
-void h(int i, int j = 2, int k = 3, 
-       int l, // expected-error {{missing default argument on parameter 'l'}}
-       int,   // expected-error {{missing default argument on parameter}}
-       int n);// expected-error {{missing default argument on parameter 'n'}}
-
-struct S { } s;
-void i(int = s) { } // expected-error {{incompatible type}}

Removed: cfe/trunk/test/Sema/default2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/default2.cpp?rev=55177&view=auto

==============================================================================
--- cfe/trunk/test/Sema/default2.cpp (original)
+++ cfe/trunk/test/Sema/default2.cpp (removed)
@@ -1,38 +0,0 @@
-// RUN: clang -fsyntax-only -verify %s
-void f(int i, int j, int k = 3);
-void f(int i, int j, int k);
-void f(int i, int j = 2, int k);
-void f(int i, int j, int k);
-void f(int i = 1, int j, int k);
-void f(int i, int j, int k);
-
-void i()
-{
-  f();
-  f(0);
-  f(0, 1);
-  f(0, 1, 2);
-}
-
-
-int f1(int i, int i, int j) { // expected-error {{redefinition of parameter 'i'}}
-  i = 17;
-  return j;
-} 
-
-int x;
-void g(int x, int y = x); // expected-error {{default argument references parameter 'x'}}
-
-void h()
-{
-   int i;
-   extern void h2(int x = sizeof(i)); // expected-error {{default argument references local variable 'i' of enclosing function}}
-}
-
-void g2(int x, int y, int z = x + y); // expected-error {{default argument references parameter 'x'}} expected-error {{default argument references parameter 'y'}}
-
-void nondecl(int (*f)(int x = 5)) // {expected-error {{default arguments can only be specified}}}
-{
-  void (*f2)(int = 17)  // {expected-error {{default arguments can only be specified}}}
-    = (void (*)(int = 42))f; // {expected-error {{default arguments can only be specified}}}
-}

Removed: cfe/trunk/test/Sema/inherit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/inherit.cpp?rev=55177&view=auto

==============================================================================
--- cfe/trunk/test/Sema/inherit.cpp (original)
+++ cfe/trunk/test/Sema/inherit.cpp (removed)
@@ -1,25 +0,0 @@
-// RUN: clang -fsyntax-only -verify %s
-class A { };
-
-class B1 : A { };
-
-class B2 : virtual A { };
-
-class B3 : virtual virtual A { }; // expected-error{{duplicate 'virtual' in base specifier}}
-
-class C : public B1, private B2 { };
-
-
-class D;
-
-class E : public D { }; // expected-error{{base class has incomplete type}}
-
-typedef int I;
-
-class F : public I { }; // expected-error{{base specifier must name a class}}
-
-union U1 : public A { }; // expected-error{{unions cannot have base classes}}
-
-union U2 {};
-
-class G : public U2 { }; // expected-error{{unions cannot be base classes}}

Removed: cfe/trunk/test/Sema/return-stack-addr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/return-stack-addr.cpp?rev=55177&view=auto

==============================================================================
--- cfe/trunk/test/Sema/return-stack-addr.cpp (original)
+++ cfe/trunk/test/Sema/return-stack-addr.cpp (removed)
@@ -1,113 +0,0 @@
-// RUN: clang -fsyntax-only -verify %s
-
-
-int* ret_local() {
-  int x = 1;
-  return &x; // expected-warning {{address of stack memory}}
-}
-
-int* ret_local_array() {
-  int x[10];
-  return x; // expected-warning {{address of stack memory}}
-}
-
-int* ret_local_array_element(int i) {
-  int x[10];
-  return &x[i]; // expected-warning {{address of stack memory}}
-}
-
-int *ret_local_array_element_reversed(int i) {
-  int x[10];
-  return &i[x]; // expected-warning {{address of stack memory}}
-}
-
-int* ret_local_array_element_const_index() {
-  int x[10];
-  return &x[2];  // expected-warning {{address of stack memory}}
-}
-
-int& ret_local_ref() {
-  int x = 1;
-  return x;  // expected-warning {{reference to stack memory}}
-}
-
-int* ret_local_addrOf() {
-  int x = 1;
-  return &*&x; // expected-warning {{address of stack memory}}
-}
-
-int* ret_local_addrOf_paren() {
-  int x = 1;
-  return (&(*(&x))); // expected-warning {{address of stack memory}}
-}
-
-int* ret_local_addrOf_ptr_arith() {
-  int x = 1;
-  return &*(&x+1); // expected-warning {{address of stack memory}}
-}
-
-int* ret_local_addrOf_ptr_arith2() {
-  int x = 1;
-  return &*(&x+1); // expected-warning {{address of stack memory}}
-}
-
-int* ret_local_field() {
-  struct { int x; } a;
-  return &a.x; // expected-warning {{address of stack memory}}
-}
-
-int& ret_local_field_ref() {
-  struct { int x; } a;
-  return a.x; // expected-warning {{reference to stack memory}}
-}
-
-int* ret_conditional(bool cond) {
-  int x = 1;
-  int y = 2;
-  return cond ? &x : &y; // expected-warning {{address of stack memory}}
-}
-
-int* ret_conditional_rhs(int *x, bool cond) {
-  int y = 1;
-  return cond ? x : &y;  // expected-warning {{address of stack memory}}
-}
-
-void* ret_c_cast() {
-  int x = 1;
-  return (void*) &x;  // expected-warning {{address of stack memory}}
-}
-
-int* ret_static_var() {
-  static int x = 1;
-  return &x;  // no warning.
-}
-
-int z = 1;
-
-int* ret_global() {
-  return &z;  // no warning.
-}
-
-int* ret_parameter(int x) {
-  return &x;  // expected-warning {{address of stack memory}}
-}
-
-
-int* ret_cpp_static_cast(short x) {
-  return static_cast<int*>(&x); // expected-warning {{address of stack memory}}
-}
-
-int* ret_cpp_reinterpret_cast(double x) {
-  return reinterpret_cast<int*>(&x); // expected-warning {{address of stack me}}
-}
-
-int* ret_cpp_reinterpret_cast_no_warning(double x) {
-  return reinterpret_cast<int*>(x); // no-warning
-}
-
-int* ret_cpp_const_cast(const int x) {
-  return const_cast<int*>(&x);  // expected-warning {{address of stack memory}}
-}
-
-// TODO: test case for dynamic_cast.  clang does not yet have
-// support for C++ classes to write such a test case.

Added: cfe/trunk/test/SemaCXX/class-names.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/class-names.cpp?rev=55178&view=auto

==============================================================================
--- cfe/trunk/test/SemaCXX/class-names.cpp (added)
+++ cfe/trunk/test/SemaCXX/class-names.cpp Fri Aug 22 10:43:49 2008
@@ -0,0 +1,52 @@
+// RUN: clang -fsyntax-only -verify %s
+class C { };
+
+C c;
+
+void D(int);
+
+class D {}; // expected-error{{previous use is here}}
+
+void foo()
+{
+  D(5);
+  class D d;
+}
+
+class D; 
+
+enum D; // expected-error{{use of 'D' with tag type that does not match previous declaration}}
+
+class A * A;
+
+class A * a2;
+
+void bar()
+{
+  A = 0;
+}
+
+void C(int);
+
+void bar2()
+{
+  C(17);
+}
+
+extern int B;
+class B;
+class B {};
+int B;
+
+enum E { e1_val };
+E e1;
+
+void E(int);
+
+void bar3() {
+  E(17);
+}
+
+enum E e2;
+
+enum E2 { E2 };

Added: cfe/trunk/test/SemaCXX/default1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/default1.cpp?rev=55178&view=auto

==============================================================================
--- cfe/trunk/test/SemaCXX/default1.cpp (added)
+++ cfe/trunk/test/SemaCXX/default1.cpp Fri Aug 22 10:43:49 2008
@@ -0,0 +1,17 @@
+// RUN: clang -fsyntax-only -verify %s
+void f(int i);
+void f(int i = 0); // expected-error {{previous definition is here}}
+void f(int i = 17); // expected-error {{redefinition of default argument}}
+
+
+void g(int i, int j, int k = 3);
+void g(int i, int j = 2, int k);
+void g(int i = 1, int j, int k);
+
+void h(int i, int j = 2, int k = 3, 
+       int l, // expected-error {{missing default argument on parameter 'l'}}
+       int,   // expected-error {{missing default argument on parameter}}
+       int n);// expected-error {{missing default argument on parameter 'n'}}
+
+struct S { } s;
+void i(int = s) { } // expected-error {{incompatible type}}

Added: cfe/trunk/test/SemaCXX/default2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/default2.cpp?rev=55178&view=auto

==============================================================================
--- cfe/trunk/test/SemaCXX/default2.cpp (added)
+++ cfe/trunk/test/SemaCXX/default2.cpp Fri Aug 22 10:43:49 2008
@@ -0,0 +1,38 @@
+// RUN: clang -fsyntax-only -verify %s
+void f(int i, int j, int k = 3);
+void f(int i, int j, int k);
+void f(int i, int j = 2, int k);
+void f(int i, int j, int k);
+void f(int i = 1, int j, int k);
+void f(int i, int j, int k);
+
+void i()
+{
+  f();
+  f(0);
+  f(0, 1);
+  f(0, 1, 2);
+}
+
+
+int f1(int i, int i, int j) { // expected-error {{redefinition of parameter 'i'}}
+  i = 17;
+  return j;
+} 
+
+int x;
+void g(int x, int y = x); // expected-error {{default argument references parameter 'x'}}
+
+void h()
+{
+   int i;
+   extern void h2(int x = sizeof(i)); // expected-error {{default argument references local variable 'i' of enclosing function}}
+}
+
+void g2(int x, int y, int z = x + y); // expected-error {{default argument references parameter 'x'}} expected-error {{default argument references parameter 'y'}}
+
+void nondecl(int (*f)(int x = 5)) // {expected-error {{default arguments can only be specified}}}
+{
+  void (*f2)(int = 17)  // {expected-error {{default arguments can only be specified}}}
+    = (void (*)(int = 42))f; // {expected-error {{default arguments can only be specified}}}
+}

Added: cfe/trunk/test/SemaCXX/inherit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/inherit.cpp?rev=55178&view=auto

==============================================================================
--- cfe/trunk/test/SemaCXX/inherit.cpp (added)
+++ cfe/trunk/test/SemaCXX/inherit.cpp Fri Aug 22 10:43:49 2008
@@ -0,0 +1,25 @@
+// RUN: clang -fsyntax-only -verify %s
+class A { };
+
+class B1 : A { };
+
+class B2 : virtual A { };
+
+class B3 : virtual virtual A { }; // expected-error{{duplicate 'virtual' in base specifier}}
+
+class C : public B1, private B2 { };
+
+
+class D;
+
+class E : public D { }; // expected-error{{base class has incomplete type}}
+
+typedef int I;
+
+class F : public I { }; // expected-error{{base specifier must name a class}}
+
+union U1 : public A { }; // expected-error{{unions cannot have base classes}}
+
+union U2 {};
+
+class G : public U2 { }; // expected-error{{unions cannot be base classes}}

Added: cfe/trunk/test/SemaCXX/return-stack-addr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/return-stack-addr.cpp?rev=55178&view=auto

==============================================================================
--- cfe/trunk/test/SemaCXX/return-stack-addr.cpp (added)
+++ cfe/trunk/test/SemaCXX/return-stack-addr.cpp Fri Aug 22 10:43:49 2008
@@ -0,0 +1,113 @@
+// RUN: clang -fsyntax-only -verify %s
+
+
+int* ret_local() {
+  int x = 1;
+  return &x; // expected-warning {{address of stack memory}}
+}
+
+int* ret_local_array() {
+  int x[10];
+  return x; // expected-warning {{address of stack memory}}
+}
+
+int* ret_local_array_element(int i) {
+  int x[10];
+  return &x[i]; // expected-warning {{address of stack memory}}
+}
+
+int *ret_local_array_element_reversed(int i) {
+  int x[10];
+  return &i[x]; // expected-warning {{address of stack memory}}
+}
+
+int* ret_local_array_element_const_index() {
+  int x[10];
+  return &x[2];  // expected-warning {{address of stack memory}}
+}
+
+int& ret_local_ref() {
+  int x = 1;
+  return x;  // expected-warning {{reference to stack memory}}
+}
+
+int* ret_local_addrOf() {
+  int x = 1;
+  return &*&x; // expected-warning {{address of stack memory}}
+}
+
+int* ret_local_addrOf_paren() {
+  int x = 1;
+  return (&(*(&x))); // expected-warning {{address of stack memory}}
+}
+
+int* ret_local_addrOf_ptr_arith() {
+  int x = 1;
+  return &*(&x+1); // expected-warning {{address of stack memory}}
+}
+
+int* ret_local_addrOf_ptr_arith2() {
+  int x = 1;
+  return &*(&x+1); // expected-warning {{address of stack memory}}
+}
+
+int* ret_local_field() {
+  struct { int x; } a;
+  return &a.x; // expected-warning {{address of stack memory}}
+}
+
+int& ret_local_field_ref() {
+  struct { int x; } a;
+  return a.x; // expected-warning {{reference to stack memory}}
+}
+
+int* ret_conditional(bool cond) {
+  int x = 1;
+  int y = 2;
+  return cond ? &x : &y; // expected-warning {{address of stack memory}}
+}
+
+int* ret_conditional_rhs(int *x, bool cond) {
+  int y = 1;
+  return cond ? x : &y;  // expected-warning {{address of stack memory}}
+}
+
+void* ret_c_cast() {
+  int x = 1;
+  return (void*) &x;  // expected-warning {{address of stack memory}}
+}
+
+int* ret_static_var() {
+  static int x = 1;
+  return &x;  // no warning.
+}
+
+int z = 1;
+
+int* ret_global() {
+  return &z;  // no warning.
+}
+
+int* ret_parameter(int x) {
+  return &x;  // expected-warning {{address of stack memory}}
+}
+
+
+int* ret_cpp_static_cast(short x) {
+  return static_cast<int*>(&x); // expected-warning {{address of stack memory}}
+}
+
+int* ret_cpp_reinterpret_cast(double x) {
+  return reinterpret_cast<int*>(&x); // expected-warning {{address of stack me}}
+}
+
+int* ret_cpp_reinterpret_cast_no_warning(double x) {
+  return reinterpret_cast<int*>(x); // no-warning
+}
+
+int* ret_cpp_const_cast(const int x) {
+  return const_cast<int*>(&x);  // expected-warning {{address of stack memory}}
+}
+
+// TODO: test case for dynamic_cast.  clang does not yet have
+// support for C++ classes to write such a test case.





More information about the cfe-commits mailing list