From: Douglas Gregor Date: Fri, 16 Jan 2009 19:38:23 +0000 (+0000) Subject: Fix . We were creating an ImplicitCastExpr X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=66b947fdf9104b53d7e8caa8f71ee0c0e3fe1521;p=clang Fix . We were creating an ImplicitCastExpr 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 --- diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 9ca1d3e9c9..f8e5092536 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -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: diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 73ac18eb1a..ba502ec7ba 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -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: diff --git a/test/SemaCXX/enum.cpp b/test/SemaCXX/enum.cpp index 7c44056e49..7626e4ab69 100644 --- a/test/SemaCXX/enum.cpp +++ b/test/SemaCXX/enum.cpp @@ -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); } + +// +typedef enum Foo { + A = 0, + B = 1 +} Foo; + + +void bar() { + Foo myvar = A; + myvar = B; +} diff --git a/test/SemaCXX/member-name-lookup.cpp b/test/SemaCXX/member-name-lookup.cpp index 1eb83548c1..4752f57aca 100644 --- a/test/SemaCXX/member-name-lookup.cpp +++ b/test/SemaCXX/member-name-lookup.cpp @@ -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}} }