diff options
author | Jason Merrill <jason@redhat.com> | 2017-06-09 20:40:50 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2017-06-09 20:40:50 -0400 |
commit | e6d7d61861c8fa7207570abb6fc23c5a2921e4da (patch) | |
tree | 8d20815456dbc2d945ec18a4963a28ba3b75f5e9 /gcc/testsuite | |
parent | 8b8b203a26bdac3dede77e76d06e4e7084f79acc (diff) | |
download | gcc-e6d7d61861c8fa7207570abb6fc23c5a2921e4da.zip gcc-e6d7d61861c8fa7207570abb6fc23c5a2921e4da.tar.gz gcc-e6d7d61861c8fa7207570abb6fc23c5a2921e4da.tar.bz2 |
Missing bits from N4268, constant evaluation for all non-type args.
* call.c (build_converted_constant_expr): Rename from
build_integral_nontype_arg_conv, handle all types.
* pt.c (convert_nontype_argument): In C++17 call it for all types.
Move NOP stripping inside pointer case, don't strip ADDR_EXPR.
* cvt.c (strip_fnptr_conv): Also strip conversions to the same type.
From-SVN: r249089
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-targ.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/crash106.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/crash84.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/crash87.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/dependent-args1.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/nontype-array1.C | 14 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/nontype13.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/nontype21.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/nontype26.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/ptrmem20.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/ptrmem8.C | 6 |
11 files changed, 25 insertions, 13 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-targ.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-targ.C index b517114..98bb502 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-targ.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-targ.C @@ -10,4 +10,4 @@ struct B { }; constexpr A a { }; -B<a> b; // { dg-error "template argument|invalid type" } +B<a> b; // { dg-error "template argument|converted constant" } diff --git a/gcc/testsuite/g++.dg/template/crash106.C b/gcc/testsuite/g++.dg/template/crash106.C index 5bef101..8d97269 100644 --- a/gcc/testsuite/g++.dg/template/crash106.C +++ b/gcc/testsuite/g++.dg/template/crash106.C @@ -11,4 +11,4 @@ template<T N = 0, void (A::*)() = &A::foo<N> > struct B {}; // { dg-error "type| B<> b; // { dg-message "non-type" } -// { dg-prune-output "could not convert" } +// { dg-prune-output "(could not convert|no matches)" } diff --git a/gcc/testsuite/g++.dg/template/crash84.C b/gcc/testsuite/g++.dg/template/crash84.C index 103e90a..b3099d9 100644 --- a/gcc/testsuite/g++.dg/template/crash84.C +++ b/gcc/testsuite/g++.dg/template/crash84.C @@ -14,7 +14,7 @@ void foo () { a<int> a1; // OK - a<int>::b<a,int> b1; // { dg-error "template argument" } + a<int>::b<a,int> b1; // { dg-error "template argument|converted constant" } } // { dg-prune-output "invalid type in declaration" } diff --git a/gcc/testsuite/g++.dg/template/crash87.C b/gcc/testsuite/g++.dg/template/crash87.C index 7b8bf4a..af81edb 100644 --- a/gcc/testsuite/g++.dg/template/crash87.C +++ b/gcc/testsuite/g++.dg/template/crash87.C @@ -17,7 +17,7 @@ template <bool name> class BUG2 : BUG { public: - typedef BUG1_5<name> ptr; // { dg-error "could not convert template argument" } + typedef BUG1_5<name> ptr; // { dg-error "convert" } }; int main() diff --git a/gcc/testsuite/g++.dg/template/dependent-args1.C b/gcc/testsuite/g++.dg/template/dependent-args1.C index a540e55..8fffbf8 100644 --- a/gcc/testsuite/g++.dg/template/dependent-args1.C +++ b/gcc/testsuite/g++.dg/template/dependent-args1.C @@ -10,4 +10,4 @@ template<int N, void (A::*)() = &A::foo<N> > struct B {}; B<int> b; // { dg-error "type/value mismatch|expected a constant|invalid type" } -// { dg-prune-output "could not convert" } +// { dg-prune-output "(could not convert|no match)" } diff --git a/gcc/testsuite/g++.dg/template/nontype-array1.C b/gcc/testsuite/g++.dg/template/nontype-array1.C index cf21908..f22551b 100644 --- a/gcc/testsuite/g++.dg/template/nontype-array1.C +++ b/gcc/testsuite/g++.dg/template/nontype-array1.C @@ -10,17 +10,31 @@ constexpr char const s3[] = "hi"; // OK since C++11 constexpr char const * f() { return s3; } +using fn_p = char const * (*)(); +template <fn_p> struct A { }; +constexpr fn_p f2() { return f; } + +struct B +{ + constexpr B() { } + constexpr operator const char *() { return s3; } +}; + int main() { Message<s1> m1; // OK (all versions) Message<s2> m2; // OK for clang since C++14, for gcc since C++17 Message<s3> m3; // OK for clang/gcc since C++11 + A<f2()> a1; // { dg-error "" "" { target c++14_down } } + static char const s4[] = "hi"; static constexpr char const s5[] = "hi"; // OK since C++11 Message<s4> m4; // { dg-error "no linkage" "" { target c++14_down } } Message<s5> m5; // { dg-error "no linkage" "" { target c++14_down } } Message<f()> m6; // { dg-error "" "" { target c++14_down } } + Message<B{}> m7; // { dg-error "" "" { target c++14_down } } + char const s8[] = "hi"; Message<s8> m8; // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/template/nontype13.C b/gcc/testsuite/g++.dg/template/nontype13.C index d604da9..3250109 100644 --- a/gcc/testsuite/g++.dg/template/nontype13.C +++ b/gcc/testsuite/g++.dg/template/nontype13.C @@ -11,7 +11,7 @@ struct Dummy template<bool B> void tester() { - bar<evil>()(); // { dg-error "constant|template" } + bar<evil>()(); // { dg-error "constant|template|convert" } } template<bool B> struct bar diff --git a/gcc/testsuite/g++.dg/template/nontype21.C b/gcc/testsuite/g++.dg/template/nontype21.C index 69cab54..508f909 100644 --- a/gcc/testsuite/g++.dg/template/nontype21.C +++ b/gcc/testsuite/g++.dg/template/nontype21.C @@ -4,4 +4,4 @@ template<char const * const x> class Something { }; extern char const xyz; -class SomethingElse:public Something<xyz> { }; // { dg-error "xyz. is a variable" } +class SomethingElse:public Something<xyz> { }; // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/template/nontype26.C b/gcc/testsuite/g++.dg/template/nontype26.C index 763d987..588ce1c 100644 --- a/gcc/testsuite/g++.dg/template/nontype26.C +++ b/gcc/testsuite/g++.dg/template/nontype26.C @@ -7,7 +7,7 @@ template<int& i> void doit() { template<const int& i> class X { public: void foo() { - doit<i>(); // { dg-error "cv-qualification|no matching" } + doit<i>(); // { dg-error "qualifi|template arg|no matching" } } }; diff --git a/gcc/testsuite/g++.dg/template/ptrmem20.C b/gcc/testsuite/g++.dg/template/ptrmem20.C index 2d2453d..e17ed84 100644 --- a/gcc/testsuite/g++.dg/template/ptrmem20.C +++ b/gcc/testsuite/g++.dg/template/ptrmem20.C @@ -12,5 +12,5 @@ template<void (A::*)()> void bar(); // { dg-message "note" } void baz() { - bar<&B::foo>(); // { dg-error "not a valid template argument|no match" } + bar<&B::foo>(); // { dg-error "template argument|no match" } } diff --git a/gcc/testsuite/g++.dg/template/ptrmem8.C b/gcc/testsuite/g++.dg/template/ptrmem8.C index 85ffa4a..b759b70 100644 --- a/gcc/testsuite/g++.dg/template/ptrmem8.C +++ b/gcc/testsuite/g++.dg/template/ptrmem8.C @@ -15,10 +15,8 @@ template <int (D::*fun)() const> int Get(); // { dg-message "note" } int main () { - Get<&B::I>(); // { dg-error "not a valid template argument" "not valid" } + Get<&B::I>(); // { dg-error "template argument|converted constant" "not valid" } // { dg-error "no match" "no match" { target *-*-* } .-1 } - // { dg-message "note" "note" { target *-*-* } .-2 } - Get<&D::I>(); // { dg-error "not a valid template argument" "not valid" } + Get<&D::I>(); // { dg-error "template argument|converted constant" "not valid" } // { dg-error "no match" "no match" { target *-*-* } .-1 } - // { dg-message "note" "note" { target *-*-* } .-2 } } |