Bug 396367 - The exception occurs when the refactoring is attempted on a file with syntactic errors
Summary: The exception occurs when the refactoring is attempted on a file with syntact...
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 8.1.1   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-11 21:19 EST by Farnaz Behrang CLA
Modified: 2020-09-04 15:26 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Farnaz Behrang CLA 2012-12-11 21:19:01 EST
In the following program...
==========
#include <stdio.h>
// Should not be here to create syntax error
#include <stdarg.h>
int main(void *var[], va_list ap) {
  int i=0;
  void *v;
  for (;;)
    v = va_arg(ap, void *); //extract statement
  return 0;
}
==========

If we remove the inclusion of stdarg.h, then there is a syntax error in the va_arg line. So, then if you try to extract, CDT throws the following exception:

 [ERROR] org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ProblemRuntimeException
at org.eclipse.cdt.internal.core.dom.rewrite.astwriter.StatementWriter.writeStatement(StatementWriter.java:151)
at org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriterVisitor.visit(ASTWriterVisitor.java:189)
at org.eclipse.cdt.internal.core.dom.rewrite.changegenerator.ChangeGeneratorWriterVisitor.visit(ChangeGeneratorWriterVisitor.java:334)
at org.eclipse.cdt.internal.core.dom.parser.c.CASTProblemStatement.accept(CASTProblemStatement.java:47)
at org.eclipse.cdt.internal.core.dom.rewrite.astwriter.StatementWriter.writeCompoundStatement(StatementWriter.java:381)
at org.eclipse.cdt.internal.core.dom.rewrite.astwriter.StatementWriter.writeStatement(StatementWriter.java:122)
at org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriterVisitor.visit(ASTWriterVisitor.java:189)

When you include the file, the syntax error is resolved, and the refactoring does not have a problem. 
May be a bug only because the refactoring should not throw an exception.