[cfe-commits] r151509 - in /cfe/trunk/test: CXX/expr/expr.ass/p9-cxx11.cpp SemaCXX/cxx98-compat.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Sun Feb 26 15:49:01 PST 2012
Author: rsmith
Date: Sun Feb 26 17:49:01 2012
New Revision: 151509
URL: http://llvm.org/viewvc/llvm-project?rev=151509&view=rev
Log:
Tests for r151508.
Added:
cfe/trunk/test/CXX/expr/expr.ass/p9-cxx11.cpp
Modified:
cfe/trunk/test/SemaCXX/cxx98-compat.cpp
Added: cfe/trunk/test/CXX/expr/expr.ass/p9-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.ass/p9-cxx11.cpp?rev=151509&view=auto
==============================================================================
--- cfe/trunk/test/CXX/expr/expr.ass/p9-cxx11.cpp (added)
+++ cfe/trunk/test/CXX/expr/expr.ass/p9-cxx11.cpp Sun Feb 26 17:49:01 2012
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+template<typename T> struct complex {
+ complex(T = T(), T = T());
+ void operator+=(complex);
+ T a, b;
+};
+
+void std_example() {
+ complex<double> z;
+ z = { 1, 2 };
+ z += { 1, 2 };
+
+ // FIXME: implement semantics of scalar init list assignment.
+ int a, b;
+ a = b = { 1 }; // unexpected-error {{incompatible type 'void'}}
+ a = { 1 } = b; // unexpected-error {{incompatible type 'void'}}
+}
+
+struct S {
+ constexpr S(int a, int b) : a(a), b(b) {}
+ int a, b;
+};
+struct T {
+ constexpr int operator=(S s) { return s.a; }
+ constexpr int operator+=(S s) { return s.b; }
+};
+static_assert((T() = {4, 9}) == 4, "");
+static_assert((T() += {4, 9}) == 9, "");
+
+int k1 = T() = { 1, 2 } = { 3, 4 }; // expected-error {{expected ';'}}
+int k2 = T() = { 1, 2 } + 1; // expected-error {{expected ';'}}
Modified: cfe/trunk/test/SemaCXX/cxx98-compat.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx98-compat.cpp?rev=151509&r1=151508&r2=151509&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx98-compat.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx98-compat.cpp Sun Feb 26 17:49:01 2012
@@ -45,6 +45,8 @@
(void)int{}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \
// expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
int x { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}}
+ S<int> s = {}; // ok, aggregate
+ s = {}; // expected-warning {{generalized initializer lists are incompatible with C++98}}
return { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}}
}
More information about the cfe-commits
mailing list