From adcef2743040ffe09dedd3bc909adf02a26a6803 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sun, 6 Dec 2015 23:34:36 -0500 Subject: [PATCH] static_assert8.C: Fix for -std=c++1z. * g++.dg/cpp0x/static_assert8.C: Fix for -std=c++1z. * g++.dg/cpp0x/auto3.C: Fix for -std=c++1z. * g++.dg/cpp1y/feat-cxx14.C: Only run with -std=c++14. * g++.dg/cpp1y/feat-cxx14-neg.C: Only run with -std=c++14. * g++.dg/cpp1z/feat-cxx1z.C: Fill in from feat-cxx14.C. * g++.dg/cpp1z/fold5.C: Don't run with -std=c++1z. * g++.dg/template/function1.C: Don't run with -std=c++1z. * g++.dg/template/call4.C: Fix access. * g++.dg/parse/crash31.C: Remove expected error text. From-SVN: r231348 --- gcc/testsuite/g++.dg/cpp0x/auto3.C | 4 +- gcc/testsuite/g++.dg/cpp0x/static_assert8.C | 2 +- gcc/testsuite/g++.dg/cpp1y/feat-cxx14-neg.C | 2 +- gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C | 3 +- gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C | 323 +++++++++++++++++++++++++++- gcc/testsuite/g++.dg/cpp1z/fold5.C | 2 +- gcc/testsuite/g++.dg/parse/crash31.C | 14 +- gcc/testsuite/g++.dg/template/call4.C | 2 +- gcc/testsuite/g++.dg/template/function1.C | 2 +- 9 files changed, 336 insertions(+), 18 deletions(-) diff --git a/gcc/testsuite/g++.dg/cpp0x/auto3.C b/gcc/testsuite/g++.dg/cpp0x/auto3.C index 5bfed1b..27aab57 100644 --- a/gcc/testsuite/g++.dg/cpp0x/auto3.C +++ b/gcc/testsuite/g++.dg/cpp0x/auto3.C @@ -17,11 +17,11 @@ struct A { }; A A1; // CWG issue 625 -A A2 = A1; // { dg-error "" } +A A2 = A1; // { dg-error "" "" { target { ! c++1z } } } auto foo() { } // { dg-error "auto" "" { target { ! c++14 } } } -void bar(auto i) // { dg-error "incomplete|auto" } +void bar(auto i) // { dg-error "incomplete|auto" "" { target { ! c++1z } } } { (void)i; } diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert8.C b/gcc/testsuite/g++.dg/cpp0x/static_assert8.C index 972f859..6602e70 100644 --- a/gcc/testsuite/g++.dg/cpp0x/static_assert8.C +++ b/gcc/testsuite/g++.dg/cpp0x/static_assert8.C @@ -6,4 +6,4 @@ static_assert (1 == 0,); // { dg-error "expected string-literal before '\\)'" } static_assert (1 == 0, "oops"); // { dg-error "static assertion failed" } -// { dg-error "static_assert without a message only available with " "" { target *-*-* } 3 } +// { dg-error "static_assert without a message only available with " "" { target { ! c++1z } } 3 } diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx14-neg.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx14-neg.C index 221bd3f..d5793ab 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx14-neg.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx14-neg.C @@ -1,4 +1,4 @@ -// { dg-do compile { target c++14 } } +// { dg-options -std=c++14 } // C++17 features: diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C index 1292966..d9dbf62 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C @@ -1,5 +1,4 @@ -// { dg-do compile { target c++14 } } -// { dg-options "-I${srcdir}/g++.dg/cpp1y -I${srcdir}/g++.dg/cpp1y/testinc" } +// { dg-options "-std=c++14 -I${srcdir}/g++.dg/cpp1y -I${srcdir}/g++.dg/cpp1y/testinc" } // C++98 features: diff --git a/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C b/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C index ead1665..9b3b284 100644 --- a/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C +++ b/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C @@ -1,5 +1,306 @@ -// { dg-do compile } -// { dg-options "-std=c++1z" } +// { dg-options "-std=c++1z -I${srcdir}/g++.dg/cpp1y -I${srcdir}/g++.dg/cpp1y/testinc" } + +// C++98 features: + +#ifndef __cpp_rtti +# error "__cpp_rtti" +#elif __cpp_rtti != 199711 +# error "__cpp_rtti != 199711" +#endif + +#ifndef __cpp_exceptions +# error "__cpp_exceptions" +#elif __cpp_exceptions != 199711 +# error "__cpp_exceptions != 199711" +#endif + +// C++11 features: + +#ifndef __cpp_raw_strings +# error "__cpp_raw_strings" +#elif __cpp_raw_strings != 200710 +# error "__cpp_raw_strings != 200710" +#endif + +#ifndef __cpp_unicode_literals +# error "__cpp_unicode_literals" +#elif __cpp_unicode_literals != 200710 +# error "__cpp_unicode_literals != 200710" +#endif + +#ifndef __cpp_user_defined_literals +# error "__cpp_user_defined_literals" +#elif __cpp_user_defined_literals != 200809 +# error "__cpp_user_defined_literals != 200809" +#endif + +#ifndef __cpp_lambdas +# error "__cpp_lambdas" +#elif __cpp_lambdas != 200907 +# error "__cpp_lambdas != 200907" +#endif + +#ifndef __cpp_range_based_for +# error "__cpp_range_based_for" +#elif __cpp_range_based_for != 200907 +# error "__cpp_range_based_for != 200907" +#endif + +#ifndef __cpp_decltype +# error "__cpp_decltype" +#elif __cpp_decltype != 200707 +# error "__cpp_decltype != 200707" +#endif + +#ifndef __cpp_attributes +# error "__cpp_attributes" +#elif __cpp_attributes != 200809 +# error "__cpp_attributes != 200809" +#endif + +#ifndef __cpp_rvalue_reference +# error "__cpp_rvalue_reference" +#elif __cpp_rvalue_reference != 200610 +# error "__cpp_rvalue_reference != 200610" +#endif + +#ifndef __cpp_variadic_templates +# error "__cpp_variadic_templates" +#elif __cpp_variadic_templates != 200704 +# error "__cpp_variadic_templates != 200704" +#endif + +#ifndef __cpp_initializer_lists +# error "__cpp_initializer_lists" +#elif __cpp_initializer_lists != 200806 +# error "__cpp_initializer_lists != 200806" +#endif + +#ifndef __cpp_delegating_constructors +# error "__cpp_delegating_constructors" +#elif __cpp_delegating_constructors != 200604 +# error "__cpp_delegating_constructors != 200604" +#endif + +#ifndef __cpp_nsdmi +# error "__cpp_nsdmi" +#elif __cpp_nsdmi != 200809 +# error "__cpp_nsdmi != 200809" +#endif + +#ifndef __cpp_inheriting_constructors +# error "__cpp_inheriting_constructors" +#elif __cpp_inheriting_constructors!= 200802 +# error "__cpp_inheriting_constructors != 200802" +#endif + +#ifndef __cpp_ref_qualifiers +# error "__cpp_ref_qualifiers" +#elif __cpp_ref_qualifiers != 200710 +# error "__cpp_ref_qualifiers != 200710" +#endif + +#ifndef __cpp_alias_templates +# error "__cpp_alias_templates" +#elif __cpp_alias_templates != 200704 +# error "__cpp_alias_templates != 200704" +#endif + +// C++14 features: + +#ifndef __cpp_binary_literals +# error "__cpp_binary_literals" +#elif __cpp_binary_literals != 201304 +# error "__cpp_binary_literals != 201304" +#endif + +#ifndef __cpp_init_captures +# error "__cpp_init_captures" +#elif __cpp_init_captures != 201304 +# error "__cpp_init_captures != 201304" +#endif + +#ifndef __cpp_generic_lambdas +# error "__cpp_generic_lambdas" +#elif __cpp_generic_lambdas != 201304 +# error "__cpp_generic_lambdas != 201304" +#endif + +#ifndef __cpp_constexpr +# error "__cpp_constexpr" +#elif __cpp_constexpr != 201304 +# error "__cpp_constexpr != 201304" +#endif + +#ifndef __cpp_decltype_auto +# error "__cpp_decltype_auto" +#elif __cpp_decltype_auto != 201304 +# error "__cpp_decltype_auto != 201304" +#endif + +#ifndef __cpp_return_type_deduction +# error "__cpp_return_type_deduction" +#elif __cpp_return_type_deduction != 201304 +# error "__cpp_return_type_deduction != 201304" +#endif + +#ifndef __cpp_aggregate_nsdmi +# error "__cpp_aggregate_nsdmi" +#elif __cpp_aggregate_nsdmi != 201304 +# error "__cpp_aggregate_nsdmi != 201304" +#endif + +#ifndef __cpp_variable_templates +# error "__cpp_variable_templates" +#elif __cpp_variable_templates != 201304 +# error "__cpp_variable_templates != 201304" +#endif + +#ifndef __cpp_digit_separators +# error "__cpp_digit_separators" +#elif __cpp_digit_separators != 201309 +# error "__cpp_digit_separators != 201309" +#endif + +#ifndef __cpp_sized_deallocation +# error "__cpp_sized_deallocation" +#elif __cpp_sized_deallocation != 201309 +# error "__cpp_sized_deallocation != 201309" +#endif + +// GNU VLA support: + +#ifndef __cpp_runtime_arrays +# error "__cpp_runtime_arrays" +#elif __cpp_runtime_arrays != 198712 +# error "__cpp_runtime_arrays != 198712" +#endif + +// C++11 attributes: + +#ifdef __has_cpp_attribute +# if ! __has_cpp_attribute(noreturn) +# error "__has_cpp_attribute(noreturn)" +# elif __has_cpp_attribute(noreturn) != 200809 +# error "__has_cpp_attribute(noreturn) != 200809" +# endif +#else +# error "__has_cpp_attribute" +#endif + +// Attribute carries_dependency not in yet. +//#ifdef __has_cpp_attribute +//# if ! __has_cpp_attribute(carries_dependency) +//# error "__has_cpp_attribute(carries_dependency)" +//# elif __has_cpp_attribute(carries_dependency) != 200809 +//# error "__has_cpp_attribute(carries_dependency) != 200809" +//# endif +//#else +//# error "__has_cpp_attribute" +//#endif + +// C++14 attributes: + +#ifdef __has_cpp_attribute +# if ! __has_cpp_attribute(deprecated) +# error "__has_cpp_attribute(deprecated)" +# elif __has_cpp_attribute(deprecated) != 201309 +# error "__has_cpp_attribute(deprecated) != 201309" +# endif +#else +# error "__has_cpp_attribute" +#endif + +// Include checks: + +// Check for __has_include macro. +#ifndef __has_include +# error "__has_include" +#endif + +// Quoted complex.h should find at least the bracket version (use operator). +#if __has_include__ "complex.h" +#else +# error "complex.h" +#endif + +// Try known bracket header (use operator). +#if __has_include__() +#else +# error "" +#endif + +// Define and use a macro to invoke the operator. +#define sluggo(TXT) __has_include__(TXT) + +#if sluggo() +#else +# error "" +#endif + +#if ! sluggo() +# error "" +#else +#endif + +// Quoted complex.h should find at least the bracket version. +#if __has_include("complex.h") +#else +# error "complex.h" +#endif + +// Try known local quote header. +#if __has_include("complex_literals.h") +#else +# error "\"complex_literals.h\"" +#endif + +// Try nonexistent bracket header. +#if __has_include() +# error "" +#else +#endif + +// Try nonexistent quote header. +#if __has_include("phlegm") +# error "\"phlegm\"" +#else +#endif + +// Test __has_include_next. +#if __has_include("phoobhar.h") +# include "phoobhar.h" +#else +# error "__has_include(\"phoobhar.h\")" +#endif + +// Try a macro. +#define COMPLEX_INC "complex.h" +#if __has_include(COMPLEX_INC) +#else +# error COMPLEX_INC +#endif + +// Realistic use of __has_include. +#if __has_include() +# define STD_ARRAY 1 +# include + template + using array = std::array<_Tp, _Num>; +#elif __has_include() +# define TR1_ARRAY 1 +# include + template + typedef std::tr1::array<_Tp, _Num> array; +#endif + +// C++17 features: + +#ifndef __cpp_unicode_characters +# error "__cpp_unicode_characters" +#elif __cpp_unicode_characters != 201411 +# error "__cpp_unicode_characters != 201411" +#endif #ifndef __cpp_static_assert # error "__cpp_static_assert" @@ -13,8 +314,26 @@ # error "__cpp_namespace_attributes != 201411" #endif +#ifndef __cpp_enumerator_attributes +# error "__cpp_enumerator_attributes" +#elif __cpp_enumerator_attributes != 201411 +# error "__cpp_enumerator_attributes != 201411" +#endif + #ifndef __cpp_nested_namespace_definitions # error "__cpp_nested_namespace_definitions" #elif __cpp_nested_namespace_definitions != 201411 # error "__cpp_nested_namespace_definitions != 201411" #endif + +#ifndef __cpp_fold_expressions +# error "__cpp_fold_expressions" +#elif __cpp_fold_expressions != 201411 +# error "__cpp_fold_expressions != 201411" +#endif + +#ifndef __cpp_nontype_template_args +# error "__cpp_nontype_template_args" +#elif __cpp_nontype_template_args != 201411 +# error "__cpp_nontype_template_args != 201411" +#endif diff --git a/gcc/testsuite/g++.dg/cpp1z/fold5.C b/gcc/testsuite/g++.dg/cpp1z/fold5.C index 0721419..da6544b 100644 --- a/gcc/testsuite/g++.dg/cpp1z/fold5.C +++ b/gcc/testsuite/g++.dg/cpp1z/fold5.C @@ -1,5 +1,5 @@ // Test that we complain about fold-expressions in C++11 and C++14. -// { dg-do compile { target c++11 } } +// { dg-do compile { target { c++11 && { ! c++1z } } } } template constexpr int f(T... t) diff --git a/gcc/testsuite/g++.dg/parse/crash31.C b/gcc/testsuite/g++.dg/parse/crash31.C index e7d6bdc..b7ca1e4 100644 --- a/gcc/testsuite/g++.dg/parse/crash31.C +++ b/gcc/testsuite/g++.dg/parse/crash31.C @@ -1,9 +1,9 @@ -struct A // { dg-message "not complete" } +struct A { - A : A; // { dg-error "expected|incomplete" } - A : B; // { dg-error "not declared|incomplete" } - A : A(); // { dg-error "undefined type|incomplete" } - A : B(); // { dg-error "function call|incomplete|not declared" } - A : A[]; // { dg-error "expected|array reference|incomplete" } - A : B[]; // { dg-error "not declared|expected|array reference|incomplete" } + A : A; // { dg-error "" } + A : B; // { dg-error "" } + A : A(); // { dg-error "" } + A : B(); // { dg-error "" } + A : A[]; // { dg-error "" } + A : B[]; // { dg-error "" } }; diff --git a/gcc/testsuite/g++.dg/template/call4.C b/gcc/testsuite/g++.dg/template/call4.C index 1f7eb4c..1958769 100644 --- a/gcc/testsuite/g++.dg/template/call4.C +++ b/gcc/testsuite/g++.dg/template/call4.C @@ -1,6 +1,6 @@ // PR c++/25364 -class OFX_PropertySuiteV1 +struct OFX_PropertySuiteV1 { static int propGetDouble (); }; diff --git a/gcc/testsuite/g++.dg/template/function1.C b/gcc/testsuite/g++.dg/template/function1.C index bceed9d..f234585 100644 --- a/gcc/testsuite/g++.dg/template/function1.C +++ b/gcc/testsuite/g++.dg/template/function1.C @@ -1,5 +1,5 @@ // PR c++/38647 -// { dg-do compile } +// { dg-do compile { target { ! c++1z } } } // { dg-prune-output "note" } template struct A {}; -- 2.7.4