[llvm-branch-commits] [cfe-branch] r113151 - in /cfe/branches/release_28: ./ lib/AST/ExprConstant.cpp lib/CodeGen/CGExprAgg.cpp lib/Headers/stddef.h lib/Lex/Pragma.cpp lib/Sema/SemaExpr.cpp test/CodeGen/designated-initializers.c test/CodeGen/fold-const-declref.c test/Sema/warn-write-strings.c test/SemaCXX/i-c-e-cxx.cpp test/SemaCXX/unary-real-imag.cpp

Bill Wendling isanbard at gmail.com
Mon Sep 6 02:13:41 PDT 2010


Author: void
Date: Mon Sep  6 04:13:40 2010
New Revision: 113151

URL: http://llvm.org/viewvc/llvm-project?rev=113151&view=rev
Log:
Approved by Chris:

$ svn merge -c 113124 https://llvm.org/svn/llvm-project/cfe/trunk
--- Merging r113124 into '.':
A    test/SemaCXX/unary-real-imag.cpp
U    lib/Sema/SemaExpr.cpp

Log:
PR8023: Don't crash on invalid uses of __real__ on class types in C++.

$ svn merge -c 113125 https://llvm.org/svn/llvm-project/cfe/trunk
--- Merging r113125 into '.':
U    lib/Lex/Pragma.cpp

Log:
fix 7320: we can't delete a trailing space if it doesn't exist.

$ svn merge -c 113127 https://llvm.org/svn/llvm-project/cfe/trunk
--- Merging r113127 into '.':
U    test/Sema/warn-write-strings.c
U    lib/Headers/stddef.h

Log:
fix PR7192 by defining wchar_t in a more conventional way.  The
type of L"x" can change based on command line arguments.

$ svn merge -c 113128 https://llvm.org/svn/llvm-project/cfe/trunk
--- Merging r113128 into '.':
A    test/CodeGen/fold-const-declref.c
U    lib/AST/ExprConstant.cpp

Log:
PR7242: Make sure to use a different context for evaluating constant
initializers, so the result of the evaluation doesn't leak through
inconsistently.  Also, don't evaluate references to variables with
initializers with side-effects.

$ svn merge -c 113130 https://llvm.org/svn/llvm-project/cfe/trunk
--- Merging r113130 into '.':
U    test/CodeGen/designated-initializers.c
U    lib/CodeGen/CGExprAgg.cpp

Log:
move the hackaround for PR6537 to catch unions as well,
fixing the ICE in PR7151

$ svn merge -c 113131 https://llvm.org/svn/llvm-project/cfe/trunk
--- Merging r113131 into '.':
U    test/SemaCXX/i-c-e-cxx.cpp

Log:
Update test for r113128.

Added:
    cfe/branches/release_28/test/CodeGen/fold-const-declref.c
      - copied unchanged from r113128, cfe/trunk/test/CodeGen/fold-const-declref.c
    cfe/branches/release_28/test/SemaCXX/unary-real-imag.cpp
      - copied unchanged from r113124, cfe/trunk/test/SemaCXX/unary-real-imag.cpp
Modified:
    cfe/branches/release_28/   (props changed)
    cfe/branches/release_28/lib/AST/ExprConstant.cpp
    cfe/branches/release_28/lib/CodeGen/CGExprAgg.cpp
    cfe/branches/release_28/lib/Headers/stddef.h
    cfe/branches/release_28/lib/Lex/Pragma.cpp
    cfe/branches/release_28/lib/Sema/SemaExpr.cpp
    cfe/branches/release_28/test/CodeGen/designated-initializers.c
    cfe/branches/release_28/test/Sema/warn-write-strings.c
    cfe/branches/release_28/test/SemaCXX/i-c-e-cxx.cpp

Propchange: cfe/branches/release_28/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Mon Sep  6 04:13:40 2010
@@ -0,0 +1,2 @@
+/cfe/trunk:113124-113125,113127-113128,113130-113131
+/llvm/trunk:113124-113125

