diff --git a/src/cmd_line.c b/src/cmd_line.c index a1fc4154cb..446baa06f1 100644 --- a/src/cmd_line.c +++ b/src/cmd_line.c @@ -4317,7 +4317,9 @@ default mode (e.g., exception handling). if (!option_kind_used[(int)optk_digit_separators]) { digit_separators_enabled = TRUE; } /* if */ - if (rvalue_references_enabled && !gpp_mode && !clang_mode) { + if (rvalue_references_enabled && + !gpp_version_is(<90000) && !clangcpp_version_is(<40000)) { + /* A field selection on a class prvalue is an xvalue (CWG 616). */ selection_from_prvalue_is_xvalue = TRUE; } /* if */ relaxed_constexpr_enabled = TRUE; diff --git a/src/exprutil.c b/src/exprutil.c index db22dd4b7b..7cbb6b71b3 100644 --- a/src/exprutil.c +++ b/src/exprutil.c @@ -25271,6 +25271,10 @@ is_temp can be NULL if that information is not needed. clear_expr_or_stmt_traversal_block(&tblock); tblock.process_expr = examine_expr_for_auto_object; tblock.follow_addressing_path = TRUE; + /* A prvalue.field xvalue (CWG 616) names a subobject of the class + prvalue, so the class object must be considered as well. */ + tblock.follow_class_rvalue_addressing_path = + selection_from_prvalue_is_xvalue; traverse_expr(expr, &tblock); is_auto_object = tblock.result; if (is_temp != NULL) *is_temp = tblock.is_temp; @@ -25321,6 +25325,10 @@ underlying entity is a temporary, return *is_temp set to TRUE. clear_expr_or_stmt_traversal_block(&tblock); tblock.process_expr = examine_expr_for_auto_object; tblock.follow_addressing_path = TRUE; + /* A pointer into a prvalue.field xvalue (CWG 616) addresses a + subobject of the class prvalue. */ + tblock.follow_class_rvalue_addressing_path = + selection_from_prvalue_is_xvalue; traverse_expr(expr, &tblock); is_addr_of_auto = tblock.result; *is_temp = tblock.is_temp; diff --git a/src/il_walk.c b/src/il_walk.c index 12b733b2cd..fa5ba55834 100644 --- a/src/il_walk.c +++ b/src/il_walk.c @@ -3266,10 +3266,10 @@ Tips for proper use of the follow_addressing_path mode: switch (op) { case eok_dot_field: /* x.y: Follow x. */ - /* We don't have to test for the prvalue.field case here because its - result is a prvalue and therefore wouldn't get here, unless - follow_class_rvalue_addressing_path is TRUE, in which case - we want to keep going anyway. */ + /* We don't have to test for the prvalue.field case here: it gets + here only if follow_class_rvalue_addressing_path is TRUE or if + its result is an xvalue (selection_from_prvalue_is_xvalue, + CWG 616), and in both cases we want to keep going. */ traverse_expr(operand1, tblock); break; case eok_points_to_field: @@ -3278,10 +3278,10 @@ Tips for proper use of the follow_addressing_path mode: break; case eok_pm_field: /* x.*pm: Follow x. */ - /* We don't have to test for the prvalue.*pm case here because its - result is a prvalue and therefore wouldn't get here, unless - follow_class_rvalue_addressing_path is TRUE, in which case - we want to keep going anyway. */ + /* We don't have to test for the prvalue.*pm case here: it gets + here only if follow_class_rvalue_addressing_path is TRUE or if + its result is an xvalue (selection_from_prvalue_is_xvalue, + CWG 616), and in both cases we want to keep going. */ traverse_expr(operand1, tblock); break; case eok_pm_points_to_field: diff --git a/src/interpret.c b/src/interpret.c index b06b001b3c..470dd4b303 100644 --- a/src/interpret.c +++ b/src/interpret.c @@ -23649,10 +23649,21 @@ after the constructor body has been interpreted. p_arg_ptr += 1; arg_size += 1; } /* for */ - if (dip->variant.constructor.value_initialization) { - /* If this is for value initialization, clear the storage first. - Do not, however, overwrite the first word (which may record the - inheritance hierarchy). */ + if (!dip->variant.constructor.value_initialization) { + /* Nothing to do. */ + } else if (!type_has_user_provided_default_constructor(class_type)) { + /* Value initialization of a class without a user-provided default + constructor zero-initializes the object before calling the + constructor, which need not initialize every subobject (e.g., a + member of a class whose implicit default constructor calls a + user-provided base class constructor). Mark the subobjects as + initialized, so that reading them is valid. */ + init_subobject_to_zero(ips, result_storage, class_type, + complete_object); + } else { + /* Otherwise, the object is not zero-initialized, but clear the + storage anyway. Do not, however, overwrite the first word (which + may record the inheritance hierarchy). */ a_byte_count n_class_bytes; a_boolean dummy = TRUE; n_class_bytes = f_value_bytes_for_type(ips, class_type, &dummy); @@ -31878,8 +31889,9 @@ the value representation of the integer value. result_addr = *(a_constexpr_address*)opnd1_value; } else { /* The first operand is a class rvalue: Create an address for - it. */ - mark_complete_object_initialized(opnd1_value); + it. Do not mark the object as fully initialized: since + C++20, a constexpr constructor can leave members + uninitialized, and reading those must be diagnosed. */ clear_address(&result_addr, opnd1_value); result_addr.alloc_seq_number = ips->storage_stack.alloc_seq(); } /* if */ @@ -32003,8 +32015,9 @@ the value representation of the integer value. result_addr = *(a_constexpr_address*)opnd1_value; } else { /* The first operand is a class rvalue: Create an address for - it. */ - mark_complete_object_initialized(opnd1_value); + it. Do not mark the object as fully initialized: since + C++20, a constexpr constructor can leave members + uninitialized, and reading those must be diagnosed. */ clear_address(&result_addr, opnd1_value); result_addr.alloc_seq_number = ips->storage_stack.alloc_seq(); } /* if */ diff --git a/src/pending_changes/gh-90-lifetime-extension-member-of-temporary.txt b/src/pending_changes/gh-90-lifetime-extension-member-of-temporary.txt new file mode 100644 index 0000000000..7f959814f5 --- /dev/null +++ b/src/pending_changes/gh-90-lifetime-extension-member-of-temporary.txt @@ -0,0 +1,20 @@ +[GH #90] +GNU and Clang C++ modes: lifetime extension through a member of a temporary + +When emulating GCC 9 or later or Clang 4 or later, selecting a member of a +class prvalue now produces an xvalue (Core issue 616), as it already did in +standard C++14 and later modes. Binding a reference to the member now +extends the lifetime of the whole temporary. For example, with +--g++ --gnu_version=150000: + + struct A { int b; ~A(); }; + const int &r = A().b; // A() was previously destroyed here. + +Constant evaluation also no longer treats every member of a class prvalue +as initialized when one is selected with "." or ".*". Since C++20, a +constexpr constructor can leave members uninitialized, and reading such a +member is now diagnosed instead of producing an indeterminate value. For +example, with --c++20: + + struct W { int n; constexpr W() {} }; + static_assert(W().n == 0); // Error: n is uninitialized. diff --git a/src/pending_changes/gh-90-value-init-zeroed-members.txt b/src/pending_changes/gh-90-value-init-zeroed-members.txt new file mode 100644 index 0000000000..83eb26ed53 --- /dev/null +++ b/src/pending_changes/gh-90-value-init-zeroed-members.txt @@ -0,0 +1,12 @@ +[GH #90] +Constexpr reads of zero-initialized members after value initialization + +Value initialization of a class without a user-provided default constructor +zero-initializes the object before calling the constructor. During +constant evaluation, the zeroed members were not treated as initialized, so +reading one that the constructor does not set was rejected. For example, +with --c++20: + + struct A { constexpr A() {} int x; }; + struct B : A { int y; }; + static_assert(B().x == 0); // Previously rejected. diff --git a/tests/expectations/edg_x86_64/imported.log b/tests/expectations/edg_x86_64/imported.log index 2c384ac8c4..42bb45d78a 100644 --- a/tests/expectations/edg_x86_64/imported.log +++ b/tests/expectations/edg_x86_64/imported.log @@ -7077,7 +7077,6 @@ gnu/cpp/cpp2a/consteval25.sft.cpp:fp:-DTEST_NUMBER=1 --c++20:FAIL: gnu/cpp/cpp2a/consteval32.sft.cpp:fn:-DTEST_NUMBER=1 --c++20:FAIL: gnu/cpp/cpp2a/constexpr-99287.sft.cpp:fp:-DTEST_NUMBER=1 --c++20:FAIL: gnu/cpp/cpp2a/constexpr-dynamic13.sft.cpp:fp:-DTEST_NUMBER=1 --c++20:FAIL: -gnu/cpp/cpp2a/constexpr-init18.sft.cpp:fp:-DTEST_NUMBER=1 --c++20:FAIL: gnu/cpp/cpp2a/constexpr-inst1.sft.cpp:fn:-DTEST_NUMBER=1 --c++14:FAIL: gnu/cpp/cpp2a/constexpr-inst2.sft.cpp:fp:-DTEST_NUMBER=1 --c++11:FAIL: gnu/cpp/cpp2a/constexpr-new11/test.mft.cpp:fp:-DTEST_NUMBER=1 --c++20:FAIL: @@ -7757,7 +7756,6 @@ gnu/cpp/init/new22.sft.cpp:fn:-DTEST_NUMBER=1:FAIL: gnu/cpp/init/new39.sft.cpp:rp:-DTEST_NUMBER=1:FAIL: gnu/cpp/init/new40.sft.cpp:rp:-DTEST_NUMBER=1:FAIL: gnu/cpp/init/null1.sft.cpp:fp:-DTEST_NUMBER=1 --c++11:FAIL: -gnu/cpp/init/ref19.sft.cpp:rp:-DTEST_NUMBER=1:FAIL: gnu/cpp/init/ref23.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: gnu/cpp/init/reference2.sft.cpp:fn:-DTEST_NUMBER=1:FAIL: gnu/cpp/init/self1.sft.cpp:fn:-DTEST_NUMBER=1 --c++11:FAIL: diff --git a/tests/tests/cwg/.cwg616.rto/default.1.1.txt b/tests/tests/cwg/.cwg616.rto/default.1.1.txt new file mode 100644 index 0000000000..b921d6c913 --- /dev/null +++ b/tests/tests/cwg/.cwg616.rto/default.1.1.txt @@ -0,0 +1 @@ +fe_only -DTEST_NUMBER=1 --c++14 Test_name.c diff --git a/tests/tests/cwg/.cwg616.rto/default.2.1.txt b/tests/tests/cwg/.cwg616.rto/default.2.1.txt new file mode 100644 index 0000000000..fe264f46a7 --- /dev/null +++ b/tests/tests/cwg/.cwg616.rto/default.2.1.txt @@ -0,0 +1 @@ +fe_only -DTEST_NUMBER=2 --c++14 --g++ --gnu_version=150000 Test_name.c diff --git a/tests/tests/cwg/.cwg616.rto/default.3.1.txt b/tests/tests/cwg/.cwg616.rto/default.3.1.txt new file mode 100644 index 0000000000..8d04c2fe9a --- /dev/null +++ b/tests/tests/cwg/.cwg616.rto/default.3.1.txt @@ -0,0 +1 @@ +fe_only -DTEST_NUMBER=3 --c++14 --clang --clang_version=190100 Test_name.c diff --git a/tests/tests/cwg/cwg616.sft.cpp b/tests/tests/cwg/cwg616.sft.cpp new file mode 100644 index 0000000000..93b2f78782 --- /dev/null +++ b/tests/tests/cwg/cwg616.sft.cpp @@ -0,0 +1,14 @@ +//type:fp +//options_all:--c++14 +//options::--g++ --gnu_version=150000:--clang --clang_version=190100 +template struct is_xvalue { static const bool value = false; }; +template struct is_xvalue { static const bool value = true; }; +struct A { int b; }; +// Selecting a member of a class prvalue produces an xvalue. +static_assert(is_xvalue::value, ""); +static_assert(is_xvalue::value, ""); + +//cwg: 616 +//title: Definition of "indeterminate value" +//meeting: Bristol 4/13 +//edg_status: Passes diff --git a/tests/tests/imported/clang/cpp/CXX/dcl.decl/dcl.init/dcl.init.general/.p16-cxx20.rto/default.1.1.txt b/tests/tests/imported/clang/cpp/CXX/dcl.decl/dcl.init/dcl.init.general/.p16-cxx20.rto/default.1.1.txt index b0262c2eb2..c3898711d9 100644 --- a/tests/tests/imported/clang/cpp/CXX/dcl.decl/dcl.init/dcl.init.general/.p16-cxx20.rto/default.1.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/dcl.decl/dcl.init/dcl.init.general/.p16-cxx20.rto/default.1.1.txt @@ -1,11 +1,4 @@ fe_only -DTEST_NUMBER=1 --clang -tused -e 200 --no_wrap_diagnostics --clang_version 999999 --c++20 Test_name.c -"Test_name.c", line 16: error: expression must have a constant value - static_assert(B().x == 0); - ^ -"Test_name.c", line 16: note: access to uninitialized object - static_assert(B().x == 0); - ^ - "Test_name.c", line 27: error: class "P0960R3::A" has no suitable copy constructor A a1(va); ^ @@ -144,4 +137,4 @@ fe_only -DTEST_NUMBER=1 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers D d8 = {vdd}; // expected-error {{no matching constructor for initialization of 'D'}} ^ -31 errors detected in the compilation of "Test_name.c". +30 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.3.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.3.1.txt index 23c8ab2e65..9db8cdbba4 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.3.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.3.1.txt @@ -43,18 +43,6 @@ fe_only -DTEST_NUMBER=3 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -635,4 +623,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -107 errors detected in the compilation of "Test_name.c". +104 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.4.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.4.1.txt index 1738068cba..9d2c6600d9 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.4.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.4.1.txt @@ -43,18 +43,6 @@ fe_only -DTEST_NUMBER=4 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -628,4 +616,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -107 errors detected in the compilation of "Test_name.c". +104 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.5.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.5.1.txt index 2311036199..86fe3e2a79 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.5.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.5.1.txt @@ -43,18 +43,6 @@ fe_only -DTEST_NUMBER=5 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -612,4 +600,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -103 errors detected in the compilation of "Test_name.c". +100 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.6.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.6.1.txt index 1781ea59f2..d6dd6d1ccd 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.6.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.6.1.txt @@ -43,18 +43,6 @@ fe_only -DTEST_NUMBER=6 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -600,4 +588,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -100 errors detected in the compilation of "Test_name.c". +97 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.7.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.7.1.txt index 0f65ec7845..d00f917a4b 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.7.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/default.7.1.txt @@ -43,18 +43,6 @@ fe_only -DTEST_NUMBER=7 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -600,4 +588,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -100 errors detected in the compilation of "Test_name.c". +97 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.3.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.3.1.txt index dd07f0d241..0237b2b78c 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.3.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.3.1.txt @@ -47,18 +47,6 @@ fe_only -DTEST_NUMBER=3 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -639,4 +627,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -107 errors detected in the compilation of "Test_name.c". +104 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.4.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.4.1.txt index b69b1360c8..299ea9b490 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.4.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.4.1.txt @@ -47,18 +47,6 @@ fe_only -DTEST_NUMBER=4 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -632,4 +620,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -107 errors detected in the compilation of "Test_name.c". +104 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.5.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.5.1.txt index b217fad05c..ba06bd79e4 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.5.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.5.1.txt @@ -47,18 +47,6 @@ fe_only -DTEST_NUMBER=5 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -616,4 +604,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -103 errors detected in the compilation of "Test_name.c". +100 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.6.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.6.1.txt index 99646fb4ff..81340c010d 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.6.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.6.1.txt @@ -47,18 +47,6 @@ fe_only -DTEST_NUMBER=6 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -604,4 +592,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -100 errors detected in the compilation of "Test_name.c". +97 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.7.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.7.1.txt index b8e9100361..b990a2e817 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.7.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32.7.1.txt @@ -47,18 +47,6 @@ fe_only -DTEST_NUMBER=7 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -604,4 +592,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -100 errors detected in the compilation of "Test_name.c". +97 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.3.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.3.1.txt index d0dcb23e1c..e5e25bd263 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.3.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.3.1.txt @@ -47,18 +47,6 @@ fe_only -DTEST_NUMBER=3 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -651,4 +639,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -110 errors detected in the compilation of "Test_name.c". +107 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.4.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.4.1.txt index 5fe2dded14..05fb67f79d 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.4.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.4.1.txt @@ -47,18 +47,6 @@ fe_only -DTEST_NUMBER=4 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -644,4 +632,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -110 errors detected in the compilation of "Test_name.c". +107 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.5.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.5.1.txt index 1713a4fe68..8c3b9e6f7e 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.5.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.5.1.txt @@ -47,18 +47,6 @@ fe_only -DTEST_NUMBER=5 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -620,4 +608,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -104 errors detected in the compilation of "Test_name.c". +101 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.6.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.6.1.txt index b5fddc6c90..181f32677d 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.6.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.6.1.txt @@ -47,18 +47,6 @@ fe_only -DTEST_NUMBER=6 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -608,4 +596,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -101 errors detected in the compilation of "Test_name.c". +98 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.7.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.7.1.txt index d639969d32..c677f6521e 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.7.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_32_cp.7.1.txt @@ -47,18 +47,6 @@ fe_only -DTEST_NUMBER=7 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -608,4 +596,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -101 errors detected in the compilation of "Test_name.c". +98 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.3.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.3.1.txt index ceda8113e7..78fad00fa7 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.3.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.3.1.txt @@ -43,18 +43,6 @@ fe_only -DTEST_NUMBER=3 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -647,4 +635,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -110 errors detected in the compilation of "Test_name.c". +107 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.4.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.4.1.txt index e17ca6ed9b..afdfeedeb0 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.4.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.4.1.txt @@ -43,18 +43,6 @@ fe_only -DTEST_NUMBER=4 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -640,4 +628,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -110 errors detected in the compilation of "Test_name.c". +107 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.5.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.5.1.txt index fa617603ee..620594a888 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.5.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.5.1.txt @@ -43,18 +43,6 @@ fe_only -DTEST_NUMBER=5 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -616,4 +604,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -104 errors detected in the compilation of "Test_name.c". +101 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.6.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.6.1.txt index 7376d54ce6..b1f83c40fc 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.6.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.6.1.txt @@ -43,18 +43,6 @@ fe_only -DTEST_NUMBER=6 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -604,4 +592,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -101 errors detected in the compilation of "Test_name.c". +98 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.7.1.txt b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.7.1.txt index c247b4210d..4b40e10f9f 100644 --- a/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.7.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/drs/.cwg6xx.rto/edg_x86_64_cp.7.1.txt @@ -43,18 +43,6 @@ fe_only -DTEST_NUMBER=7 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers const std::type_info &an2 = typeid(n + 1); ^ -"Test_name.c", line 213: error: invalid redeclaration of type name "cwg616::T" (declared at line 212) - using T = decltype((static_cast(s).n)); - ^ - -"Test_name.c", line 214: error: invalid redeclaration of type name "cwg616::T" (declared at line 213) - using T = decltype((f().n)); - ^ - -"Test_name.c", line 215: error: invalid redeclaration of type name "cwg616::T" (declared at line 214) - using T = decltype(S().*&S::n); - ^ - "Test_name.c", line 246: error: incomplete type "int []" is not allowed sizeof(x); ^ @@ -604,4 +592,4 @@ At end of source: error: expected a "}" constexpr int c = true || f(); ^ -101 errors detected in the compilation of "Test_name.c". +98 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/default.2.1.txt b/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/default.2.1.txt index ad76d16536..8665cb9052 100644 --- a/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/default.2.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/default.2.1.txt @@ -365,6 +365,13 @@ fe_only -DTEST_NUMBER=2 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers constexpr volatile S f() { return S(); } // cxx20-warning {{volatile-qualified return type 'volatile S' is deprecated}} ^ +"Test_name.c", line 362: error: expression must have a constant value + static_assert(f().i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} + ^ +"Test_name.c", line 362: note: attempt to read from volatile storage + static_assert(f().i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} + ^ + "Test_name.c", line 363: error: expression must have a constant value static_assert(((volatile const S&&)(S)0).i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} ^ @@ -1140,4 +1147,4 @@ fe_only -DTEST_NUMBER=2 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers constexpr bool v8 = qv > (void*)&s.a; ^ -93 errors detected in the compilation of "Test_name.c". +94 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/edg_x86_32.2.1.txt b/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/edg_x86_32.2.1.txt index ad790e2063..b880afe7f7 100644 --- a/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/edg_x86_32.2.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/edg_x86_32.2.1.txt @@ -374,6 +374,13 @@ fe_only -DTEST_NUMBER=2 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers constexpr volatile S f() { return S(); } // cxx20-warning {{volatile-qualified return type 'volatile S' is deprecated}} ^ +"Test_name.c", line 362: error: expression must have a constant value + static_assert(f().i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} + ^ +"Test_name.c", line 362: note: attempt to read from volatile storage + static_assert(f().i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} + ^ + "Test_name.c", line 363: error: expression must have a constant value static_assert(((volatile const S&&)(S)0).i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} ^ @@ -1156,4 +1163,4 @@ fe_only -DTEST_NUMBER=2 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers constexpr intptr_t i = f((intptr_t)&foo - 10); // expected-error{{constexpr variable 'i' must be initialized by a constant expression}} \ ^ -95 errors detected in the compilation of "Test_name.c". +96 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/edg_x86_32_cp.2.1.txt b/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/edg_x86_32_cp.2.1.txt index 41df730ffc..6cc6c6b4c2 100644 --- a/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/edg_x86_32_cp.2.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/edg_x86_32_cp.2.1.txt @@ -362,6 +362,13 @@ fe_only -DTEST_NUMBER=2 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers constexpr volatile S f() { return S(); } // cxx20-warning {{volatile-qualified return type 'volatile S' is deprecated}} ^ +"Test_name.c", line 362: error: expression must have a constant value + static_assert(f().i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} + ^ +"Test_name.c", line 362: note: attempt to read from volatile storage + static_assert(f().i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} + ^ + "Test_name.c", line 363: error: expression must have a constant value static_assert(((volatile const S&&)(S)0).i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} ^ @@ -1144,4 +1151,4 @@ fe_only -DTEST_NUMBER=2 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers constexpr intptr_t i = f((intptr_t)&foo - 10); // expected-error{{constexpr variable 'i' must be initialized by a constant expression}} \ ^ -95 errors detected in the compilation of "Test_name.c". +96 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/edg_x86_64_cp.2.1.txt b/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/edg_x86_64_cp.2.1.txt index 57fddb4333..c74f13ebbb 100644 --- a/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/edg_x86_64_cp.2.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/expr/expr.const/.p2-0x.rto/edg_x86_64_cp.2.1.txt @@ -353,6 +353,13 @@ fe_only -DTEST_NUMBER=2 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers constexpr volatile S f() { return S(); } // cxx20-warning {{volatile-qualified return type 'volatile S' is deprecated}} ^ +"Test_name.c", line 362: error: expression must have a constant value + static_assert(f().i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} + ^ +"Test_name.c", line 362: note: attempt to read from volatile storage + static_assert(f().i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} + ^ + "Test_name.c", line 363: error: expression must have a constant value static_assert(((volatile const S&&)(S)0).i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} ^ @@ -1128,4 +1135,4 @@ fe_only -DTEST_NUMBER=2 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers constexpr bool v8 = qv > (void*)&s.a; ^ -93 errors detected in the compilation of "Test_name.c". +94 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/CXX/special/class.init/class.inhctor.init/.p1.rto/default.1.1.txt b/tests/tests/imported/clang/cpp/CXX/special/class.init/class.inhctor.init/.p1.rto/default.1.1.txt index b861f68325..bad18c1ab6 100644 --- a/tests/tests/imported/clang/cpp/CXX/special/class.init/class.inhctor.init/.p1.rto/default.1.1.txt +++ b/tests/tests/imported/clang/cpp/CXX/special/class.init/class.inhctor.init/.p1.rto/default.1.1.txt @@ -38,17 +38,4 @@ fe_only -DTEST_NUMBER=1 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers ^ detected during implicit generation of "vbase::D::B(int, int)" at line 89 -"Test_name.c", line 125: error: expression must have a constant value - constexpr Wrap2 b = {}; - ^ -"Test_name.c", line 117: note: access to uninitialized object - constexpr Param(int c) : n(4 * b.a + b.b + c) {} - ^ -"Test_name.c", line 123: note: called from: - constexpr Wrap1::Wrap1() : B(1) {} - ^ -"Test_name.c", line 112: note: called from: - struct Wrap2 : Wrap1 {}; - ^ - -10 errors detected in the compilation of "Test_name.c". +9 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/default.1.1.txt b/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/default.1.1.txt index bffb5a08a7..a9aa510486 100644 --- a/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/default.1.1.txt +++ b/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/default.1.1.txt @@ -321,14 +321,14 @@ fe_only -DTEST_NUMBER=1 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers ^ "SemaCXX/constant-expression-cxx2a.cpp", line 586: note: access to uninitialized object static_assert(Y(0,0).z1.n == 0); - ^ + ^ "SemaCXX/constant-expression-cxx2a.cpp", line 587: error: expression must have a constant value static_assert(Y(0,0).z3.n == 0); ^ "SemaCXX/constant-expression-cxx2a.cpp", line 587: note: access to uninitialized object static_assert(Y(0,0).z3.n == 0); - ^ + ^ "SemaCXX/constant-expression-cxx2a.cpp", line 589: error: expression must have a constant value static_assert(copy(Y(0,0)).z2.n == 0); diff --git a/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/edg_x86_32.1.1.txt b/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/edg_x86_32.1.1.txt index 5de6cdae54..adc5caf7af 100644 --- a/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/edg_x86_32.1.1.txt +++ b/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/edg_x86_32.1.1.txt @@ -321,14 +321,14 @@ fe_only -DTEST_NUMBER=1 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers ^ "SemaCXX/constant-expression-cxx2a.cpp", line 586: note: access to uninitialized object static_assert(Y(0,0).z1.n == 0); - ^ + ^ "SemaCXX/constant-expression-cxx2a.cpp", line 587: error: expression must have a constant value static_assert(Y(0,0).z3.n == 0); ^ "SemaCXX/constant-expression-cxx2a.cpp", line 587: note: access to uninitialized object static_assert(Y(0,0).z3.n == 0); - ^ + ^ "SemaCXX/constant-expression-cxx2a.cpp", line 589: error: expression must have a constant value static_assert(copy(Y(0,0)).z2.n == 0); diff --git a/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/edg_x86_32_cp.1.1.txt b/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/edg_x86_32_cp.1.1.txt index cc21dc7a33..674a683226 100644 --- a/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/edg_x86_32_cp.1.1.txt +++ b/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/edg_x86_32_cp.1.1.txt @@ -335,14 +335,14 @@ fe_only -DTEST_NUMBER=1 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers ^ "SemaCXX/constant-expression-cxx2a.cpp", line 586: note: access to uninitialized object static_assert(Y(0,0).z1.n == 0); - ^ + ^ "SemaCXX/constant-expression-cxx2a.cpp", line 587: error: expression must have a constant value static_assert(Y(0,0).z3.n == 0); ^ "SemaCXX/constant-expression-cxx2a.cpp", line 587: note: access to uninitialized object static_assert(Y(0,0).z3.n == 0); - ^ + ^ "SemaCXX/constant-expression-cxx2a.cpp", line 589: error: expression must have a constant value static_assert(copy(Y(0,0)).z2.n == 0); diff --git a/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/edg_x86_64_cp.1.1.txt b/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/edg_x86_64_cp.1.1.txt index cb6067532a..227b3e7bd3 100644 --- a/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/edg_x86_64_cp.1.1.txt +++ b/tests/tests/imported/clang/cpp/SemaCXX/.constant-expression-cxx2a.rto/edg_x86_64_cp.1.1.txt @@ -335,14 +335,14 @@ fe_only -DTEST_NUMBER=1 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers ^ "SemaCXX/constant-expression-cxx2a.cpp", line 586: note: access to uninitialized object static_assert(Y(0,0).z1.n == 0); - ^ + ^ "SemaCXX/constant-expression-cxx2a.cpp", line 587: error: expression must have a constant value static_assert(Y(0,0).z3.n == 0); ^ "SemaCXX/constant-expression-cxx2a.cpp", line 587: note: access to uninitialized object static_assert(Y(0,0).z3.n == 0); - ^ + ^ "SemaCXX/constant-expression-cxx2a.cpp", line 589: error: expression must have a constant value static_assert(copy(Y(0,0)).z2.n == 0); diff --git a/tests/tests/imported/clang/cpp/SemaCXX/.constexpr-value-init.rto/default.1.1.txt b/tests/tests/imported/clang/cpp/SemaCXX/.constexpr-value-init.rto/default.1.1.txt index dbe90c1c66..060b495068 100644 --- a/tests/tests/imported/clang/cpp/SemaCXX/.constexpr-value-init.rto/default.1.1.txt +++ b/tests/tests/imported/clang/cpp/SemaCXX/.constexpr-value-init.rto/default.1.1.txt @@ -30,16 +30,6 @@ fe_only -DTEST_NUMBER=1 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers struct B { // expected-note {{in call to 'A()'}} ^ -"Test_name.c", line 22: error: expression must have a constant value - constexpr B b2 = B(); // ok - ^ -"Test_name.c", line 7: note: access to uninitialized object - constexpr A() : a(b + 1), b(a + 1) {} // expected-note 5{{outside its lifetime}} - ^ -"Test_name.c", line 11: note: called from: - struct B { // expected-note {{in call to 'A()'}} - ^ - "Test_name.c", line 30: error: const variable "c1" requires an initializer -- class "C" has no user-provided default constructor constexpr C c1; // expected-error {{without a user-provided default constructor}} ^ @@ -67,16 +57,6 @@ fe_only -DTEST_NUMBER=1 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers constexpr E e1; // expected-error {{constant expression}} expected-note {{in call to 'E()'}} ^ -"Test_name.c", line 47: error: expression must have a constant value - constexpr E e2 = E(); - ^ -"Test_name.c", line 7: note: access to uninitialized object - constexpr A() : a(b + 1), b(a + 1) {} // expected-note 5{{outside its lifetime}} - ^ -"Test_name.c", line 46: note: called from: - constexpr E e1; // expected-error {{constant expression}} expected-note {{in call to 'E()'}} - ^ - "Test_name.c", line 59: error: incomplete type "InvalidDeclInsideConstExpr::i<1>" is not allowed i g; // expected-error {{implicit instantiation of undefined template 'InvalidDeclInsideConstExpr::i<1>'}} ^ @@ -118,4 +98,4 @@ fe_only -DTEST_NUMBER=1 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers constexpr E e1; // expected-error {{constant expression}} expected-note {{in call to 'E()'}} ^ -12 errors detected in the compilation of "Test_name.c". +10 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/SemaCXX/.constexpr-value-init.rto/default.2.1.txt b/tests/tests/imported/clang/cpp/SemaCXX/.constexpr-value-init.rto/default.2.1.txt index 413803bd7f..20da054180 100644 --- a/tests/tests/imported/clang/cpp/SemaCXX/.constexpr-value-init.rto/default.2.1.txt +++ b/tests/tests/imported/clang/cpp/SemaCXX/.constexpr-value-init.rto/default.2.1.txt @@ -30,16 +30,6 @@ fe_only -DTEST_NUMBER=2 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers struct B { // expected-note {{in call to 'A()'}} ^ -"Test_name.c", line 22: error: expression must have a constant value - constexpr B b2 = B(); // ok - ^ -"Test_name.c", line 7: note: access to uninitialized object - constexpr A() : a(b + 1), b(a + 1) {} // expected-note 5{{outside its lifetime}} - ^ -"Test_name.c", line 11: note: called from: - struct B { // expected-note {{in call to 'A()'}} - ^ - "Test_name.c", line 30: error: const variable "c1" requires an initializer -- class "C" has no user-provided default constructor constexpr C c1; // expected-error {{without a user-provided default constructor}} ^ @@ -67,16 +57,6 @@ fe_only -DTEST_NUMBER=2 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers constexpr E e1; // expected-error {{constant expression}} expected-note {{in call to 'E()'}} ^ -"Test_name.c", line 47: error: expression must have a constant value - constexpr E e2 = E(); - ^ -"Test_name.c", line 7: note: access to uninitialized object - constexpr A() : a(b + 1), b(a + 1) {} // expected-note 5{{outside its lifetime}} - ^ -"Test_name.c", line 46: note: called from: - constexpr E e1; // expected-error {{constant expression}} expected-note {{in call to 'E()'}} - ^ - "Test_name.c", line 59: error: incomplete type "InvalidDeclInsideConstExpr::i<1>" is not allowed i g; // expected-error {{implicit instantiation of undefined template 'InvalidDeclInsideConstExpr::i<1>'}} ^ @@ -118,4 +98,4 @@ fe_only -DTEST_NUMBER=2 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers constexpr E e1; // expected-error {{constant expression}} expected-note {{in call to 'E()'}} ^ -12 errors detected in the compilation of "Test_name.c". +10 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/clang/cpp/SemaCXX/.cxx2c-placeholder-vars.rto/default.1.1.txt b/tests/tests/imported/clang/cpp/SemaCXX/.cxx2c-placeholder-vars.rto/default.1.1.txt index 277238cca3..67ead7a95a 100644 --- a/tests/tests/imported/clang/cpp/SemaCXX/.cxx2c-placeholder-vars.rto/default.1.1.txt +++ b/tests/tests/imported/clang/cpp/SemaCXX/.cxx2c-placeholder-vars.rto/default.1.1.txt @@ -267,10 +267,6 @@ fe_only -DTEST_NUMBER=1 --clang -tused -e 200 --no_wrap_diagnostics --clang_vers int _, _; // expected-warning {{placeholder variables are incompatible with C++ standards before C++2c}} \ ^ -"Test_name.c", line 236: warning: expression has no effect - S{}._; // expected-error {{ambiguous reference to placeholder '_', which is defined multiple times}} - ^ - "Test_name.c", line 235: warning: variable "s" was declared but never referenced S s{._ =0}; // expected-error {{ambiguous reference to placeholder '_', which is defined multiple times}} ^ diff --git a/tests/tests/imported/gnu/cpp/cpp0x/.constexpr-delegating3.rto/default.1.1.txt b/tests/tests/imported/gnu/cpp/cpp0x/.constexpr-delegating3.rto/default.1.1.txt index fe3eb50e9e..1026717d8f 100644 --- a/tests/tests/imported/gnu/cpp/cpp0x/.constexpr-delegating3.rto/default.1.1.txt +++ b/tests/tests/imported/gnu/cpp/cpp0x/.constexpr-delegating3.rto/default.1.1.txt @@ -1,9 +1,9 @@ fe_only -DTEST_NUMBER=1 --gnu_version=999999 -tused -e 200 --no_wrap --no_wrap_diagnostics --c++11 Test_name.c -"Test_name.c", line 12: error: static assertion failed with "" +"Test_name.c", line 12: error: expression must have a constant value static_assert(test(0).m == 0, ""); - ^ -"Test_name.c", line 12: note: the final comparison was -48039863565308959547770532813896688677 == 0 + ^ +"Test_name.c", line 12: note: access to uninitialized object static_assert(test(0).m == 0, ""); - ^ + ^ 1 error detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/gnu/cpp/cpp0x/.constexpr-delegating3.rto/edg_x86_32.1.1.txt b/tests/tests/imported/gnu/cpp/cpp0x/.constexpr-delegating3.rto/edg_x86_32.1.1.txt deleted file mode 100644 index 439ecda17a..0000000000 --- a/tests/tests/imported/gnu/cpp/cpp0x/.constexpr-delegating3.rto/edg_x86_32.1.1.txt +++ /dev/null @@ -1,9 +0,0 @@ -fe_only -DTEST_NUMBER=1 --gnu_version=999999 -tused -e 200 --no_wrap --no_wrap_diagnostics --c++11 Test_name.c -"Test_name.c", line 12: error: static assertion failed with "" - static_assert(test(0).m == 0, ""); - ^ -"Test_name.c", line 12: note: the final comparison was -2604246222170760229 == 0 - static_assert(test(0).m == 0, ""); - ^ - -1 error detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/gnu/cpp/cpp0x/.constexpr-delegating3.rto/edg_x86_32_cp.1.1.txt b/tests/tests/imported/gnu/cpp/cpp0x/.constexpr-delegating3.rto/edg_x86_32_cp.1.1.txt deleted file mode 100644 index 439ecda17a..0000000000 --- a/tests/tests/imported/gnu/cpp/cpp0x/.constexpr-delegating3.rto/edg_x86_32_cp.1.1.txt +++ /dev/null @@ -1,9 +0,0 @@ -fe_only -DTEST_NUMBER=1 --gnu_version=999999 -tused -e 200 --no_wrap --no_wrap_diagnostics --c++11 Test_name.c -"Test_name.c", line 12: error: static assertion failed with "" - static_assert(test(0).m == 0, ""); - ^ -"Test_name.c", line 12: note: the final comparison was -2604246222170760229 == 0 - static_assert(test(0).m == 0, ""); - ^ - -1 error detected in the compilation of "Test_name.c". diff --git a/tests/tests/imported/gnu/cpp/cpp2a/.constexpr-init18.rto/default.1.1.txt b/tests/tests/imported/gnu/cpp/cpp2a/.constexpr-init18.rto/default.1.1.txt index 73ead29a37..2ed4eaf390 100644 --- a/tests/tests/imported/gnu/cpp/cpp2a/.constexpr-init18.rto/default.1.1.txt +++ b/tests/tests/imported/gnu/cpp/cpp2a/.constexpr-init18.rto/default.1.1.txt @@ -1,16 +1 @@ fe_only -DTEST_NUMBER=1 --gnu_version=999999 -tused -e 200 --no_wrap --no_wrap_diagnostics --c++20 Test_name.c -"Test_name.c", line 14: error: initialization is not constant - constexpr t<1> h1; - ^ -"Test_name.c", line 14: note: access to uninitialized subobject (member "e::w") - constexpr t<1> h1; - ^ - -"Test_name.c", line 17: error: initialization is not constant - constexpr t<42> h2; - ^ -"Test_name.c", line 17: note: access to uninitialized subobject (member "e::w") - constexpr t<42> h2; - ^ - -2 errors detected in the compilation of "Test_name.c". diff --git a/tests/tests/regressions/.gh-90-old-modes.rto/default.1.1.txt b/tests/tests/regressions/.gh-90-old-modes.rto/default.1.1.txt new file mode 100644 index 0000000000..38d19b508a --- /dev/null +++ b/tests/tests/regressions/.gh-90-old-modes.rto/default.1.1.txt @@ -0,0 +1 @@ +fe_only -DTEST_NUMBER=1 --c++14 --g++ --gnu_version=80300 Test_name.c diff --git a/tests/tests/regressions/.gh-90-old-modes.rto/default.2.1.txt b/tests/tests/regressions/.gh-90-old-modes.rto/default.2.1.txt new file mode 100644 index 0000000000..fdbcccb1e7 --- /dev/null +++ b/tests/tests/regressions/.gh-90-old-modes.rto/default.2.1.txt @@ -0,0 +1 @@ +fe_only -DTEST_NUMBER=2 --c++14 --clang --clang_version=30900 Test_name.c diff --git a/tests/tests/regressions/.gh-90-warn.rto/default.1.1.txt b/tests/tests/regressions/.gh-90-warn.rto/default.1.1.txt new file mode 100644 index 0000000000..14477c2b8b --- /dev/null +++ b/tests/tests/regressions/.gh-90-warn.rto/default.1.1.txt @@ -0,0 +1,13 @@ +fe_only -DTEST_NUMBER=1 --c++20 Test_name.c +"Test_name.c", line 13: warning: returning reference to local temporary + const int &f1() { return A().b; } // Warning. + ^ + +"Test_name.c", line 14: warning: returning pointer to local temporary + const int *f2() { return &static_cast(A().b); } // Warning. + ^ + +"Test_name.c", line 15: warning: returning reference to local temporary + int &&f3() { return static_cast(A()).b; } // Warning. + ^ + diff --git a/tests/tests/regressions/.gh-90-warn.rto/default.2.1.txt b/tests/tests/regressions/.gh-90-warn.rto/default.2.1.txt new file mode 100644 index 0000000000..c31dbdcd95 --- /dev/null +++ b/tests/tests/regressions/.gh-90-warn.rto/default.2.1.txt @@ -0,0 +1,13 @@ +fe_only -DTEST_NUMBER=2 --c++20 --g++ --gnu_version=150000 Test_name.c +"Test_name.c", line 13: warning: returning reference to local temporary + const int &f1() { return A().b; } // Warning. + ^ + +"Test_name.c", line 14: warning: returning pointer to local temporary + const int *f2() { return &static_cast(A().b); } // Warning. + ^ + +"Test_name.c", line 15: warning: returning reference to local temporary + int &&f3() { return static_cast(A()).b; } // Warning. + ^ + diff --git a/tests/tests/regressions/.gh-90-warn.rto/default.3.1.txt b/tests/tests/regressions/.gh-90-warn.rto/default.3.1.txt new file mode 100644 index 0000000000..cfb8e39f76 --- /dev/null +++ b/tests/tests/regressions/.gh-90-warn.rto/default.3.1.txt @@ -0,0 +1,13 @@ +fe_only -DTEST_NUMBER=3 --c++20 --g++ --gnu_version=80000 Test_name.c +"Test_name.c", line 13: warning: returning reference to local temporary + const int &f1() { return A().b; } // Warning. + ^ + +"Test_name.c", line 14: warning: returning pointer to local temporary + const int *f2() { return &static_cast(A().b); } // Warning. + ^ + +"Test_name.c", line 15: warning: returning reference to local temporary + int &&f3() { return static_cast(A()).b; } // Warning. + ^ + diff --git a/tests/tests/regressions/.gh-90-warn.rto/default.4.1.txt b/tests/tests/regressions/.gh-90-warn.rto/default.4.1.txt new file mode 100644 index 0000000000..10046374bd --- /dev/null +++ b/tests/tests/regressions/.gh-90-warn.rto/default.4.1.txt @@ -0,0 +1,13 @@ +fe_only -DTEST_NUMBER=4 --c++20 --clang --clang_version=190100 Test_name.c +"Test_name.c", line 13: warning: returning reference to local temporary + const int &f1() { return A().b; } // Warning. + ^ + +"Test_name.c", line 14: warning: returning pointer to local temporary + const int *f2() { return &static_cast(A().b); } // Warning. + ^ + +"Test_name.c", line 15: warning: returning reference to local temporary + int &&f3() { return static_cast(A()).b; } // Warning. + ^ + diff --git a/tests/tests/regressions/.gh-90.rto/default.1.1.txt b/tests/tests/regressions/.gh-90.rto/default.1.1.txt new file mode 100644 index 0000000000..30e4550776 --- /dev/null +++ b/tests/tests/regressions/.gh-90.rto/default.1.1.txt @@ -0,0 +1 @@ +eccp -DTEST_NUMBER=1 --c++14 Test_name.c diff --git a/tests/tests/regressions/.gh-90.rto/default.1.2.txt b/tests/tests/regressions/.gh-90.rto/default.1.2.txt new file mode 100644 index 0000000000..ff2642c6d5 --- /dev/null +++ b/tests/tests/regressions/.gh-90.rto/default.1.2.txt @@ -0,0 +1 @@ +./a.out diff --git a/tests/tests/regressions/.gh-90.rto/default.2.1.txt b/tests/tests/regressions/.gh-90.rto/default.2.1.txt new file mode 100644 index 0000000000..b424c530a9 --- /dev/null +++ b/tests/tests/regressions/.gh-90.rto/default.2.1.txt @@ -0,0 +1 @@ +eccp -DTEST_NUMBER=2 --c++20 Test_name.c diff --git a/tests/tests/regressions/.gh-90.rto/default.2.2.txt b/tests/tests/regressions/.gh-90.rto/default.2.2.txt new file mode 100644 index 0000000000..ff2642c6d5 --- /dev/null +++ b/tests/tests/regressions/.gh-90.rto/default.2.2.txt @@ -0,0 +1 @@ +./a.out diff --git a/tests/tests/regressions/.gh-90.rto/default.3.1.txt b/tests/tests/regressions/.gh-90.rto/default.3.1.txt new file mode 100644 index 0000000000..6a31461038 --- /dev/null +++ b/tests/tests/regressions/.gh-90.rto/default.3.1.txt @@ -0,0 +1 @@ +eccp -DTEST_NUMBER=3 --c++14 --g++ --gnu_version=90000 Test_name.c diff --git a/tests/tests/regressions/.gh-90.rto/default.3.2.txt b/tests/tests/regressions/.gh-90.rto/default.3.2.txt new file mode 100644 index 0000000000..ff2642c6d5 --- /dev/null +++ b/tests/tests/regressions/.gh-90.rto/default.3.2.txt @@ -0,0 +1 @@ +./a.out diff --git a/tests/tests/regressions/.gh-90.rto/default.4.1.txt b/tests/tests/regressions/.gh-90.rto/default.4.1.txt new file mode 100644 index 0000000000..582096beac --- /dev/null +++ b/tests/tests/regressions/.gh-90.rto/default.4.1.txt @@ -0,0 +1 @@ +eccp -DTEST_NUMBER=4 --c++20 --g++ --gnu_version=150000 Test_name.c diff --git a/tests/tests/regressions/.gh-90.rto/default.4.2.txt b/tests/tests/regressions/.gh-90.rto/default.4.2.txt new file mode 100644 index 0000000000..ff2642c6d5 --- /dev/null +++ b/tests/tests/regressions/.gh-90.rto/default.4.2.txt @@ -0,0 +1 @@ +./a.out diff --git a/tests/tests/regressions/.gh-90.rto/default.5.1.txt b/tests/tests/regressions/.gh-90.rto/default.5.1.txt new file mode 100644 index 0000000000..7a32723bd5 --- /dev/null +++ b/tests/tests/regressions/.gh-90.rto/default.5.1.txt @@ -0,0 +1 @@ +eccp -DTEST_NUMBER=5 --c++14 --clang --clang_version=40000 Test_name.c diff --git a/tests/tests/regressions/.gh-90.rto/default.5.2.txt b/tests/tests/regressions/.gh-90.rto/default.5.2.txt new file mode 100644 index 0000000000..ff2642c6d5 --- /dev/null +++ b/tests/tests/regressions/.gh-90.rto/default.5.2.txt @@ -0,0 +1 @@ +./a.out diff --git a/tests/tests/regressions/.gh-90.rto/default.6.1.txt b/tests/tests/regressions/.gh-90.rto/default.6.1.txt new file mode 100644 index 0000000000..36d2f6899d --- /dev/null +++ b/tests/tests/regressions/.gh-90.rto/default.6.1.txt @@ -0,0 +1 @@ +eccp -DTEST_NUMBER=6 --c++20 --clang --clang_version=190100 Test_name.c diff --git a/tests/tests/regressions/.gh-90.rto/default.6.2.txt b/tests/tests/regressions/.gh-90.rto/default.6.2.txt new file mode 100644 index 0000000000..ff2642c6d5 --- /dev/null +++ b/tests/tests/regressions/.gh-90.rto/default.6.2.txt @@ -0,0 +1 @@ +./a.out diff --git a/tests/tests/regressions/gh-90-old-modes.sft.cpp b/tests/tests/regressions/gh-90-old-modes.sft.cpp new file mode 100644 index 0000000000..ec95e6f196 --- /dev/null +++ b/tests/tests/regressions/gh-90-old-modes.sft.cpp @@ -0,0 +1,10 @@ +//type:fp +//options_all:--c++14 +//options:--g++ --gnu_version=80300:--clang --clang_version=30900 +// GCC before 9 and Clang before 4 do not implement Core issue 616: selecting +// a member of a class prvalue still produces a prvalue (the C++11 rule). +template struct is_prvalue { static const bool value = true; }; +template struct is_prvalue { static const bool value = false; }; +template struct is_prvalue { static const bool value = false; }; +struct A { int b; }; +static_assert(is_prvalue::value, ""); diff --git a/tests/tests/regressions/gh-90-warn.sft.cpp b/tests/tests/regressions/gh-90-warn.sft.cpp new file mode 100644 index 0000000000..476bdbbae9 --- /dev/null +++ b/tests/tests/regressions/gh-90-warn.sft.cpp @@ -0,0 +1,21 @@ +//type:fp +//options_all:--c++20 +//options::--g++ --gnu_version=150000:--g++ --gnu_version=80000:--clang --clang_version=190100 + +// Returning a reference or pointer into a member of a class prvalue returns +// a reference into a local temporary. When "A().b" is an xvalue (Core issue +// 616), that is still diagnosed, as it is when "A().b" is a prvalue. + +struct A { int b; ~A(); }; +struct R { int &r; int *p; }; +int g; + +const int &f1() { return A().b; } // Warning. +const int *f2() { return &static_cast(A().b); } // Warning. +int &&f3() { return static_cast(A()).b; } // Warning. + +// No warnings for these. +const int &n1() { return R{g, &g}.r; } +const int &n2() { return *R{g, &g}.p; } +const int &n3(A &&a) { return static_cast(a).b; } +int n4() { return A().b; } diff --git a/tests/tests/regressions/gh-90.sft.cpp b/tests/tests/regressions/gh-90.sft.cpp new file mode 100644 index 0000000000..d1b2d17bbc --- /dev/null +++ b/tests/tests/regressions/gh-90.sft.cpp @@ -0,0 +1,53 @@ +//type:rp +//options:--c++14:--c++20:--c++14 --g++ --gnu_version=90000:--c++20 --g++ --gnu_version=150000:--c++14 --clang --clang_version=40000:--c++20 --clang --clang_version=190100 + +// Binding a reference to a subobject of a temporary extends the lifetime of +// the whole temporary (N4140 [class.temporary]/5). In GNU and Clang modes, +// "A().b" was a prvalue (the C++11 rule), so the reference was bound to a +// copy of the member and the A temporary was destroyed at the end of the +// full-expression. GCC 9 and Clang 4 implement Core issue 616, under which +// "A().b" is an xvalue that designates the member of the temporary. + +int d; +struct A { + int b; + int i[2]; + ~A() { ++d; } +}; + +int failures; +void check(bool ok) { if (!ok) ++failures; } + +int main() { + { + const int &r = A().b; + check(d == 0); // Previously failed in GNU and Clang modes. + } + check(d == 1); + d = 0; + { + int &&r = A().b; + check(d == 0); // Previously failed in GNU and Clang modes. + } + check(d == 1); + d = 0; + { + const int &r = A().i[0]; + check(d == 0); + } + check(d == 1); + d = 0; + { + int A::*pm = &A::b; + const int &r = A().*pm; + check(d == 0); + } + check(d == 1); + d = 0; + { + int (&&r)[2] = A().i; + check(d == 0); + } + check(d == 1); + return failures; +}