]> granicus.if.org Git - clang/commitdiff
Fix <rdar://problem/6502934>. We were creating an ImplicitCastExpr
authorDouglas Gregor <dgregor@apple.com>
Fri, 16 Jan 2009 19:38:23 +0000 (19:38 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 16 Jan 2009 19:38:23 +0000 (19:38 +0000)
with reference type (it should be an lvalue with non-reference type).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62345 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h
lib/Sema/SemaExprCXX.cpp
test/SemaCXX/enum.cpp
test/SemaCXX/member-name-lookup.cpp

index 9ca1d3e9c9e6d0d1e7756c3d2b4e4f1c4ce88d3a..f8e50925360aeb3316869faec9f03a6ee4d7f919 100644 (file)
@@ -1076,7 +1076,8 @@ class RecordDecl : public TagDecl {
   /// If so, this cannot be contained in arrays or other structs as a member.
   bool HasFlexibleArrayMember : 1;
 
-  ///
+  /// AnonymousStructOrUnion - Whether this is the type of an
+  /// anonymous struct or union.
   bool AnonymousStructOrUnion : 1;
 
 protected:
index 73ac18eb1aa1b7a83d0bf66586f1819c02f8a97a..ba502ec7baa99fb30ec2368ebf85b9d7bd8b4e2f 100644 (file)
@@ -764,7 +764,8 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
   if (SCS.CopyConstructor) {
     // FIXME: Create a temporary object by calling the copy
     // constructor.
-    ImpCastExprToType(From, ToType);
+    ImpCastExprToType(From, ToType.getNonReferenceType(), 
+                      ToType->isReferenceType());
     return false;
   }
 
@@ -849,7 +850,8 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
     break;
 
   case ICK_Qualification:
-    ImpCastExprToType(From, ToType);
+    ImpCastExprToType(From, ToType.getNonReferenceType(), 
+                      ToType->isReferenceType());
     break;
 
   default:
index 7c44056e4979e59e6ddccf4c93078bce9a589603..7626e4ab6955b25ff059744e4e1d9035ecca5cdd 100644 (file)
@@ -1,5 +1,4 @@
 // RUN: clang -fsyntax-only -verify %s
-
 enum E {
   Val1,
   Val2
@@ -12,3 +11,15 @@ void f() {
   E e = Val1;
   float& fr = enumerator_type(Val2);
 }
+
+// <rdar://problem/6502934>
+typedef enum Foo {
+       A = 0,
+       B = 1
+} Foo;
+       
+       
+void bar() {
+       Foo myvar = A;
+       myvar = B;
+}
index 1eb83548c198cfceb3d47ef7c847817d67be1d34..4752f57acac4fcf8f2d0bffd33e24f1f19a16dc2 100644 (file)
@@ -59,10 +59,10 @@ void D::test_lookup() {
   f(0); // expected-error{{non-static member 'f' found in multiple base-class subobjects of type 'struct A'}}
   static_f(0); // okay
 
-  // FIXME: should work  E e = D::enumerator; // okay
+  E e = enumerator; // okay
   type t = 0; // okay
 
-  // FIXME:  E2 e2 = D::enumerator2; // okay
+  E2 e2 = enumerator2; // okay
 
   E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}}
 }