Commit c6653f43 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Fix possible crash when parsing layout qualifiers nodes.



Task-number: QTCREATORBUG-4563
Reviewed-by: default avatarLeandro Melo <leandro.melo@nokia.com>
parent 42732605
......@@ -290,11 +290,11 @@ public:
List<ExpressionAST *> *arguments;
} function;
int qualifier;
LayoutQualifier *layout;
List<LayoutQualifier *> *layout_list;
LayoutQualifierAST *layout;
List<LayoutQualifierAST *> *layout_list;
struct {
int qualifier;
List<LayoutQualifier *> *layout_list;
List<LayoutQualifierAST *> *layout_list;
} type_qualifier;
struct {
TypeAST *type;
......@@ -1394,7 +1394,7 @@ case $rule_number: {
ast(1) = makeAstNode<ParameterDeclarationAST>
(makeAstNode<QualifiedTypeAST>
(sym(1).qualifier, sym(3).param_declarator.type,
(List<LayoutQualifier *> *)0),
(List<LayoutQualifierAST *> *)0),
ParameterDeclarationAST::Qualifier(sym(2).qualifier),
sym(3).param_declarator.name);
} break;
......@@ -1415,7 +1415,7 @@ parameter_declaration ::= parameter_type_qualifier parameter_qualifier parameter
case $rule_number: {
ast(1) = makeAstNode<ParameterDeclarationAST>
(makeAstNode<QualifiedTypeAST>
(sym(1).qualifier, type(3), (List<LayoutQualifier *> *)0),
(sym(1).qualifier, type(3), (List<LayoutQualifierAST *> *)0),
ParameterDeclarationAST::Qualifier(sym(2).qualifier),
(const QString *)0);
} break;
......@@ -1605,7 +1605,7 @@ case $rule_number: {
fully_specified_type ::= type_specifier ;
/.
case $rule_number: {
ast(1) = makeAstNode<QualifiedTypeAST>(0, type(1), (List<LayoutQualifier *> *)0);
ast(1) = makeAstNode<QualifiedTypeAST>(0, type(1), (List<LayoutQualifierAST *> *)0);
} break;
./
......@@ -1656,28 +1656,28 @@ case $rule_number: {
layout_qualifier_id_list ::= layout_qualifier_id ;
/.
case $rule_number: {
sym(1).layout_list = makeAstNode< List<LayoutQualifier *> >(sym(1).layout);
sym(1).layout_list = makeAstNode< List<LayoutQualifierAST *> >(sym(1).layout);
} break;
./
layout_qualifier_id_list ::= layout_qualifier_id_list COMMA layout_qualifier_id ;
/.
case $rule_number: {
sym(1).layout_list = makeAstNode< List<LayoutQualifier *> >(sym(1).layout_list, sym(3).layout);
sym(1).layout_list = makeAstNode< List<LayoutQualifierAST *> >(sym(1).layout_list, sym(3).layout);
} break;
./
layout_qualifier_id ::= IDENTIFIER ;
/.
case $rule_number: {
sym(1).layout = makeAstNode<LayoutQualifier>(string(1), (const QString *)0);
sym(1).layout = makeAstNode<LayoutQualifierAST>(string(1), (const QString *)0);
} break;
./
layout_qualifier_id ::= IDENTIFIER EQUAL NUMBER ;
/.
case $rule_number: {
sym(1).layout = makeAstNode<LayoutQualifier>(string(1), string(3));
sym(1).layout = makeAstNode<LayoutQualifierAST>(string(1), string(3));
} break;
./
......
......@@ -354,6 +354,13 @@ List<StructTypeAST::Field *> *StructTypeAST::fixInnerTypes(TypeAST *innerType, L
return fields;
}
void LayoutQualifierAST::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
visitor->endVisit(this);
}
void QualifiedTypeAST::accept0(Visitor *visitor)
{
if (visitor->visit(this))
......
......@@ -69,6 +69,7 @@ class BasicTypeAST;
class NamedTypeAST;
class ArrayTypeAST;
class StructTypeAST;
class LayoutQualifierAST;
class QualifiedTypeAST;
class DeclarationAST;
class PrecisionDeclarationAST;
......@@ -214,6 +215,7 @@ public:
Kind_StructType,
Kind_AnonymousStructType,
Kind_StructField,
Kind_LayoutQualifier,
Kind_QualifiedType,
// Declarations
......@@ -260,6 +262,7 @@ public:
virtual ArrayTypeAST *asArrayType() { return 0; }
virtual StructTypeAST *asStructType() { return 0; }
virtual QualifiedTypeAST *asQualifiedType() { return 0; }
virtual LayoutQualifierAST *asLayoutQualifier() { return 0; }
virtual DeclarationAST *asDeclaration() { return 0; }
virtual PrecisionDeclarationAST *asPrecisionDeclaration() { return 0; }
......@@ -785,22 +788,24 @@ public: // attributes
List<Field *> *fields;
};
class GLSL_EXPORT LayoutQualifier
class GLSL_EXPORT LayoutQualifierAST: public AST
{
public:
LayoutQualifier(const QString *_name, const QString *_number)
: name(_name), number(_number), lineno(0) {}
LayoutQualifierAST(const QString *_name, const QString *_number)
: AST(Kind_LayoutQualifier), name(_name), number(_number) {}
virtual LayoutQualifierAST *asLayoutQualifier() { return this; }
virtual void accept0(Visitor *visitor);
public: // attributes
const QString *name;
const QString *number;
int lineno;
};
class GLSL_EXPORT QualifiedTypeAST: public TypeAST
{
public:
QualifiedTypeAST(int _qualifiers, TypeAST *_type, List<LayoutQualifier *> *_layout_list)
QualifiedTypeAST(int _qualifiers, TypeAST *_type, List<LayoutQualifierAST *> *_layout_list)
: TypeAST(Kind_QualifiedType), qualifiers(_qualifiers), type(_type)
, layout_list(finish(_layout_list)) {}
......@@ -840,7 +845,7 @@ public:
public: // attributes
int qualifiers;
TypeAST *type;
List<LayoutQualifier *> *layout_list;
List<LayoutQualifierAST *> *layout_list;
};
class GLSL_EXPORT DeclarationAST: public AST
......
......@@ -129,6 +129,9 @@ public:
virtual bool visit(StructTypeAST::Field *) { return true; }
virtual void endVisit(StructTypeAST::Field *) {}
virtual bool visit(LayoutQualifierAST *) { return true; }
virtual void endVisit(LayoutQualifierAST *) {}
virtual bool visit(QualifiedTypeAST *) { return true; }
virtual void endVisit(QualifiedTypeAST *) {}
......
This diff is collapsed.
#line 218 "./glsl.g"
#line 217 "./glsl.g"
/**************************************************************************
**
......@@ -76,11 +76,11 @@ public:
List<ExpressionAST *> *arguments;
} function;
int qualifier;
LayoutQualifier *layout;
List<LayoutQualifier *> *layout_list;
LayoutQualifierAST *layout;
List<LayoutQualifierAST *> *layout_list;
struct {
int qualifier;
List<LayoutQualifier *> *layout_list;
List<LayoutQualifierAST *> *layout_list;
} type_qualifier;
struct {
TypeAST *type;
......
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......@@ -29,7 +30,6 @@
**
**************************************************************************/
// This file was generated by qlalr - DO NOT EDIT!
#include "glslparsertable_p.h"
......
......@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......
......@@ -786,8 +786,8 @@ bool Semantic::visit(StructTypeAST *ast)
bool Semantic::visit(QualifiedTypeAST *ast)
{
_type = type(ast->type);
for (List<LayoutQualifier *> *it = ast->layout_list; it; it = it->next) {
LayoutQualifier *q = it->value;
for (List<LayoutQualifierAST *> *it = ast->layout_list; it; it = it->next) {
LayoutQualifierAST *q = it->value;
// q->name;
// q->number;
Q_UNUSED(q);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment