Hi,
In TargetInfo::isValidGCCRegisterName the Name might be empty again after
removing the %
Found on code like
register int foo asm("%" MACRO);
where MACRO was supposed to be defined in a header file that was not found.
Regards
--
Olivier
>From 0e4a4764f58c1c7bd66b83c37afaeefea569dbba Mon Sep 17 00:00:00 2001
From: Olivier Goffart <[email protected]>
Date: Thu, 7 Aug 2014 12:44:24 +0200
Subject: [PATCH] Fix assertion on asm register that are "%"
Name might be empty again after we removed the '%' prefix
and Name[0] would assert.
Found on code like
register int foo asm("%" MACRO);
where MACRO was supposed to be defined in a header file that was not found.
---
lib/Basic/TargetInfo.cpp | 2 ++
test/Sema/asm.c | 1 +
2 files changed, 3 insertions(+)
diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp
index aecf13b..a352980 100644
--- a/lib/Basic/TargetInfo.cpp
+++ b/lib/Basic/TargetInfo.cpp
@@ -338,6 +338,8 @@ bool TargetInfo::isValidGCCRegisterName(StringRef Name) const {
// Get rid of any register prefix.
Name = removeGCCRegisterPrefix(Name);
+ if (Name.empty())
+ return false;
getGCCRegNames(Names, NumNames);
diff --git a/test/Sema/asm.c b/test/Sema/asm.c
index 89c8c57..13ae25f 100644
--- a/test/Sema/asm.c
+++ b/test/Sema/asm.c
@@ -107,6 +107,7 @@ void test10(void){
register int r asm ("cx");
register int rr asm ("rr_asm"); // expected-error{{unknown register name 'rr_asm' in asm}}
+ register int rrr asm ("%"); // expected-error{{unknown register name '%' in asm}}
}
// This is just an assert because of the boolean conversion.
--
2.0.4
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits