Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarkus Schorn2008-04-16 12:30:23 -0400
committerMarkus Schorn2008-04-16 12:30:23 -0400
commitb7afd7af2c519cf732695405e36f685434fbd409 (patch)
tree3b4a6205edefcf0e534631d6078857421d046eca /core
parente4f737f6b10eb8b0d912700b9918443f095e397e (diff)
downloadorg.eclipse.cdt-b7afd7af2c519cf732695405e36f685434fbd409.tar.gz
org.eclipse.cdt-b7afd7af2c519cf732695405e36f685434fbd409.tar.xz
org.eclipse.cdt-b7afd7af2c519cf732695405e36f685434fbd409.zip
Testcase provided by Richard Miskin, bug 145389.
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java
index c354a3e4320..0fc8c8d2842 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java
@@ -710,6 +710,45 @@ public class CompleteParser2Tests extends BaseTestCase {
parse( "asm ( \"blah blah blah\" );" ); //$NON-NLS-1$
}
+
+ /**
+ * Tests GNU extensions to asm
+ * e.g. asm volatile ("stuff");
+ * asm ("addl %%ebx,%%eax" : "=a"(foo) : "a"(foo),"b"(bar) );
+ */
+ public void testGNUASMExtension() throws Exception
+ {
+ // volatile keyword
+ parse( "asm volatile( \"blah blah blah\" );", true, ParserLanguage.C, true ); //$NON-NLS-1$
+ parse( "asm volatile( \"blah blah blah\" );", true, ParserLanguage.CPP, true ); //$NON-NLS-1$
+
+ // Use of operands
+ parse( "asm (\"addl %%ebx,%%eax\" : \"=a\"(foo) :\"a\"(foo), \"b\"(bar) );", true, ParserLanguage.C, true );//$NON-NLS-1$
+ parse( "asm (\"addl %%ebx,%%eax\" : \"=a\"(foo) :\"a\"(foo), \"b\"(bar) );", true, ParserLanguage.CPP, true );//$NON-NLS-1$
+
+ // Invalid use of operands
+ parse( "asm (\"addl %%ebx,%%eax\" \"=a\"(foo) :\"a\"(foo) : \"b\"(bar) );", false, ParserLanguage.C, true );//$NON-NLS-1$
+ parse( "asm (\"addl %%ebx,%%eax\" \"=a\"(foo) :\"a\"(foo) : \"b\"(bar) );", false, ParserLanguage.CPP, true );//$NON-NLS-1$
+
+ // Code from bug 145389.
+ parse("#define mb() __asm__ __volatile__ (\"sync\" : : : \"memory\")\r\n" +
+ "\r\n" +
+ "int main(int argc, char **argv) {\r\n" +
+ " mb();\r\n" +
+ "}");
+ // Code from bug 117001
+ parse("static inline long\r\n" +
+ "div_ll_X_l_rem(long long divs, long div, long *rem)\r\n" +
+ "{\r\n" +
+ " long dum2;\r\n" +
+ " __asm__(\"divl %2\":\"=a\"(dum2), \"=d\"(*rem) // syntax error indicated at \":\"\r\n" +
+ " : \"rm\"(div), \"A\"(divs));\r\n" +
+ "\r\n" +
+ " return dum2;\r\n" +
+ "\r\n" +
+ "}");
+ }
+
public void testOverride() throws Exception
{
IASTTranslationUnit tu = parse( "void foo();\n void foo( int );\n"); //$NON-NLS-1$

Back to the top