if the location given points at the last token of the macro instantiation.
Fixes rdar://
9045701.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133804
91177308-0d34-0410-b5e6-
96231b3b80d8
SourceLocation Lexer::getLocForEndOfToken(SourceLocation Loc, unsigned Offset,
const SourceManager &SM,
const LangOptions &Features) {
- if (Loc.isInvalid() || !Loc.isFileID())
+ if (Loc.isInvalid())
return SourceLocation();
-
+
+ if (Loc.isMacroID()) {
+ if (Offset > 0 || !SM.isAtEndOfMacroInstantiation(Loc))
+ return SourceLocation(); // Points inside the macro instantiation.
+
+ // Continue and find the location just after the macro instantiation.
+ Loc = SM.getInstantiationRange(Loc).second;
+ }
+
unsigned Len = Lexer::MeasureTokenLength(Loc, SM, Features);
if (Len > Offset)
Len = Len - Offset;
X = 4 // expected-error{{expected ';' after expression}}
}
+// rdar://9045701
+void test9045701(int x) {
+#define VALUE 0
+ x = VALUE // expected-error{{expected ';' after expression}}
+}
// rdar://7980651
typedef int intptr_t; // expected-note {{'intptr_t' declared here}}