]> granicus.if.org Git - clang/commitdiff
Improved type source location for long long type.
authorAbramo Bagnara <abramo.bagnara@gmail.com>
Sun, 6 Mar 2011 22:21:56 +0000 (22:21 +0000)
committerAbramo Bagnara <abramo.bagnara@gmail.com>
Sun, 6 Mar 2011 22:21:56 +0000 (22:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127132 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/DeclSpec.cpp

index a154fbd79a967dba67b6e648e2ca389b334d1f0b..2f8a159336516aaa7977526a22642bb900a4d4fa 100644 (file)
@@ -380,12 +380,14 @@ bool DeclSpec::SetStorageClassSpecThread(SourceLocation Loc,
 bool DeclSpec::SetTypeSpecWidth(TSW W, SourceLocation Loc,
                                 const char *&PrevSpec,
                                 unsigned &DiagID) {
-  if (TypeSpecWidth != TSW_unspecified &&
-      // Allow turning long -> long long.
-      (W != TSW_longlong || TypeSpecWidth != TSW_long))
+  // Overwrite TSWLoc only if TypeSpecWidth was unspecified, so that
+  // for 'long long' we will keep the source location of the first 'long'.
+  if (TypeSpecWidth == TSW_unspecified)
+    TSWLoc = Loc;
+  // Allow turning long -> long long.
+  else if (W != TSW_longlong || TypeSpecWidth != TSW_long)
     return BadSpecifier(W, (TSW)TypeSpecWidth, PrevSpec, DiagID);
   TypeSpecWidth = W;
-  TSWLoc = Loc;
   if (TypeAltiVecVector && !TypeAltiVecBool &&
       ((TypeSpecWidth == TSW_long) || (TypeSpecWidth == TSW_longlong))) {
     PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);