Skip to content

Commit

Permalink
Avoid clang warning: expression with side effects will be evaluated d…
Browse files Browse the repository at this point in the history
…espite being used as an operand to 'typeid'

This is not a useful warning here but simply extracting `*schema->at(0)`
to a variable avoids it.

Warning example: https://travis-ci.org/sass/libsass/jobs/471245025
Refs sass#1523
  • Loading branch information
glebm authored and xzyfer committed Feb 1, 2019
1 parent 2c47dbb commit c6b972e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ast_selectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,19 @@ namespace Sass {
bool Selector_Schema::has_parent_ref() const
{
if (String_Schema_Obj schema = Cast<String_Schema>(contents())) {
return !schema->empty() && typeid(*schema->at(0)) == typeid(Parent_Selector);
if (schema->empty()) return false;
const auto& first = *schema->at(0);
return typeid(first) == typeid(Parent_Selector);
}
return false;
}

bool Selector_Schema::has_real_parent_ref() const
{
if (String_Schema_Obj schema = Cast<String_Schema>(contents())) {
return !schema->empty() && typeid(*schema->at(0)) == typeid(Parent_Reference);
if (schema->empty()) return false;
const auto& first = *schema->at(0);
return typeid(first) == typeid(Parent_Reference);
}
return false;
}
Expand Down

0 comments on commit c6b972e

Please sign in to comment.