[cfe-commits] r131204 - in /cfe/trunk/lib/Sema: SemaDecl.cpp SemaDeclCXX.cpp

Sean Hunt scshunt at csclub.uwaterloo.ca
Wed May 11 15:50:12 PDT 2011


Author: coppro
Date: Wed May 11 17:50:12 2011
New Revision: 131204

URL: http://llvm.org/viewvc/llvm-project?rev=131204&view=rev
Log:
Commit some missing changes to the previous patch.

This means we get C++0x jump-across-intializer semantics correct.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=131204&r1=131203&r2=131204&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed May 11 17:50:12 2011
@@ -5657,13 +5657,25 @@
       //   program is ill-formed.
       // C++0x [dcl.init]p11:
       //   If no initializer is specified for an object, the object is
-      //   default-intiialized; [...].
+      //   default-intialized; [...].
     } else {
       // Check for jumps past the implicit initializer.  C++0x
       // clarifies that this applies to a "variable with automatic
       // storage duration", not a "local variable".
-      if (getLangOptions().CPlusPlus && Var->hasLocalStorage())
-        getCurFunction()->setHasBranchProtectedScope();
+      // C++0x [stmt.dcl]p3
+      //   A program that jumps from a point where a variable with automatic
+      //   storage duration is not ins cope to a point where it is in scope is
+      //   ill-formed unless the variable has scalar type, class type with a
+      //   trivial defautl constructor and a trivial destructor, a cv-qualified
+      //   version of one of these types, or an array of one of the preceding
+      //   types and is declared without an initializer.
+      if (getLangOptions().CPlusPlus && Var->hasLocalStorage() && Record) {
+        CXXRecordDecl *CXXRecord = cast<CXXRecordDecl>(Record->getDecl());
+        if (!getLangOptions().CPlusPlus0x ||
+            !CXXRecord->hasTrivialDefaultConstructor() ||
+            !CXXRecord->hasTrivialDestructor())
+          getCurFunction()->setHasBranchProtectedScope();
+      }
 
       InitializedEntity Entity = InitializedEntity::InitializeVariable(Var);
       InitializationKind Kind

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=131204&r1=131203&r2=131204&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed May 11 17:50:12 2011
@@ -3210,7 +3210,7 @@
           return true;
 
         // Don't try to initialize the anonymous union
-        // This is technically non-conformant, but sanity deamands it.
+        // This is technically non-conformant, but sanity demands it.
         continue;
       }
     }





More information about the cfe-commits mailing list