To add an extra class when there is no title
<h1<?php if(!get_the_title()){echo ' class="no-title"';}?>><?php the_title();?></h1>
Or to only display h1 tags when there is a title
<?php if(get_the_title()) { ?>
<h1><?php the_title();?></h1>
<?php }?>