[cfe-commits] r44375 - /cfe/trunk/Sema/SemaDecl.cpp
Chris Lattner
sabre at nondot.org
Tue Nov 27 13:21:36 PST 2007
Author: lattner
Date: Tue Nov 27 15:21:35 2007
New Revision: 44375
URL: http://llvm.org/viewvc/llvm-project?rev=44375&view=rev
Log:
Set loc earlier in CheckSingleInitializer to avoid emitting a
diagnostic without a location. This produces:
simpleTest.c:2:18: error: initializer element is not constant
int *myPointer = &(myArray[2]);
^~~~~~~~~~~~~
instead of:
error: initializer element is not constant
Modified:
cfe/trunk/Sema/SemaDecl.cpp
Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=44375&r1=44374&r2=44375&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Tue Nov 27 15:21:35 2007
@@ -359,7 +359,7 @@
bool Sema::CheckSingleInitializer(Expr *&Init, bool isStatic,
QualType DeclType) {
- SourceLocation loc;
+ SourceLocation loc = Init->getLocStart();
// FIXME: Remove the isReferenceType check and handle assignment
// to a reference.
@@ -370,7 +370,6 @@
}
AssignmentCheckResult result;
- loc = Init->getLocStart();
// Get the type before calling CheckSingleAssignmentConstraints(), since
// it can promote the expression.
QualType rhsType = Init->getType();
More information about the cfe-commits
mailing list