[cfe-commits] r43024 - in /cfe/trunk: Sema/SemaExpr.cpp test/Sema/cxx-references.cpp
Chris Lattner
sabre at nondot.org
Mon Oct 15 19:55:40 PDT 2007
Author: lattner
Date: Mon Oct 15 21:55:40 2007
New Revision: 43024
URL: http://llvm.org/viewvc/llvm-project?rev=43024&view=rev
Log:
initialization of references should not do default fn/array promotions.
This fixes a bug Anders noticed.
Modified:
cfe/trunk/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/cxx-references.cpp
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=43024&r1=43023&r2=43024&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Mon Oct 15 21:55:40 2007
@@ -1056,11 +1056,15 @@
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;
Modified: cfe/trunk/test/Sema/cxx-references.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/cxx-references.cpp?rev=43024&r1=43023&r2=43024&view=diff
==============================================================================
--- cfe/trunk/test/Sema/cxx-references.cpp (original)
+++ cfe/trunk/test/Sema/cxx-references.cpp Mon Oct 15 21:55:40 2007
@@ -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 @@
P[1] = 1;
}
-#endif
+typedef int t[1];
+void test2() {
+ t a;
+ t& b = a;
+
+
+ int c[3];
+ int (&rc)[3] = c;
+}
More information about the cfe-commits
mailing list