Modified: cfe/branches/release_28/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_28/lib/AST/ExprConstant.cpp?rev=113151&r1=113150&r2=113151&view=diff
==============================================================================
--- cfe/branches/release_28/lib/AST/ExprConstant.cpp (original)
+++ cfe/branches/release_28/lib/AST/ExprConstant.cpp Mon Sep  6 04:13:40 2010
@@ -1008,8 +1008,11 @@
 
         VD->setEvaluatingValue();
 
-        if (Visit(const_cast<Expr*>(Init))) {
+        Expr::EvalResult EResult;
+        if (Init->Evaluate(EResult, Info.Ctx) && !EResult.HasSideEffects &&
+            EResult.Val.isInt()) {
           // Cache the evaluated value in the variable declaration.
+          Result = EResult.Val;
           VD->setEvaluatedValue(Result);
           return true;
         }

Modified: cfe/branches/release_28/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_28/lib/CodeGen/CGExprAgg.cpp?rev=113151&r1=113150&r2=113151&view=diff
==============================================================================
--- cfe/branches/release_28/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/branches/release_28/lib/CodeGen/CGExprAgg.cpp Mon Sep  6 04:13:40 2010
@@ -582,8 +582,17 @@
   // the optimizer, especially with bitfields.
   unsigned NumInitElements = E->getNumInits();
   RecordDecl *SD = E->getType()->getAs<RecordType>()->getDecl();
-  unsigned CurInitVal = 0;
-
+  
+  // If we're initializing the whole aggregate, just do it in place.
+  // FIXME: This is a hack around an AST bug (PR6537).
+  if (NumInitElements == 1 && E->getType() == E->getInit(0)->getType()) {
+    EmitInitializationToLValue(E->getInit(0),
+                               CGF.MakeAddrLValue(DestPtr, E->getType()),
+                               E->getType());
+    return;
+  }
+  
+  
   if (E->getType()->isUnionType()) {
     // Only initialize one field of a union. The field itself is
     // specified by the initializer list.
@@ -615,19 +624,10 @@
 
     return;
   }
-  
-  // If we're initializing the whole aggregate, just do it in place.
-  // FIXME: This is a hack around an AST bug (PR6537).
-  if (NumInitElements == 1 && E->getType() == E->getInit(0)->getType()) {
-    EmitInitializationToLValue(E->getInit(0),
-                               CGF.MakeAddrLValue(DestPtr, E->getType()),
-                               E->getType());
-    return;
-  }
-  
 
   // Here we iterate over the fields; this makes it simpler to both
   // default-initialize fields and skip over unnamed fields.
+  unsigned CurInitVal = 0;
   for (RecordDecl::field_iterator Field = SD->field_begin(),
                                FieldEnd = SD->field_end();
        Field != FieldEnd; ++Field) {

Modified: cfe/branches/release_28/lib/Headers/stddef.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_28/lib/Headers/stddef.h?rev=113151&r1=113150&r2=113151&view=diff
==============================================================================
--- cfe/branches/release_28/lib/Headers/stddef.h (original)
+++ cfe/branches/release_28/lib/Headers/stddef.h Mon Sep  6 04:13:40 2010
@@ -34,7 +34,7 @@
 #ifndef __cplusplus
 #ifndef _WCHAR_T
 #define _WCHAR_T
-typedef __typeof__(*L"") wchar_t;
+typedef __WCHAR_TYPE__ wchar_t;
 #endif
 #endif
 

Modified: cfe/branches/release_28/lib/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_28/lib/Lex/Pragma.cpp?rev=113151&r1=113150&r2=113151&view=diff
==============================================================================
--- cfe/branches/release_28/lib/Lex/Pragma.cpp (original)
+++ cfe/branches/release_28/lib/Lex/Pragma.cpp Mon Sep  6 04:13:40 2010
@@ -384,7 +384,9 @@
       Lex(DependencyTok);
     }
 
-    Message.erase(Message.end()-1);
+    // Remove the trailing ' ' if present.
+    if (!Message.empty())
+      Message.erase(Message.end()-1);
     Diag(FilenameTok, diag::pp_out_of_date_dependency) << Message;
   }
 }

