[cfe-commits] r131754 - /cfe/trunk/test/SemaCXX/generalized-initializers.cpp
Johannes Schaub (litb)
schaub.johannes at googlemail.com
Fri May 20 14:59:03 PDT 2011
Sebastian Redl wrote:
> Author: cornedbee
> Date: Fri May 20 16:07:01 2011
> New Revision: 131754
>
> URL: http://llvm.org/viewvc/llvm-project?rev=131754&view=rev
> Log:
> Introduce XFAILed test for braced initializer lists.
>
> Added:
> cfe/trunk/test/SemaCXX/generalized-initializers.cpp
>
> Added: cfe/trunk/test/SemaCXX/generalized-initializers.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/generalized-
initializers.cpp?rev=131754&view=auto
>
==============================================================================
> --- cfe/trunk/test/SemaCXX/generalized-initializers.cpp (added) +++
> cfe/trunk/test/SemaCXX/generalized-initializers.cpp Fri May 20 16:07:01
> 2011 @@ -0,0 +1,127 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only
...
> +
> +namespace objects {
> +
> + struct A {
> + A();
> + A(int, double);
> + A(int, int);
> + A(std::initializer_list<int>);
> +
> + int operator[](A);
> + };
> +
> + void initialization() {
> + // FIXME: how to ensure correct overloads are called?
> + { A a{}; }
> + { A a = {}; }
> + { A a{1, 1.0}; }
> + { A a = {1, 1.0}; }
> + { A a{1, 2, 3, 4, 5, 6, 7, 8}; }
> + { A a = {1, 2, 3, 4, 5, 6, 7, 8}; }
> + { A a{1, 2, 3, 4, 5, 6, 7, 8}; }
> + { A a{1, 2}; }
> + }
> +
Perhaps:
template<int N>
+ struct A {
+ A() { static_assert(N == 0, ""); }
+ A(int, double) { static_assert(N == 1, ""); }
+ A(int, int) { static_assert(N == 2, ""); }
+ A(std::initializer_list<int>) { static_assert(N == 3, ""); }
+
+ int operator[](A);
+ };
+ void initialization() {
+ { A<0> a{}; }
+ { A<0> a = {}; }
+ { A<3> a{1, 1.0}; }
+ { A<3> a = {1, 1.0}; }
+ { A<3> a{1, 2, 3, 4, 5, 6, 7, 8}; }
+ { A<3> a = {1, 2, 3, 4, 5, 6, 7, 8}; }
+ { A<3> a{1, 2, 3, 4, 5, 6, 7, 8}; }
+ { A<3> a{1, 2}; }
+ }
I did some other tests that I posted to a GCC PR. If you want you can add
them here too: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47453#c3
More information about the cfe-commits
mailing list