diff options
author | Chris Lattner <sabre@nondot.org> | 2007-10-16 02:55:40 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-10-16 02:55:40 +0000 |
commit | 943140ee64e979325d25084bf4d768896601a7ce (patch) | |
tree | cca87efda803f9f22ac4547e10ee07692b70936e | |
parent | a1fe1176a40861cc66797e424e5aa6a6d1035219 (diff) |
initialization of references should not do default fn/array promotions.
This fixes a bug Anders noticed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43024 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Sema/SemaExpr.cpp | 8 | ||||
-rw-r--r-- | test/Sema/cxx-references.cpp | 13 |
2 files changed, 17 insertions, 4 deletions
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp index 8ee0913f99..046b92bb07 100644 --- a/Sema/SemaExpr.cpp +++ b/Sema/SemaExpr.cpp @@ -1056,11 +1056,15 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) { Sema::AssignmentCheckResult Sema::CheckSingleAssignmentConstraints(QualType lhsType, Expr *&rExpr) { - // This check seems unnatural, however it is necessary to insure the proper + // This check seems unnatural, however it is necessary to ensure the proper // conversion of functions/arrays. If the conversion were done for all // DeclExpr's (created by ActOnIdentifierExpr), it would mess up the unary // expressions that surpress this implicit conversion (&, sizeof). - DefaultFunctionArrayConversion(rExpr); + // + // Suppress this for references: C99 8.5.3p5. FIXME: revisit when references + // are better understood. + if (!lhsType->isReferenceType()) + DefaultFunctionArrayConversion(rExpr); Sema::AssignmentCheckResult result; diff --git a/test/Sema/cxx-references.cpp b/test/Sema/cxx-references.cpp index 74ad310395..a1c3eb5518 100644 --- a/test/Sema/cxx-references.cpp +++ b/test/Sema/cxx-references.cpp @@ -1,12 +1,13 @@ // RUN: clang -fsyntax-only %s int g(int); -#if 0 void f() { int i; int &r = i; r = 1; +#if 0 // FIXME: &ref not right yet int *p = &r; +#endif int &rr = r; int (&rg)(int) = g; rg(i); @@ -18,4 +19,12 @@ void f() { P[1] = 1; } -#endif +typedef int t[1]; +void test2() { + t a; + t& b = a; + + + int c[3]; + int (&rc)[3] = c; +} |