Modified: cfe/branches/release_28/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_28/lib/Sema/SemaExpr.cpp?rev=113151&r1=113150&r2=113151&view=diff
==============================================================================
--- cfe/branches/release_28/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/release_28/lib/Sema/SemaExpr.cpp Mon Sep  6 04:13:40 2010
@@ -6796,7 +6796,7 @@
                               UnaryOperatorKind Opc,
                               Expr *Input) {
   if (getLangOptions().CPlusPlus && Input->getType()->isOverloadableType() &&
-      Opc != UO_Extension) {
+      UnaryOperator::getOverloadedOperator(Opc) != OO_None) {
     // Find all of the overloaded operators visible from this
     // point. We perform both an operator-name lookup from the local
     // scope and an argument-dependent lookup based on the types of

Modified: cfe/branches/release_28/test/CodeGen/designated-initializers.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_28/test/CodeGen/designated-initializers.c?rev=113151&r1=113150&r2=113151&view=diff
==============================================================================
--- cfe/branches/release_28/test/CodeGen/designated-initializers.c (original)
+++ cfe/branches/release_28/test/CodeGen/designated-initializers.c Mon Sep  6 04:13:40 2010
@@ -8,10 +8,10 @@
 // CHECK: @u = global %union.anon zeroinitializer
 union { int i; float f; } u = { };
 
-// CHECK: @u2 = global %0 { i32 0, [4 x i8] undef }
+// CHECK: @u2 = global %1 { i32 0, [4 x i8] undef }
 union { int i; double f; } u2 = { };
 
-// CHECK: @u3 = global %1 zeroinitializer
+// CHECK: @u3 = global %2 zeroinitializer
 union { double f; int i; } u3 = { };
 
 // CHECK: @b = global [2 x i32] [i32 0, i32 22]
@@ -19,7 +19,7 @@
   [1] = 22
 };
 
-int main(int argc, char **argv)
+void test1(int argc, char **argv)
 {
   // CHECK: internal global %struct.foo { i8* null, i32 1024 }
   static struct foo foo = {
@@ -33,5 +33,24 @@
   // CHECK-NOT: call void @llvm.memset
   union { int i; float f; } u3;
 
-  // CHECK: ret i32
+  // CHECK: ret void
+}
+
+
+// PR7151
+struct S {
+  int nkeys;
+  int *keys;
+  union {
+    void *data;
+  };
+};
+
+void test2() {
+  struct S *btkr;
+  
+  *btkr = (struct S) {
+    .keys  = 0,
+    { .data  = 0 },
+  };
 }

Modified: cfe/branches/release_28/test/Sema/warn-write-strings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_28/test/Sema/warn-write-strings.c?rev=113151&r1=113150&r2=113151&view=diff
==============================================================================
--- cfe/branches/release_28/test/Sema/warn-write-strings.c (original)
+++ cfe/branches/release_28/test/Sema/warn-write-strings.c Mon Sep  6 04:13:40 2010
@@ -1,4 +1,10 @@
 // RUN: %clang_cc1 -verify -fsyntax-only -Wwrite-strings %s
 
 // PR4804
-char* x = "foo"; // expected-warning {{initializing 'char *' with an expression of type 'char const [4]' discards qualifiers}}
+char* x = "foo"; // expected-warning {{initializing 'char *' with an expression of type 'const char [4]' discards qualifiers}}
+
+// PR7192
+#include <stddef.h>
+void test(wchar_t *dst) {
+  dst[0] = 0;  // Ok.
+}

Modified: cfe/branches/release_28/test/SemaCXX/i-c-e-cxx.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_28/test/SemaCXX/i-c-e-cxx.cpp?rev=113151&r1=113150&r2=113151&view=diff
==============================================================================
--- cfe/branches/release_28/test/SemaCXX/i-c-e-cxx.cpp (original)
+++ cfe/branches/release_28/test/SemaCXX/i-c-e-cxx.cpp Mon Sep  6 04:13:40 2010
@@ -16,7 +16,7 @@
 }
 
 int a() {
-  const int t=t; // expected-note {{subexpression not valid}}
+  const int t=t;
   switch(1) { // expected-warning {{no case matching constant switch condition '1'}}
     case t:; // expected-error {{not an integer constant expression}}
   }





More information about the llvm-branch-commits mailing list