]> granicus.if.org Git - clang/commitdiff
Add a test to ensure we don't permit mutable access on temporaries outside the evalua...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 23 Feb 2018 02:03:26 +0000 (02:03 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 23 Feb 2018 02:03:26 +0000 (02:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325854 91177308-0d34-0410-b5e6-96231b3b80d8

test/SemaCXX/constant-expression-cxx1y.cpp

index f81988c4db7384704f461867d290bf3eae7678d1..d22cba430adce582c27fae2457f9864c9028ac7b 100644 (file)
@@ -1028,13 +1028,14 @@ namespace Mutable {
   static_assert(k == 123, "");
 
   struct Q { A &&a; int b = a.n; };
-  constexpr Q q = { A{456} }; // ok
+  constexpr Q q = { A{456} }; // expected-note {{temporary}}
   static_assert(q.b == 456, "");
+  static_assert(q.a.n == 456, ""); // expected-error {{constant expression}} expected-note {{outside the expression that created the temporary}}
 
   constexpr A a = {123};
   constexpr int m = a.n; // expected-error {{constant expression}} expected-note {{mutable}}
 
-  constexpr Q r = { static_cast<A&&>(const_cast<A&>(a)) }; // expected-error {{constant expression}} expected-note@-7 {{mutable}}
+  constexpr Q r = { static_cast<A&&>(const_cast<A&>(a)) }; // expected-error {{constant expression}} expected-note@-8 {{mutable}}
 
   struct B {
     mutable int n; // expected-note {{here}}